TangerineDog Posted September 26, 2017 Share Posted September 26, 2017 I'm trying to make a script that sets a variable one point higher, sets a timer and, when that timer runs out, repeats the whole process. I'm clear on how to make the timer, but I don't know how to declare the variable and what command makes the script set it to its current value +1. Could you please help me out? Link to comment Share on other sites More sharing options...
foamyesque Posted September 26, 2017 Share Posted September 26, 2017 The increment and decrement operators are: x+=1 and x-=1. How you declare 'x' depends on what it is actually supposed to be. An actor value? Some property of an object? A counter? Link to comment Share on other sites More sharing options...
TangerineDog Posted September 27, 2017 Author Share Posted September 27, 2017 (edited) I'm still trying to fgure that out - basically, I need one script to continually raise x and one that, upon consumption of a food item, reduces x by a number specified for every single food item. So... I guess an actor value would work. Or... no, not yet knowledgeable enough to make any guessing worthwile... Edited September 27, 2017 by TangerineDog Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 27, 2017 Share Posted September 27, 2017 Small example: Int FoodVar = 0 Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Food FoodVar += (1 * aiItemCount) EndIf EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem as Food FoodVar -= (1 * aiItemCount) EndIf EndEventAdds one for each instance to the variable as items are added and subtracts one for each instance as items are removed. FoodVar is the variable that you would reference throughout the remainder of the script in order to do whatever it is that you wish depending upon its value. The above instance would be a snippet of an actor's quest alias script. Link to comment Share on other sites More sharing options...
TangerineDog Posted September 27, 2017 Author Share Posted September 27, 2017 (edited) Thanks, I'm working through that, but I still can't figure out how to transfer it to my problem. I'm still stuck at the point where I need to finish the first script - the one that sets in at some point (need to figure out how to do that, too) and:-establishes the variable HungerCount-raises that variable by 1 every float value of pHoursToWait I'll set in the CK. After that, each food item will have an effect with a certain magnitude that lowers the variable HungerCount by that very magnitude. I'm just too green to know how to establish HungerCount in the first place. Edit:This, added to a magic effect used on a scroll, starts the hunger upon use of the scroll, but it only lasts for the time the scroll' effect lasts. Working on that. ScriptName HungerCounterScript extends activemagiceffectFloat Property pHoursToWait AutoInt Property HungerCount AutoEvent OnUpdateGameTime(); debug.trace(self + "OnUpdateGameTime") HungerCount += 1 Debug.Notification("Hunger increased") RegisterForSingleUpdateGameTime(pHourstoWait) EndEventEvent OnEffectStart(Actor akTarget, Actor akCaster) ; start timer RegisterForSingleUpdateGameTime(pHourstoWait) Debug.Notification("Hunger starting") EndEvent Edit 2:The above script is now part of a constant effect I added to a spell.The scroll now uses a different scripted effect, one that simply adds the spell to the player.Debug Messages prove that adding the spell, the start of the spell and the constant updating work liek a charm. So far, so good.I just ran into another problem, but I'll open another thread for that. Thank you!! Edited September 28, 2017 by TangerineDog Link to comment Share on other sites More sharing options...
Recommended Posts