Jump to content

[LE] Have script set variable to value?


TangerineDog

Recommended Posts

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

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 by TangerineDog
Link to comment
Share on other sites

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
EndEvent

Adds 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

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 activemagiceffect

Float Property pHoursToWait Auto
Int Property HungerCount Auto

Event OnUpdateGameTime()

; debug.trace(self + "OnUpdateGameTime")
HungerCount += 1
Debug.Notification("Hunger increased")
RegisterForSingleUpdateGameTime(pHourstoWait)

EndEvent

Event 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 by TangerineDog
Link to comment
Share on other sites

  • Recently Browsing   0 members

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