Why won't this rotate?

n4gix

Resource contributor
#1
Can anyone suggest why this script doesn't seem to work? It's not too complicated! It should simply increment the L:var from 0 to 36 then reset, rinse and repeat endlessly:
Code:
  <!-- CUSTOM SCRIPTS -->
  <Animation name="Beacon_Light_Rotate" guid="f7e61f65-6d05-480d-b9f9-6c04e0c0484c" length="36" type="Sim" typeParam2="Beacon_Light_Rotate" typeParam="AutoPlay" />

  <PartInfo>
    <Name>Beacon_Light_Rotate</Name>
    <AnimLength>36</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (A:LIGHT BEACON,bool)
          if{ (L:Beacon_Light_Rotate,enum) ++ 37 % (>L:Beacon_Light_Rotate,enum) }
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>
 
#3
Hi Bill,
Personally, I will simply add a line to the code to know exactly which variable to use for the animation...! Apprentice notice....

Code:
<Code>
    (A:LIGHT BEACON,bool)
    if{ (L:Beacon_Light_Rotate,enum) ++ 37 % (>L:Beacon_Light_Rotate,enum) }
    (L:Beacon_Light_Rotate,enum)
</Code>
 
Last edited:
#4
Some "apprentice notice"! With it does work, without it it doesn't. Now someone riddle me that!

Edit: this also works (putting a copy of the value on the stack) ...

Code:
<Code>
        (A:LIGHT BEACON,bool)
        if{ (L:Beacon_Light_Rotate,enum) ++ 37 % d (>L:Beacon_Light_Rotate,enum) }
</Code>
 
Last edited:

n4gix

Resource contributor
#5
Thanks for the kick in the butt guys. I should have caught that myself, but my only excuses are (a) old age and failing memory and (b) that I don't script all that much any longer having long ago gotten 90%+ that I need already done and tested. Rarely do I have to do something "new."

Of course "duplicating" the result of the iteration using "d" to put the result on the stack is absolutely necessary, otherwise the result isn't "remembered" for the next iteration! :wave:
 
#6
Of course "duplicating" the result of the iteration using "d" to put the result on the stack is absolutely necessary, otherwise the result isn't "remembered" for the next iteration!
This method is much more elegant than mine...! We learn a little more every day...! :D
 
#7
I am left a little confused by this thread. I copied and pasted the original code into a gauge and watched the value of the variable count up to 36 repeatedly as intended. So the code works in a gauge, but not when compiled into the model?
 
#8
It also works very well in the .mdl : the value of (L:Beacon_Light_Rotate,enum) is well implemented, but the animation does not know which value to use to make the animation work. For this reason, it is necessary to "remind" the animation that it is the variable (L:Beacon_Light_Rotate,enum) that it should be used, and it is necessary to put it on the stack!
 
Top