Scripts / New Hunger Thirst Script working

Author
Message
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 29th May 2014 08:12 Edited at: 2nd Jun 2014 15:27
Edit Attachment wasn't working so put in a new post



Edit: Have modified the script with new information come to light so the globals are included in the script itself now and local's have been identified as such. Have attached a zipped file to this post with the 3 scripts and also the 3 FPE's which replace the FPE files in the collectables section. Have also updated the script here under the code headers.



EDIT: Ok i finally have a working Hunger and Thirst Script and here it is:



Note: For this to work i took the syringe pickup and modified the FPE so quantity is -1 and then attached this script to and hid it on the level somewhere, doesnt really need hiding as once it has this script on it it just becomes a static object anyway. For the creative this script can be applied to anything thats not going to be interacted with so go nuts, just modify the FPE to say its a health pickup and make the quantity -1 or whatever you want.



Edit: Yes another Edit, heres a video of it working:













heres the one for food:







and the one for drink:







If anyone is interested i wouldn't mind some food and drink entities made that i could put FPE files onto and different values and put this all together as a pack so people don't have to modify the chips and milk entities.

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
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 29th May 2014 09:21 Edited at: 30th May 2014 04:09
EDIT: Global's now included as part of script

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
J0linar
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 3rd Feb 2010
Location: Vienna, AT
Posted: 29th May 2014 10:25
Hey thats a nice one, in combination with animations this could find plenty of use. For example if you know Vampire The Masquerade Redemption/Bloodlines



One could do a vampire bloodsucking game



Well done mate

http://j0linar.blogspot.co.at/



PC SPECS: Windows 8 Pro 64-bit, Intel I7-3630QM 4.8GHz CPU, Nvidia GTX 675M - 2048MB GPU, 16GB DDR3 RAM
PM
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 29th May 2014 10:45
lol making this was starting to do my head in for a little while there

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
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 29th May 2014 11:53
Could a mod change the title for me so it doesn't say hangs on nil anymore but working instead

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
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 29th May 2014 13:33
Awesome, very nice job, thanks! I guess the next step now is for me to make images to represent how much hunger/thirst the character has, and then apply that to a LUA script I guess.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
Slaur3n
GameGuru TGC Backer
16
Years of Service
User Offline
Joined: 16th Sep 2008
Location: Norway
Posted: 29th May 2014 13:39
how to modify the fpe?



this is what i have done: placed a syringe static, with the first script in main. And food and drink script on "chips" and "milk" entity. Loading crashes at loading physics
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 29th May 2014 15:15 Edited at: 29th May 2014 15:39
i will upload the modified FPE tomorrow for the syringe and the chips and milk entities as well i had to make ismedpack = 0 and also remove the whole quantity section but i will upload these as well just remember to back them up before replacing them, at the moment I'm getting in trouble with the missus for being on the computer so yeah i will update everything tomorrow.



with the crashing on physics does it have an error message at all, sometimes when it stops you have to Alt TAB to see it, if it does please let me know what it says but hopefully when i give you the updated FPE files everything should be good



and i dont know about setting the syringe as static i just left as was as it still needs to se it as a health pack to give negative health but yeah i''l upload everything involved tommorow that i have it working with

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
Slaur3n
GameGuru TGC Backer
16
Years of Service
User Offline
Joined: 16th Sep 2008
Location: Norway
Posted: 29th May 2014 16:02
error message : no function called food_drink_main
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 29th May 2014 16:35
You have to rename the line of code after the "function" command so that it matches the name of the document.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 30th May 2014 03:38
Zip File Attatched to this post

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
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 30th May 2014 03:39
@Dralel yeah we cant use our own HUD's yet but when we can i'll be looking into this 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
Slaur3n
GameGuru TGC Backer
16
Years of Service
User Offline
Joined: 16th Sep 2008
Location: Norway
Posted: 30th May 2014 10:51
i can pickup food and drinks. but my hunger and thirst level is not showing anywhere.
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 30th May 2014 11:27 Edited at: 30th May 2014 11:33
Yeah it doesn't I didn't want to have it on the screen the whole time if you want I can write up a quick display script that can display it all the time or just when you get close to something other then that it will just run in the background.



It will however tell you when your getting too hungry or thirsty but on default setting you won't see those messages for at least 30 minutes.



this is only because at the moment we can only have one prompt on the screen at a time so i left it off the display so as to avoid conflicts with other prompts

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
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 30th May 2014 11:43 Edited at: 30th May 2014 11:45
I just made this up quickly just save it as displayhandt.lua then attatch it to something and when you get close it should display your hunger and thirst. Haven't actually tested it as my main computer has been dissasembled for a week but should work.



also for those learning it is heavilly commented for what everything does.





edit these are also much easier to read if you use something with syntax highlight. for example i use notepad++, and set the language to Lua and comments are in green and commands in blue, much easier to work with

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
science boy
16
Years of Service
User Offline
Joined: 3rd Oct 2008
Location: Up the creek
Posted: 30th May 2014 13:29
if you need anything doing art wise let me know for free, as in to aid scripts, otherwise i can send to you for private use if it is mine to give

an unquenchable thirst for knowledge of game creation!!!
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 30th May 2014 16:49
all these scripts i have made out of selfish desire for what i wanted in a game and im just learning so i want nothing in return for sharing them im just glad they can help others in their games

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
unfamillia
Forum Support
14
Years of Service
User Offline
Joined: 26th Jul 2010
Location: Preston, Lancashire
Posted: 30th May 2014 20:49 Edited at: 30th May 2014 20:50
AuShadow,



Please forgive my poor scripting, I am terrible, but, willing to learn.



If I wanted this script to show a message when the player was close to an entity, almost like an inner monologue, would this be possible just by removing a few sections? (such as below)





-- Display Entity Text



function displayhandt_main(e)



-- math for player distance, this is always the same

-- Put it into any script where you want to have it based on distance to player

PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;

PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;

PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;

PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));



-- Detect if player is close enough to display the prompt

-- Increase the number to increase the distance you can be from the object

if PlayerDist < 80 then

--Now to display the text and variables

Prompt ("How are these candles lit? I thought this was abandoned")

-- End the if statement

end

-- End the function

end



Also, does the custom Lua need to be named the same as what follows the function?



Quote: "function displayhandt_main(e)"




Or is this what I would name the entity?



Again, please excuse my lack of knowledge! This is all really new to me!



Cheers



Jay.

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th May 2014 22:15 Edited at: 30th May 2014 22:15
yes that is correct for displaying a prompt

and yes you need to name the file the same as the part after function

i.e. function displayhandt_main(e) would be called displayhandt.lua

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 31st May 2014 02:39 Edited at: 31st May 2014 02:41
Modifying others scripts was how I started to learn , I've started to make a page of script parts that you can look at and copy the sections you wanted and modify as needed, not a visual maker like Avram's more of a learning aid and it helps me to remember too , will post it when I'm finished,



Will just be about a week or so as my computer has been packed up while we paint the house

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
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 9th Jun 2014 12:42
here's an easy to change to your needs script, though not as heavily commented.

easy to change the time delay the script updates, and the starting and max thirst and hunger



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
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Jun 2014 13:01


this would now work better as a percentage
e.g. to always show at around 50%


also the end part of this comment is not technically true
Quote: "-- Change starting hunger and thirst here, must be equal to or less then max's, set below"

because you have already accounted for it in this check


although im not sure why you didn't just set them to maxthirst / maxhunger rather than add a whole new variable?
keep up the good work

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 9th Jun 2014 13:11
yeah i did realise i didnt really need those 2 new variables after i posted it , and may eventually make it percentage based but i am going to leave this as is now for a while and move onto other things

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

Login to post a reply

Server time is: 2024-12-22 05:25:06
Your offset time is: 2024-12-22 05:25:06