SetScriptVar

Started by Hunter Seeker, May 02, 2013, 06:32:32 PM

Previous topic - Next topic

Hunter Seeker

I have a long code but unless you want to read the whole thing i just want to understand what i am missing in the SetScriptVar

SetScriptVar(<-ChildUID "RemoteEmitter" "IsActive" 1 TraceStack)
SetScriptVar(<-ParentUID "RemoteEmitter" "IsChildActive" 1 TraceStack)

The Trace shows stacks of (bottom to top): {13 "RemoteEmitter" "IsActive" 1} and {5 "RemoteEmitter" "IsChildActive" 1}
I checked traces for the child/parent units to verify correct UID's are 13 and 5.
After this code and trace shows execution the Script Varriable of the other units do not change.
I know i'm missing something but i'm stumped.  Any help is appreciated.

Full code if you want to read it:

$ParentName:"Null"
$SelfName:"Null"
$ChildName:"Null"
$Creeper:100
$Interval:150
$RemoteX:999
$RemoteY:999
#IsActive 0=none 1=digging 2=active
$IsActive:2
#IsChildActive 0=False 1=True
$IsChildActive:0
$DigDelay:1800
$DigTarget:1

once
#if no UserModified remote location, change to self
if(<-RemoteX 999 eq)
CurrentX ->RemoteX
endif
if(<-RemoteY 999 eq)
CurrentX ->RemoteY
endif
#if not active disable digitalus
if(<-IsActive 2 neq)
SetUnitAttribute(Self CONST_SUPPORTSDIGITALIS 0)
endif
#gets UID from ChildName
if(<-ChildName "Null" neq)
GetCoresWithVar("SelfName" <-ChildName)
#should have list of 1 unit UID with 1 as an integer on the top of the stack unless names were reused
#ShowTraceLog
#Trace("ChildStack: ") TraceStack
pop ->ChildUID
endif
#gets UID from ParentName
if(<-ParentName "Null" neq)
GetCoresWithVar("SelfName" <-ParentName)
#should have list of 1 unit UID with 1 as an integer on the top of the stack unless names were reused
#ShowTraceLog
#Trace("ParentStack: ") TraceStack
pop ->ParentUID
endif
endonce

ShowTraceLog
Trace4("Active: " <-IsActive " Child: " <-IsChildActive)

If(<-IsActive 1 eq)
SetTerrain(CurrentCoords GetTerrain(CurrentCoords) -1 add)
#check to see if it dug up to the ground, if so activate
if(GetTerrain(CurrentCoords) <-DigTarget eq)
ShowTraceLog
Trace("DigTracing: ")
2 ->IsActive
SetImage(Self "main" "Emitter")
SetUnitAttribute(Self CONST_SUPPORTSDIGITALIS 1)
SetScriptVar(<-ChildUID "RemoteEmitter" "IsActive" 1 TraceStack)
SetScriptVar(<-ParentUID "RemoteEmitter" "IsChildActive" 1 TraceStack)
else
<-DigDelay Delay
endif
endif


If(<-IsActive 2 eq)
if(<-IsChildActive 0 eq)
SetCreeper(CurrentCoords add(<-Creeper GetCreeper(CurrentCoords)))
<-Interval Delay
else
GetCreeper(CurrentCoords) ->SelfCreeperLevel
GetCreeper(<-RemoteX <-RemoteY) ->RemoteCreeperLevel
<-RemoteCreeperLevel <-SelfCreeperLevel <-Creeper add add 2 div ->NewLevel
SetCreeper(CurrentCoords <-NewLevel)
SetCreeper(<-RemoteX <-RemoteY <-NewLevel)
<-Interval Delay
endif
endif

Aspire to Inspire

knucracker

For the name of the script put "RemoteEmitter.crpl" rather than just "RemoteEmitter".  See if that makes a difference...
Right now I have it so that script names are literally the names of the files on disk.  In theory you could manually create a file without the .crpl extension and it should work fine.

But, I may change this so that if you present something like "RemoteEmitter", I will automatically add ".crpl" internally if not already present.

Hunter Seeker

Aspire to Inspire