Jump to content

Scripting - First Attempt


GomuGomu64

Recommended Posts

Should be

Form.UnregisterForUpdateGameTime()

And of course you'll need to match it with

 

Form.RegisterForUpdateGameTime(.25)

 

*Sigh* It fixed that one error, and has given me two more (Well, the same error twice)

 

 

scriptName Hunger extends Quest

int Property iAAGGHunger = 100 auto ;This is the script default when you start a new game or start the plugin.

Function AAFunction()
debug.MessageBox("Hunger plugin loaded!")
endFunction

Function AAAFunction()                       
 Form.RegisterForUpdateGameTime(0.25)
endFunction

Event OnUpdateGameTime()
       if iAAGGHunger > 1
               iAAGGHunger -= 1 ; -= means that Hunger = Hunger - 1
       elseif iAAGGHunger == 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. Sucks to be you!")
       elseif iAAGGHunger <=10
               debug.MessageBox("Ah, your stomach beckons for bacon. Might be a good idea to eat. You know, being hungry and all.")
       endif

       Form.UnregisterForUpdateGameTime()

endEvent

Event OnActivate(ObjectReference akActionRef)
       if iAAGGHunger == 99
               iAAGGHunger += 1
               debug.MessageBox("Your belly is full, your mouth tastes fantastic. Life is good.")
       elseif iAAGGHunger == 100
               debug.MessageBox("You have already eaten! You don't want to get indigestion, now.")
       elseif iAAGGHunger == 50
               debug.MessageBox("The gurgling has stopped, but you probably eat more. You fat pig.")
       endif
endEvent

 

 

And the error is

 

C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(10,7): cannot call the member function RegisterForUpdateGameTime alone or on a type, must call it on a variable

C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(23,13): cannot call the member function UnregisterForUpdateGameTime alone or on a type, must call it on a variable

No output generated for Hunger, compilation failed.

 

 

Also, thanks again for your help so far. I am really obliged to you guys :D

Edited by GomuGomu64
Link to comment
Share on other sites

Looking at Creationkit.com you should get rid of the unregister line.

 

@Crestfall

The custom script Hunger isn't a script library and thus will put out an error. The Quest script library doesn't handle game time and so Form would be the only plausible thing to use. Should you try to use it as an extension of the main script that you're using, then get rid of the prefix.

Edited by Budz42
Link to comment
Share on other sites

Form is a general type, you need to actually have a form object.

 

I'm not sure but if you don't put anything before Register/UnregisterForUpdateGameTime it will implicitly use the current script. You can try like Hunger.UnregisterForUpdateGameTime().

 

Egh. It gave the same errors as before.

 

Sheesh. What started out as a simple variable changer has become so complicated. I much prefer Lua than to papyrus XD

Link to comment
Share on other sites

Don't put Form.UnregisterForUpdateGameTime, just put UnregisterForUpdateGameTime. As a suggestion, I think its actually UnregisterforUpdateGameTime, at least it is that way in the script I'm looking at.

 

EDIT: Also, how long is it supposed to take to reach death? At the moment I think it will take about 25 seconds to die from hunger :D.

Edited by WiseMan999
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...