Need help sharing an objectreference as a variable

Post » Thu Jun 21, 2012 4:29 am

I have three buttons that when you press one of them I want it to set a variable shared between the three buttons to a different objectreference thus the script in each button knows what the objectreference has been set to. Please help I have not found what I consider a good example of this that I completely understand.

For more information say if you press button A and it sets Objectreference to a xmarker in solitude but if you press button A it is an xmarker in riverwood. Then button C can move the actor to either of the choices ?


Thanks
User avatar
kirsty williams
 
Posts: 3509
Joined: Sun Oct 08, 2006 5:56 am

Post » Thu Jun 21, 2012 5:56 pm

are you enabling/disabling the xmarkers?

im not entirely sure what you're asking or what you're trying to achieve

if all you are doing is enabling/disabling various xmarkers through buttons, the buttons do not need to "talk" to each other through variables, they only need to query whether or not the markers are enabled/disabled


for example lets say you have a room with 2 light switches, hitting will turn on or off the light, but you want each button to know if the light is already on or off. one way is to do like you say where you share a variable between them (totally unnecessary though). the other way is for each light swith to do a condition function

if lightmarker.isenabled()
TurnOff()

elseIf lightmarker isDisabled()
TurnOn()

endIf



can be the exact same script used on both switches
User avatar
Ezekiel Macallister
 
Posts: 3493
Joined: Fri Jun 22, 2007 12:08 pm

Post » Thu Jun 21, 2012 6:13 pm

Actually I am trying to use the buttons to set a location for the last button to move the actor to. So Button A = Location 1 Button B = Location 2 and Button C is take me to what was set by button A or B
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Thu Jun 21, 2012 10:27 am

you can do this either using states or a global variable. it's simpler to write a script using a global variable, but in my experience using states would be a little more reliable (i personally try to use globals as little as possible)


here's how it would work with states:



this would go on button C. the button by itself will not do anything until it has its state set by either of the 2 other buttons

ObjectReference Property Location1 AutoObjectReference Property Location2 AutoEvent OnInit()  GoToState("Idle")EndEventState IdleEndStateState Loc1  Event OnActivate(ObjectReference akActionRef)	  akActionRef.MoveTo(Location1)  EndEventEndStateState Loc2  Event OnActivate(ObjectReference akActionRef)	  akActionRef.MoveTo(Location1)  EndEventEndState


This script would go on Button A and B

ObjectReference Property ButtonC  AutoString Property StateLocation  AutoEvent OnActivate(ObjectReference akActionRef)	(ButtonC as WhateverNameOfButtonCScript).GoToState(StateLocation)EndEvent


In the properties of that script you point ButtonC to button C obviously, and in the StateLocation you set the name of the state that you want it to enter.



for example lets say Location1 is pointing to Solitude, and Button A is supposed to set that marker for travel. so in the script properties of Button A, you would write Loc1 as the string value for StateLocation, and Loc2 for the string property on Button B's script.
User avatar
Strawberry
 
Posts: 3446
Joined: Thu Jul 05, 2007 11:08 am

Post » Thu Jun 21, 2012 8:52 am

Wow Thank you... I was able to use and build upon that code wonderfully. Awesome... I really want to say I am grateful for the help.
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm


Return to V - Skyrim