GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 Oh your problem is you cannot use fAAGGHunger with the '=' operator. Try like fAAGGHunger.getValue() and fAAGGHunger.setValue(valuehere) Thanks! Got that part sorted out! Problem is now, how do I check if fAAGGHunger is of a specific value? if fAAGGHunger > 1 fAAGGHunger.addvalue(-1) elseif fAAGGHunger = 1 Game.GetPlayer().ModActorValue("health", 0) I.E How would I make it so that works? Link to comment Share on other sites More sharing options...
WiseMan999 Posted February 13, 2012 Share Posted February 13, 2012 The only thing I can think of is that you might need to say "Hunger += 1" instead of "Hunger + 1" (and its opposite Hunger -= 1 of course) as you aren't assigning it a new value. I could be wrong though, I'm fairly new to scripting too :D. Link to comment Share on other sites More sharing options...
Crestfall Posted February 13, 2012 Share Posted February 13, 2012 Sorry, I edited the last post but just to make sure you see it, use == when you want to test if something is equal use = when you want to change the value of something Link to comment Share on other sites More sharing options...
GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 Sorry, I edited the last post but just to make sure you see it, use == when you want to test if something is equal use = when you want to change the value of something Wicked cool. That fixed those errors... Sadly, I've got a whole new batch D: Here's the script now: scriptName Hunger extends Quest Function AAFunction() debug.MessageBox("Hunger plugin loaded!") endFunction Function AAAFunction() RegisterForUpdateGameTime(0.25) endFunction Event OnUpdateGameTime() if fAAGGHunger >= 1 fAAGGHunger -= 1 elseif fAAGGHunger == 1 Game.GetPlayer().ModActorValue("health", 0) debug.MessageBox("Oh dear. You didn't eat, so you died. Sucks 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 endEvent Event 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.") endif endEvent And here are the new batch of errors: C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(12,4): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(12,16): cannot compare a none to a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(12,16): cannot relatively compare variables to None C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(13,2): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(13,2): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(13,14): cannot subtract a none from a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(14,8): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(14,20): cannot compare a none to a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(17,8): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(17,20): cannot compare a none to a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(17,20): cannot relatively compare variables to None C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(21,1): variable UnregisterForUpdateGameTime is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(26,4): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(26,16): cannot compare a none to a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(27,2): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(27,2): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(27,14): cannot add a none to a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(29,8): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(29,20): cannot compare a none to a int (cast missing or types unrelated) C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(31,8): variable fAAGGHunger is undefined C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(31,20): cannot compare a none to a int (cast missing or types unrelated) No output generated for Hunger, compilation failed. Funnily enough, it's the same two errors. I guess if I can "define" fAGGHunger, it'll get rid of them.Do I have to do some sort of reference to the global value? Something like "RegisterForUpdateGameTime()" but "RegisterGlobalVariable()" (Made the second reference up :s ) Link to comment Share on other sites More sharing options...
Galacticat42 Posted February 13, 2012 Share Posted February 13, 2012 (edited) Here are my edits - I fixed your syntax errors.scriptName Hunger extends Quest ;------------------ ;Properties ;------------------ int Property iAAGGHunger = 100 auto ;This is the script default when you start a new game or start the plugin. ;------------------ ;Functions ;------------------ Function AAFunction() debug.MessageBox("Hunger plugin loaded!") endFunction Function AAAFunction() 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 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 Edited February 13, 2012 by Budz42 Link to comment Share on other sites More sharing options...
Crestfall Posted February 13, 2012 Share Posted February 13, 2012 (edited) Okay so this is the problem fAAGGHunger is a global variable, think of it as a box and inside it it has an integer (which is your hunger). You can't actually compare the global variable (fAAGGHunger) to an integer (1). Instead, you need to use fAAGGHunger.getValue() and that will return the integer which you can compare to other integers. Also when you want to change the value, use fAAGGHunger.setValue(valuehere). When it says variable fAAGGHunger is undefined, its probably because you did not initialize it with a value (basically the default value that it starts at). Actually I don't know if papyrus is strongly typed so you might just have to give it a default value and don't need to bother with the getValue and setValue. Edited February 13, 2012 by Crestfall Link to comment Share on other sites More sharing options...
WiseMan999 Posted February 13, 2012 Share Posted February 13, 2012 I think adding "GlobalVariable Property Hunger Auto" at the start might work. EDIT: wow, 3 ninjas :D. By the way, I think as your script currently stands you'll reach Hunger=1 in about 25 seconds as you update game time every 0.25 seconds - although I'm not sure. Also, are you unregistering for UpdateGameTime every time you get updated? Wouldn't that mean the script will only happen once? I think you might need to register again just under it (again, don;t take my word :D). Link to comment Share on other sites More sharing options...
MofoMojo Posted February 13, 2012 Share Posted February 13, 2012 (edited) Oh your problem is you cannot use fAAGGHunger with the '=' operator. Try like fAAGGHunger.getValue() and fAAGGHunger.setValue(valuehere) Thanks! Got that part sorted out! Problem is now, how do I check if fAAGGHunger is of a specific value? if fAAGGHunger > 1 fAAGGHunger.addvalue(-1) elseif fAAGGHunger = 1 Game.GetPlayer().ModActorValue("health", 0) I.E How would I make it so that works? I think faaGGHunger is a float value (don't have the editor handy at the moment). This might be keep you from typing out GetValue() all the time: ;create a temp variable for ease of use float hungervalue = fAAGGHunger.GetValue() if hungerValue > 1 hungerValue = hungervalue - 1 fAAGGHunger.SetValue(hungerValue) elseif hungervalue = 1 Game.GetPlayer().ModActorValue("health", 0) endif -MM Edit: Just saw Wiseman's response. if fAAGGHunger is a global variable, You MUST reference it as a property in your script GlobalVariable Property fAAGGHunger auto And, it would be a good idea to go into Properies of the script after compiling it and AUTO-FILLING it. For some reason, even if properties are properly defined in scripts, they don't always work unless I do that. Your mileage may vary. Edit2: @Crestfall - It is strongly typed. If it's a float value you can't just store the value in a variable of type int without casting it. Edited February 13, 2012 by MofoMojo Link to comment Share on other sites More sharing options...
GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 @Budz Wow. Thats fantastic! I only have one last error :D @CrestFall Now I'm intrigued. Is there some sort of command for comparing? @WiseMan Yep, it worked :3 Got one last error! Thanks for all your help so far! :D Last error : C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(34,8): variable UnregisterForUpdateGameTime is undefined Now, I don't see how this can cause an error. Should I just go ahead and save, ignoring it? Link to comment Share on other sites More sharing options...
Galacticat42 Posted February 13, 2012 Share Posted February 13, 2012 Should be Form.UnregisterForUpdateGameTime()And of course you'll need to match it with Form.RegisterForUpdateGameTime(.25) Link to comment Share on other sites More sharing options...
Recommended Posts