Scripts / Help getting started with scripting

Author
Message
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 23rd Dec 2018 12:24
Hi.

I'm only getting started with scripting in GameGuru but I have faced a problem right at the beginning.
I figured I start with a very simple script that display a message on the screen if the player is for certain distance from an entity and also hide the entity. But I can't get it to work.

This is my code:



It doesn't work and I have no idea why. I don't get the text on the screen not even the Initialized one and the entity never get hidden.
I don't have much experience with Lua but I do have some experience with other languages but have no idea why is this not working.
I have the script inside the scriptbank folder, I have attached the script to the entity, the entity is in the scene not sure what else I need to do.

I also tried the example script from the Steam Guide and that doesn't work neither.

Could anyone give me a kick in the right direction please?

Thanks.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Dec 2018 12:33 Edited at: 23rd Dec 2018 12:47
Is the script called myscript.lua ?

Is the entity you've attached it to active? Hover over it in the editor and it should highlight green not red.

You probably won't see the first Prompt btw, the init function is called before you get to seen anything on screen, use PromptDuration(str,v) instead, the 'v' part is milliseconds so 3000 would display the string for 3 seconds.
Been there, done that, got all the T-Shirts!
PM
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 23rd Dec 2018 12:38
Thanks, the problem was the script file didn't have the same name as the functions
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Dec 2018 12:48
Cool, so you're off and running now then.
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-05-08 19:40:46
Your offset time is: 2024-05-08 19:40:46