Scripts / Am I Doing Somehing Wrong With This Script?

Author
Message
TheSourceCode
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 12th Apr 2015 18:22
Okay, first let me say I am very noob when it comes to scripting, and thats why I am learnign it. But anyways, I made this text script here:
function text_init(e)
end
function text_init(e)
Prompt(str)
PromptDuration(str,1200)
PromptTextSize(3)
PromptLocal(e, "Hello"")
Text(125,125,size,txt)
TextCenterOnX(350,350,size,txt)
end
end

that I want it to show text when the player stands on the trigger zone,
but everytime I make a trigger marker and select the script, an error pops up saying: "scriptback\text.lua: unfinished string near ' ")' "

All help is appreciated.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Apr 2015 19:21 Edited at: 12th Apr 2015 21:01
sorry but this is funny
you have literally used every single command to show text there... you only need 1.

i'll explain their uses...
Prompt(str) <- replace 'str' with the text you wish to show
e.g.
Prompt("Hello")

PromptDuration(str,1200) <--same as above but uses a time setting before it disappears
e.g. (will show Hello for 1.2seconds)
PromptDuration("Hello",1200)

PromptTextSize(3) <--sets the size of the text on screen while using the prompt commands (not really seen this used, you certainly don't have to if you're happy with the default size)

PromptLocal(e, "Hello"") <-- shows text at the bottom of the entity defined at 'e' (not at bottom of screen is the difference here)


Text(125,125,size,txt) <-- a more complete version of the prompt command (you need to place the text in % of screen, 100 being max, so 125 - as in your code - wont be shown)

TextCenterOnX(350,350,size,txt) <-- better version of above command, again you need value from 1~100 really, size of 1 is default
e.g. (will show Hello at bottom center of screen similar to a prompt call)
TextCenterOnX(95,50,1,"Hello")

now for your actual request you also need an 'if' statement to check the player is inside the zone otherwise the text will always show

apply this code script to your zone
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
TheSourceCode
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 12th Apr 2015 19:34
Like I said before, I am a complete noob and this is my first attempt for scripting. Figures some pro would get a laugh from it. lol

But anyways, thanks a ton!!!
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 12th Apr 2015 20:24
If I'm not wrong, you use this statment twice:

function text_init(e)
end

instead of use:



3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 8.1 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Apr 2015 21:05
sorry if i sounded rude, it's only funny because it's kind of like you're shouting at your script with so many prompt calls, we all have to start somewhere, nothing wrong with being new
3com is correct though, you should use main(e) for the second function part, i didn't notice that.
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
TheSourceCode
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 13th Apr 2015 17:26
SmallG, you didn't sound rude, just made me feel a little bad with my script.

But all is alright, thanks for the help you are giving.

(Also, thank you 3com. )
PM

Login to post a reply

Server time is: 2024-12-21 14:29:34
Your offset time is: 2024-12-21 14:29:34