Jump to content

Recommended Posts

Posted

I am currently working on a simple script that allows the player to summon any horses he owns at will. I tried adding horses to a property array by applying a magic effect to a horse when the player buys it. The effect caries a script that adds the horse to an Actor Property array. The problem is that when I try to access this array from a separate script, it only returns the default value, none. I did some testing, and it seems that once the OnEffectStart Event that actually stores the horse in the array ends, the array values get reset to none.

 

Is there a way I can store the horses and retrieve them at any given later time? I am looking for something like the GetPlayerLastRiddenHorse() function in the Game script, except that I want to store multiple horses and access any given one at will.

 

Thanks in advance.

Posted
You could also have a magic ring that (when worn) teleports the horse to the player magically. Makes a little more sense (to me, anyway). One ring for each horse in your inventory, and inventories are infinite (in theory).
Posted
If I understood you correctly, you need a way to access a variable from multiple scripts? You do that by declaring a property for your scripts and make that property point to the same object (for example a global variable). That way when you change the value of the variable in one script, it will be changed for all other scripts as well.
Posted

If I understood you correctly, you need a way to access a variable from multiple scripts? You do that by declaring a property for your scripts and make that property point to the same object (for example a global variable). That way when you change the value of the variable in one script, it will be changed for all other scripts as well.

 

That is exactly right. I currently have an actor property that is made, at run-time, to point to the object reference of a horse. However when I try to access this property from a separate script, its value is returned as none. Also, if I try to access the property within the same script, but a different event, it returns none as well. I will include simplified versions of my scripts below. The first is attached to an aimed magic effect and the second is attached to a self magic effect.

 

Scriptname Bind extends ActiveMagicEffect

Actor Property CurrentHorse Auto

Event OnMagicEffectStart(Actor Target, Actor Source)
   CurrentHorse = Target
   Debug.Notification(CurrentHorse)    ;This outputs the reference as intended.
EndEvent


Event OnEffectFinish(Actor Target, Actor Source)
   Debug.Notification(CurrentHorse)    ;This outputs "none."
EndEvent

 

Scriptname Call extends ActiveMagicEffect

Bind Property BindScript Auto

Event OnEffectStart(Actor Target, Actor Source)
   BindScript.CurrentHorse.PathToReference(Source, 1.0)
   Debug.Notification(BindScript.CurrentHorse)    ;This outputs "none."
EndEvent

  • Recently Browsing   0 members

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