Papyrus Hunger script - No worky.

Post » Tue Jun 19, 2012 1:27 am

The script I've made makes it so that whenever the player eats something, the value fAAGGHunger goes up. Over time, the value will go down.
I used a barebones quest to make my script initialise when Skyrim is played, but it just doesn't seem to work.

http:// skyrim. nexusm ods.co m/downloa ds/file.php?id= 9611

Remove the spaces, as I cannot post links for some reason.

I would prefer to be shown how to fix it, rather than just to have the fix given to me (Although if the fixes were detailed alongside the file, I would like that :3 ) so I could learn how to do it properly next time.

Thanks in advance!

...Oh, and here is the script (If it being on its own is any use)

Edit: Didn't seem to have posted the script. Here it is :

scriptName Hunger extends Questint Property fAAGGHunger = 100 auto ;This is the script default when you start a new game or start the plugin.Function AAFunction()debug.MessageBox("Hunger plugin loaded!")endFunctionFunction AAAFunction()					    RegisterForUpdateGameTime(0.25)endFunctionEvent OnUpdateGameTime()	    if fAAGGHunger > 1			    fAAGGHunger -= 1 ; -= means that Hunger = Hunger - 1	    elseif fAAGGHunger == 1 ; This means that the code checks if the value is at 1			    Game.GetPlayer().ModActorValue("health", 0)  debug.MessageBox("Oh dear. You didn't eat, so you died. svcks to be you!")	    elseif fAAGGHunger <=10			    debug.MessageBox("Ah, your stomach beckons for bacon. Might be a good idea to eat. You know, being hungry and all.")	    endif	    UnregisterForUpdateGameTime()endEventEvent OnActivate(ObjectReference akActionRef)	    if fAAGGHunger == 99			    fAAGGHunger += 1			    debug.MessageBox("Your belly is full, your mouth tastes fantastic. Life is good.")	    elseif fAAGGHunger == 100			    debug.MessageBox("You have already eaten! You don't want to get indigestion, now.")	    elseif fAAGGHunger == 50			    debug.MessageBox("The gurgling has stopped, but you probably eat more. You fat pig.")	    endifendEvent
User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am

Post » Mon Jun 18, 2012 11:27 pm

I think you need to change this:
Function AAAFunction()                                      RegisterForUpdateGameTime(0.25)endFunction

to this:

Event OnInit() RegisterForUpdateGameTime(0.25)EndEvent

If that's all your code, then AAAFunction is never getting called. OnInit gets called when the quest first initializes.
User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Tue Jun 19, 2012 3:21 am

I love you. I'll go give it a shot :D
User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm

Post » Mon Jun 18, 2012 5:53 pm

Eugh. Good news is, is that the Event OnInit works (Added a message to it's event saying the plugin is loaded), but the variable fAAGGHunger never changes. It just stays at 0. I'm going to go check to see if I set the variable to 0 by accident.

Edit: Yep, Variable was at 0. Changed it to 50. Time to test the script.

Edit2: Gah. Doesn't make a difference. The Global variable won't decrease every 15 in-game minutes, and eating something won't add to it either.

Actually, looking over my code, I noticed this :

Event OnActivate(ObjectReference akActionRef)

I'm not actually referring to anything. How would I refer to a peice of food in the player's inventory that has been eaten? I would like my script to add 1 to fAAGGHunger whenever something is eaten.
User avatar
Killah Bee
 
Posts: 3484
Joined: Sat Oct 06, 2007 12:23 pm

Post » Mon Jun 18, 2012 10:08 pm

You may have to add a magic effect to each piece of food or attach a script to each piece of food.
User avatar
jason worrell
 
Posts: 3345
Joined: Sat May 19, 2007 12:26 am

Post » Tue Jun 19, 2012 12:44 am

You may have to add a magic effect to each piece of food or attach a script to each piece of food.
The bolded part is how it was done in Fallout:New Vegas; there were the usual things like how much a given edible healed or buffed you, and an additional value (called FOD) that lowered your amount of hunger.

If you do add such an effect, you can then set it at different values for each item it's attached to, and only need the one script to process them all.
User avatar
Stephanie Nieves
 
Posts: 3407
Joined: Mon Apr 02, 2007 10:52 pm


Return to V - Skyrim