Scripts / Heavily Commented Hunger and Thirst Script to help new coders understand it

Author
Message
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 3rd Jun 2014 11:34 Edited at: 3rd Jun 2014 11:42
ok so i have tried to comment how every little thing in this code works and what it does.



if i have missed anything or there's something you want explained better please just ask and i will try my best







something not explained is the g_Time variable, this is a variable that i think comes from the engine it-self and i've taken to refering to it as game time , no idea if that's what it actually is but it works ,



hope all this helps anyway

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

Feel free to visit and edit the public FPSCR resource wiki page: http://fpscrresource.wikispaces.com/home
The Next
TGC Web Engineer
16
Years of Service
User Offline
Joined: 3rd Dec 2007
Location: United Kingdom
Posted: 3rd Jun 2014 12:42
A nicely commented script well done for sharing this it will help many users I am sure.

On a side note, nice to see the new code highlighting is working nicely.

Windows 7 Pro, Intel i7 3.8 GHz, 16GB DDR3, NVIDIA GTX 780 4GB Superclocked
PM
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 3rd Jun 2014 13:10
Yes its good. Makes it a lot easier to tell comments apart from code and the highlighting of what's in a prompt is a nice touch too

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

Feel free to visit and edit the public FPSCR resource wiki page: http://fpscrresource.wikispaces.com/home
Dralel
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 3rd Jun 2014 17:34
Excellent work! And I heavily appreciate the comments on the script.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
rolfy
17
Years of Service
User Offline
Joined: 23rd Jun 2006
Location:
Posted: 4th Jun 2014 05:29
Excellent, thanks for this

A funny thing happened on the way to the forum...
Uman
GameGuru TGC Backer
19
Years of Service
User Offline
Joined: 22nd Oct 2004
Location:
Posted: 4th Jun 2014 11:59
Thanks for that.

Thats the wonderful kind of help users especially non expert scipters need.

To serve software best - similar detailed explanations and examples of their use of all of the commands and functions and alike that are eventually included should be included in a reference file, manual and alike and wherever possible with supporting working examples.

I know its has to come as part of a priority list and may never happen by would be very helpful I am sure.

AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 4th Jun 2014 12:19
No problem I've drafted up my next one which I will post as is and heavily commented which is going to be a Lua 24hour repeating clock that also affects lighting settings.

Basically a lua day and night script where you could also script things in later to only happen at specific times of day.

Hopefully it will be up in just over a week. Will probably write in a day easy enough but no computer for about another week , its killing me

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

Feel free to visit and edit the public FPSCR resource wiki page: http://fpscrresource.wikispaces.com/home
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 4th Jun 2014 12:30
Oh and by the way if anyone sees a script here by anyone and wants me to I can try and explain it aswell

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

Feel free to visit and edit the public FPSCR resource wiki page: http://fpscrresource.wikispaces.com/home
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Jun 2014 13:48
nicely done, i would suggest in future to maybe try remember to add in more user control to your scripts - max amount of hunger / thirst, how much time to pass before it starts to drop etc - i.e. instead of
you would write
and let them set the max hunger at the top of the script (while you can keep it at 5000 by default so it'll still work as is), that way it's much more userfriendly for people looking to adjust it but that's not really got anything to do with the explanation side of it, which you have done very well

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 4th Jun 2014 15:49
I agree with that notion.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 10th Jun 2014 14:02
Me too.
But the way a Select case here, would be nice, but not sure is this's achievable here, am really new scripter.
Thanks AuShadow, comments are really good code pratice for everyone, even for you.

3com
PM
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 3rd Apr 2015 07:29
Does this still work in GameGuru?
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 3rd Apr 2015 10:56 Edited at: 3rd Apr 2015 11:09
No but this should:



Not tested but if doesn't work then move the variables out of the _init function and place them between that and the _main function but NOT INSIDE the main function and save as food_drink.lua

lol i think this may have been the last script i actually wrote, need to find time to get abck into learning lua again.

lol almost forgot to update to the HurtPlayer function instead of AddPlayerHealth, but spotted it and sorted now

by the way make sure what ever entity this is applied to has ALWAYS ON ticked in the properties tab otherwise it will stop working once you are 3000 game units away from it. and must be dynamic also
PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 26th Apr 2015 09:21
how can I use it??

must I create a tigger zone or what else??
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM

Login to post a reply

Server time is: 2024-05-07 07:32:51
Your offset time is: 2024-05-07 07:32:51