GomuGomu64 Posted February 13, 2012 Share Posted February 13, 2012 (edited) Basically, I've made a Hunger script that is added to a quest, which is started at run-time, and can never be finished/abandoned.This, being my first script ever, I presume it is completely error-prone. I would be most grateful if errors could be found and detailed, so I may fix 'em and not make the same mistake in the future. Thanks in advance! scriptName Hunger extends Quest GlobalVariable Property Hunger Auto Function AAAFunction() RegisterForUpdateGameTime(.25) endFunction Event OnUpdateGameTime() if Hunger > 1 Hunger - 1 elseif Hunger = 1 Game.GetPlayer().ModActorValue("health", 0) debug.MessageBox("Oh dear. You didn't eat, so you died. Sucks to be you!") elseif Hunger <=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 Hunger = 99 Hunger + 1 debug.MessageBox("Your belly is full, your mouth tastes fantastic. Life is good.") elseif Hunger = 100 debug.MessageBox("You have already eaten! You don't want to get indigestion, now.") elseif Hunger = 50 debug.MessageBox("The gurgling has stopped, but you probably eat more. You fat pig.") endif endEvent Edit: I have another problem. I slightly edited the script so that it would actually work (Following this short guide on making a script run at the start of the game. scriptName Hunger extends Quest Function init() GlobalVariable Property Hunger Auto Function AAAFunction() RegisterForUpdateGameTime(0.25) endFunction Event OnUpdateGameTime() if Hunger > 1 Hunger - 1 elseif Hunger = 1 Game.GetPlayer().ModActorValue("health", 0) debug.MessageBox("Oh dear. You didn't eat, so you died. Sucks to be you!") elseif Hunger <=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 Hunger = 99 Hunger + 1 debug.MessageBox("Your belly is full, your mouth tastes fantastic. Life is good.") elseif Hunger = 100 debug.MessageBox("You have already eaten! You don't want to get indigestion, now.") elseif Hunger = 50 debug.MessageBox("The gurgling has stopped, but you probably eat more. You fat pig.") endif endEvent debug.MessageBox("Hunger plugin loaded!") endFunction I get this from the Compiler Output : Compiling "Hunger"... C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(5,15): no viable alternative at input 'Property' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(14,8): no viable alternative at input 'Hunger' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(29,8): no viable alternative at input 'Hunger' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(31,8): no viable alternative at input 'Hunger' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(36,5): no viable alternative at input '.' No output generated for Hunger, compilation failed. Any idea on how I can fix that? Edit2: I changed the script-property to a Global Variable, fixing that "No viable alternative at input 'Property'" compile error, however I still get errors. This is the slightly changed script : 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 these are it's compiler errors : Starting 1 compile threads for 1 files... Compiling "Hunger"... C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(14,8): no viable alternative at input 'fAAGGHunger' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(26,4): no viable alternative at input 'fAAGGHunger' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(29,8): no viable alternative at input 'fAAGGHunger' C:\Program Files\The Elder Scrolls V Skyrim\Data\Scripts\Source\temp\Hunger.psc(31,8): no viable alternative at input 'fAAGGHunger' No output generated for Hunger, compilation failed. Can someone please help me resolve these errors? Can't save the script without doing this, and I'll need to shut this compy off soon XD Edited February 13, 2012 by GomuGomu64 Link to comment Share on other sites More sharing options...
0xLordx0 Posted February 13, 2012 Share Posted February 13, 2012 Do you mind if i ask where you learnt to script? what tutorials did you follow and what did you do to improve?i'm looking to start scripting and i really need to know how to go from beginner to harder stuffThanks Link to comment Share on other sites More sharing options...
GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 Oh jeez mate, I just started scripting like, 5 minutes ago. I basically asked questions on the forums (For things that didn't yield results on the CreationKit.com site) and worked from there. I also took a gander at a few scripts that maybe-kinda-sorta resembled a bare-bones of what I wanted to do. Best go on the site, follow the tutorials, and when your stumped, ask questions here. The people 'ere are good. Link to comment Share on other sites More sharing options...
Deleted147363User Posted February 13, 2012 Share Posted February 13, 2012 Basically, I've made a Hunger script that is added to a quest, which is started at run-time, and can never be finished/abandoned.This, being my first script ever, I presume it is completely error-prone. I would be most grateful if errors could be found and detailed, so I may fix 'em and not make the same mistake in the future. Thanks in advance! Great work I can't fault the logic here. I can see some interesting possibilities for the player e.g. being poisoned, reduced stamina etc. Link to comment Share on other sites More sharing options...
GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 Basically, I've made a Hunger script that is added to a quest, which is started at run-time, and can never be finished/abandoned.This, being my first script ever, I presume it is completely error-prone. I would be most grateful if errors could be found and detailed, so I may fix 'em and not make the same mistake in the future. Thanks in advance! Great work I can't fault the logic here. I can see some interesting possibilities for the player e.g. being poisoned, reduced stamina etc. Aye, but I slightly changed it because I mis-read a part of the code which I followed from a tutorial (That is now hyperlinked on my edited post), and I get compiler errors.Mind checking out the edited script please? :3 Link to comment Share on other sites More sharing options...
gengrimm Posted February 13, 2012 Share Posted February 13, 2012 I would recommend creating a global variable called fAA<Modder's Initials>hunger variable i.e fAAGGhunger rather than using a non globle variable that will be used by multiple function/scripts. It will be easier to access that way if you are writing numours scripts that need to access that data. ~~~~~~~~~~~~~~~~~~~Also I'd make Magic effect bonuses for Well Fed or Hungry. i.efull = +10% Health/Sta Regen-----------------------Hungry = 25% HP drainMal-nurished = 50% hp drainStarving = 75% health drain Link to comment Share on other sites More sharing options...
GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 Bump. Kinda need this to be spotted, don't have much spare time. Life is beckoning :P Link to comment Share on other sites More sharing options...
Crestfall Posted February 13, 2012 Share Posted February 13, 2012 Where did you define fAAGGHunger? Link to comment Share on other sites More sharing options...
GomuGomu64 Posted February 13, 2012 Author Share Posted February 13, 2012 (edited) I defined it under Misc->Global It's a short variable....Perhaps I should make it a float? Edit: Nope, changing it to a float didn't work. Edited February 13, 2012 by GomuGomu64 Link to comment Share on other sites More sharing options...
Crestfall Posted February 13, 2012 Share Posted February 13, 2012 (edited) Oh your problem is you cannot use fAAGGHunger with the '=' operator. Just kidding, just use '=='. = means assertion == means equality check Edited February 13, 2012 by Crestfall Link to comment Share on other sites More sharing options...
Recommended Posts