Script: Set a property from another script

Post » Wed Jun 20, 2012 2:03 am

Hey modders.

I need help with a script, what I am trying to do is set the property of a script using another script.

What I need is some simple (and I mean simple and easy to understand) examples of scripts that do just this. What the script would have to do is change the property of another script when a specific item is equipped so base your examples on that basis pls, thanks

Also use Script01 as the name for the script that would have the property which would be changed by the other script (Script02).



scriptname Script01 extends Quest

If Hand01 == false
additem01
elseif Hand01 == true
additem02
end


Bool Property Hand01 Auto

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


scriptname Script02 extends ObjectReference


event onequip()

(here is where the property (Hand01) attached to Script01 is set by Script02)

endevent






:ermm:
User avatar
Oyuki Manson Lavey
 
Posts: 3438
Joined: Mon Aug 28, 2006 2:47 am

Post » Wed Jun 20, 2012 11:10 am

If you add a property of type Script01, then you will be able to access the Hand01 property on the object at which you point your Script01 property. Alternately, if you can return that object via a function that returns on object of type http://www.creationkit.com/Quest_Script (or some other ancestor of Script01) then you could cast that object to type Script01 to make your custom property accessible.

Cipscis
User avatar
Emily Shackleton
 
Posts: 3535
Joined: Sun Feb 11, 2007 12:36 am

Post » Tue Jun 19, 2012 9:28 pm

If you add a property of type Script01, then you will be able to access the Hand01 property on the object at which you point your Script01 property. Alternately, if you can return that object via a function that returns on object of type http://www.creationkit.com/Quest_Script (or some other ancestor of Script01) then you could cast that object to type Script01 to make your custom property accessible.

Cipscis

"I mean simple and easy to understand"

Did not understand much of that, sorry. If you look at Script01 theirs a bool property.

Need example scripts.
User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am

Post » Tue Jun 19, 2012 8:52 pm

OK, here ya go, sport.

Script 1:

Scriptname IHaveSomeProperties Extends ObjectReferenceInt Property IntProp Auto ; An integerbool Property BoolProp Auto ; A booleanObjectReference Property ObjProp Auto ; An ObjectReference; Other Script stuff here, Functions, events, etc.

Script 2:

ScriptName IUsePropertiesFromScript1 Extends ObjectReferenceIHaveSomeProperties Property OtherScript Auto ; Assign this in the "properties" button outside the script, or from another script.Function SetBoolProperty(Bool What) ; Function to set the boolean property on  the other script.   OtherScript.BoolProp = WhatendFunctionBool Function GetBoolProperty() ; returns the value of the Bool Property on the other script.   return OtherScript.BoolPropEndFunctionFunction SetObjectProperty(ObjectReference What)  OtherScript.ObjProp = WhatendFunctionObjectReference GetObjectProperty()   return OtherScript.ObjPropEndFunctionFunction SetIntProperty(ObjectReference What)  OtherScript.IntProp = WhatendFunctionint Function GetIntProperty()   return OtherScript.IntPropEndFunctionFunction SetObjectProperty(ObjectReference What)  OtherScript.ObjProp = WhatendFunctionObjectReference Function GetObjectProperty()   return OtherScript.ObjPropEndFunction

In short, you need a property that refers to the other script...you can then access those properties by using a period followed by the property name.
User avatar
Liii BLATES
 
Posts: 3423
Joined: Tue Aug 22, 2006 10:41 am


Return to V - Skyrim