Scripts / Can't wrap head around states????

Author
Message
Flatlander
GameGuru Master
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 10th Feb 2020 01:12
Because of my memory issues, I eventually wrote a template when needing to use states (of course that is most all the time). Believe me, it took a long time for me to sort out something workable. I hope this is useful for some of you guys trying to use lua (especially lua in game development).



Here is an example of a short script based on amenmoses' "playerfreeze" script.



This also has an example of using one of his other fabulous scripts called "utillib.lua" as well as extracting the name of the entity.
Alienware Aurora R7 with SSD 256GB boot drive ( C: ) and a secondary drive ( D: ) that is 2TB
Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 3.19 with Intel Turbo-burst
Installed RAM 16.0 GB
64-bit operating system, x64-based processor
Windows 10 Home
NVIDIA GeForce GTX 1070 with 8192 MB GDDR5 and 8095 MB shared system memory
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 10th Feb 2020 19:45
Use strings for states! Makes it more readable later on when looking back at it and can also be more efficient strangely enough.

i.e. if state == 'start' then
Been there, done that, got all the T-Shirts!
PM
Flatlander
GameGuru Master
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 10th Feb 2020 20:54
AmenMoses wrote: "Use strings for states! Makes it more readable later on when looking back at it and can also be more efficient strangely enough."

I agree. This is an excellent suggestion. Especially when you have a multitude of states. I also like to use variables with descriptive names and if you have a mind like mine (always in a state of confusion) be careful in using abbreviations.
Alienware Aurora R7 with SSD 256GB boot drive ( C: ) and a secondary drive ( D: ) that is 2TB
Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 3.19 with Intel Turbo-burst
Installed RAM 16.0 GB
64-bit operating system, x64-based processor
Windows 10 Home
NVIDIA GeForce GTX 1070 with 8192 MB GDDR5 and 8095 MB shared system memory

Login to post a reply

Server time is: 2024-04-23 10:04:39
Your offset time is: 2024-04-23 10:04:39