Scripts / Lua Commands that start with a g_

Author
Message
Flatlander
GameGuru Master
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 5th Apr 2017 21:10
I am slowly but surely I am learning how to use lua. I should; being a programmer for over 45 years using such languages as asm, COBOL, C (not C++ or Visual C, BASIC, and Visual Basic - oh and Dark Basic. My brain isn't working as well as it used to so it is much slower. However, if I have all the commands at my finger tips then I can figure things out. I purchased all of the scripts from the store to help me out. I'm also using smallg's scripts as well. He appears to be the guru of scripts. Maybe that's why he called himself smallg as or the son of Game Guru. I noticed there are some commands -- no not commands they look more like variables--such as g_Entity and g_KeyPressE. Low and behold it just hit me right now. The prefix "g_" stands for global I bet. Also, I remember seeing a lua file called global.lua. Just checked it out and sure enough everything I need to use conditions for lua.

I've decided to go ahead and post. This to let you know I'm still here and have whole-heartedly made up my mind to use GG rather than FPSC despite the fact that I had paid for almost all of the model packs and made use of the store. Also, the number of characters seem to be at a premium. Character Creator could be very useful but I have been having difficulties with that. But that's a different topic not for here.
When in doubt -- C4 :heh, heh, heh:

-Jamie Hyneman
Corno_1
GameGuru Tool Maker
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 5th Apr 2017 21:42
I never thought that g_ means global. I always thought it means "get" because the engine fills it with values which I can access to with the var. Maybe both

Great to see all the guru´s of FPSC come to this forum. Welcome
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 5th Apr 2017 22:21
Quote: "I never thought that g_ means global. I always thought it means "get" because the engine fills it with values which I can access to with the var."


It means global, hence when you put it in front of a variable it becomes a global variable

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Ratall
15
Years of Service
User Offline
Joined: 29th Jun 2008
Location: Not Here
Posted: 5th Apr 2017 23:49
May I also point out that if you define a variable with a name starting with g_ it will be saved and restored by the standard game save and load functions. Variables you define with names not starting with g_ are not.

For details of what is saved and not look in gamedata.lua in the titlesbank.

Always check out global.lua in scriptbank regularly for new commands/engine variables

Quod cito fit, cito perit.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 6th Apr 2017 00:12
Yep, the naming convention simply enables the save game function to know what to save for you.

Generally in Lua everything that doesn't have 'local' in front of it is global, global variables and global functions are a lot slower to access so good practice is to make everything that doesn't have to be global, local. (I say generally because you can hide 'global' variables inside modules that are not actually visible outside the module but strictly speaking they are not really 'local' in the Lua sense)

Also be aware that any numerical variable you define will be 64 bit double precision floating point so if you have state variables you can save memory by using short strings instead (and it tends to be more readable).

Lua is extremely powerful btw, it has become my favourite language and I also have 40 years of coding experience so I've used a heck of a lot of different languages.

Been there, done that, got all the T-Shirts!
PM
Corno_1
GameGuru Tool Maker
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 6th Apr 2017 17:03
@Corno_1 oh man nobody gets your unfunny jokes. Get? Really. This make absolute no sense. You can set these vars, e.g. g_var = 1. Also this would be an r for return like r_var and not a g. Grow up and get out of your twenties, little boy.
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 6th Apr 2017 19:25
I remember when my waist size was in the twenties, very distant memories mind.
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: 6th Apr 2017 21:40
corno_1 wrote: ". . . of FPSC come to this forum. Welcome"


Thanks mate. The 'g' is a shortened version from 'ggg' -- go get global. I think.

ratall wrote: "For details of what is saved and not look in gamedata.lua in the titlesbank."


Lee is up to his old tricks with GG. In FPSC it was always difficult to find out tidbits, like this. Thanks ratall.


AmenMoses wrote: "I remember when my waist size was in the twenties, very distant memories mind"


I know what you mean. I, too, had a small waist at one time in the late teens and early twenties. It is not even close today. I can get used to lua once I get started with it. The thing was I took all that time learning fpi and just when I was getting good at it, BOOM, I have to learn something else. However, lua is a lot more like a programming language and that now makes it more appealing.

I notice, I am doing my old mistakes again. Not placing the if statements in the right places. Also I have to quit typing 'endif'.


When in doubt -- C4 :heh, heh, heh:

-Jamie Hyneman

Login to post a reply

Server time is: 2024-04-25 11:28:27
Your offset time is: 2024-04-25 11:28:27