I tried to used the script in a mod I've been working and....trying for weeks and couldn't figure out what I'm doing wrong... Any ideas? Thanks!
**********************************************************************************************ORIGINAL CODE FROM WIKI**************************************************************************************************
scn SlidingObjectSCRIPT
ref xObject
short xStdSpeed
short xSpeed
short xMaxDisplacement
float xPosZ
float xPosMin
float xPosMax
begin onactivate
if xObject == 0
; First time only: set vars
;======================
; xStdSpeed positive: Object will initially go up
; xStdSpeed negative: Object will initially go down
;======================
set xObject to aaqqActivator; aaqqPlatform ; aaqqPaint
set xStdSpeed to -5 ; <<< Change to your liking (units per second)
set xMaxDisplacement to 100 ; <<< Displacement limit
set xPosZ to xObject.getstartingpos z
if xStdSpeed > 0
set xPosMin to xPosZ
set xPosMax to xPosZ + xMaxDisplacement
else
set xPosMax to xPosZ
set xPosMin to xPosZ - xMaxDisplacement
set xStdSpeed to -xStdSpeed
endif
endif
if xPosZ <= xPosMin
set xSpeed to xStdSpeed
else
set xSpeed to -xStdSpeed
endif
end
begin gamemode
if xSpeed == 0
return
endif
set xPosZ to xObject.getpos Z + xSpeed * getsecondspassed
if xPosZ > xPosMax
set xPosZ to xPosMax
set xSpeed to 0
endif
if xPosZ < xPosMin
set xPosZ to xPosMin
set xSpeed to 0
endif
xObject.setpos Z xPosZ
xObject.reset3Dstate
end
************************************END ORIGINAL CODE
************************************BEGIN CODE AS IT IS IN THE MOD
scn 111aaaTAMSI01
ref xObject
short xStdSpeed
short xSpeed
short xMaxDisplacement
float xPosZ
float xPosMin
float xPosMax
Begin OnActivate ;Begins when object is activated like a button.
Message "Testing this script",,20 & "2" ;Test "Message" to Insure command is going to the game
If xObject == 0 ; Checks to see if reference object/activator is set
set xObject to TamAeroMSep1 ;Set xobject reference variable to the object you want to move.
set xStdSpeed to 25 ;Change to your liking (units per second) an initial positive # will go up. negivtive down.
set xMaxDisplacement to 500000 ; Max distance in units object will travel before stopping.
set xPosZ to xObject.getstartingpos z ;Capture TES CS Object Starting Position
If xStdSpeed > 0
set xPosMin to xPosZ
set xPosMax to xPosZ + xMaxDisplacement
endif ; End Positive Speed Check and MAX MIN Var value assignement
If xstdspeed <=0
set xPosMax to xPosZ
set xPosMin to xPosZ - xMaxDisplacement
set xStdSpeed to -xStdSpeed
endif ; End Negative Speed Check and MAX MIN Var value assignement
endif ;End Variable value assignment
If xPosZ <= xPosMin ;
set xSpeed to xStdSpeed
else
set xSpeed to -xStdSpeed
endif
end ;End
begin gamemode
if xSpeed == 0
message "xSpeed is still 0"
return
endif
set xPosZ to xObject.getpos Z + xSpeed * getsecondspassed
if xPosZ > xPosMax
set xPosZ to xPosMax
set xSpeed to 0
endif
if xPosZ < xPosMin
set xPosZ to xPosMin
set xSpeed to 0
endif
xObject.setpos Z xPosZ
xObject.reset3Dstate
end