Scripts / [SOLVED] Lua and scripting

Author
Message
Baldielocks
1
Years of Service
User Offline
Joined: 17th Jun 2022
Location: Grimsby,
Posted: 22nd Jun 2022 12:12
Hi folks, Couple of questions. I`m trying to get a wall to disappear when I flick a switch. Can`t for the life of me get it to work with the inbuilt logic. So I presume I need to script Lua ( which I think I will need if I am to progress further using GG Max). Now I`ve done some programming before but never Lua so I`ve bought a book to read and assist me. What do I use to create the scripts and how do I attach them of assets i.e. the switch. All help is greatly appreciated.

The author of this post has marked a post as an answer.

Go to answer
PM
Baldielocks
1
Years of Service
User Offline
Joined: 17th Jun 2022
Location: Grimsby,
Posted: 23rd Jun 2022 11:01
I`ve asked on steam and I`ve bought and downloaded Lua Pad+ so the creating scripts should be no problem ( just limited by my ability to start with.)
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 23rd Jun 2022 16:01
@ Baldielocks
Attach the script below to the wall.
Follow the video steps.

https://youtu.be/5yNEddngbsg

Sorry, miss the relationship on the video, please, refer to pic below.



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

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Jun 2022 20:02
Recommend you edit your scripts with notepad++
Been there, done that, got all the T-Shirts!
PM
Baldielocks
1
Years of Service
User Offline
Joined: 17th Jun 2022
Location: Grimsby,
Posted: 24th Jun 2022 18:28
Thanks for that, It works but not as I intended the walls can be walked through when visible, I played around with a few settings and I can keep the wall solid but when it disappears where it was can`t walk through where it was. There must be a command to destroy an object is there or can you turn solid physics on / off through scripting. This would be handy as I could the make walls disappear to pass that way and reappear to block a way.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 24th Jun 2022 20:20
ColisionOn( e ) and CollisionOff( e ) are the commands you are looking for.
Been there, done that, got all the T-Shirts!
PM
Baldielocks
1
Years of Service
User Offline
Joined: 17th Jun 2022
Location: Grimsby,
Posted: 25th Jun 2022 10:02
That works perfect AmenMosses. Thank you for the help. By the way I just stuck CollisionOff(e) after Hide(e) I take it this is bad practice and I should have placed it on line below but before end ?
One last question if you don`t mind g_Entity[e]['activated'] == 1 is then the entity is on and ==0 is when it is off, so if I put if g_Entity[e] == 0 then Show(e) it would show entity and any code after that would run if entity is off ?
I know this may seam a little obvious too many but I`m only just getting back into this now I have time to spare and I haven`t done any programming since the 80`s Cheers Guys.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Jun 2022 10:35
With Lua you can put commands on the same line and separate with a semi-colon but I prefer to separate them out for readability.

i.e.:
Show( e )
CollisionOn( e )

instead of
Show( e ); CollisionOn( e )

if you do:
if g_Entity[ e ].activated == 0 then
Show( e )
else
... etc
end

Then Show( e ) will be called every frame until the entity is activated, i.e. 60 times a second, which is inefficient scripting as it only needs to be called once.
Better practice is to create a state engine so you only actually execute the Show/Hide/CollisionOn/CollisionOff once on a state change.

Been there, done that, got all the T-Shirts!
PM
Baldielocks
1
Years of Service
User Offline
Joined: 17th Jun 2022
Location: Grimsby,
Posted: 26th Jun 2022 09:46
This post has been marked by the post author as the answer.
Cheers for that, all help is much appreciated.
PM

Login to post a reply

Server time is: 2024-04-26 08:07:18
Your offset time is: 2024-04-26 08:07:18