taglag Posted October 16, 2013 Share Posted October 16, 2013 (edited) Could someone help me with a reciprocation Script for and Object. Every thing I have come up with is rather lame. I can not seem to get a simple piston action to work in the way I wish. I was hoping that some of you might have some sample scripts to get me started in the right direction. This is a very lame script, first attempt, I am sure there must be and easier way, and I actually desire a much smoother action than this allows. It is just to give and Idea of what I was wanting. Very quickly done, and I am sure there is a much better, and easier way. And I hope smoother faster action if needed. However this would always move the Object up and down, reguardless of it's Orientation. and It would be better if I could rotate it, and still have the Object move in the same direction back and forth. Begin gamemode set me to getself if Me.getdistance player > 800 return else if once == 0 me.enable set zstart to me.getpos z set znew to zstart set once to 1 endif endif ;***UP*** if timer >= 10 && timer < 12 && reverse == 0 && step == 0 set znew to znew + 4 me.SetPos z znew set step to 1 elseif timer >= 20 && timer < 22 && reverse == 0 && step == 1 set znew to znew + 4 me.SetPos z znew set step to 2 elseif timer >= 30 && timer < 32 && reverse == 0 && step == 2 set znew to znew + 4 me.SetPos z znew set step to 3 elseif timer >= 40 && timer < 42 && reverse == 0 && step == 3 set znew to znew + 4 me.SetPos z znew set step to 4 elseif timer >= 50 && timer < 52 && reverse == 0 && step == 4 set znew to znew + 4 me.SetPos z znew set step to 5 endif ;***Down*** if timer <= 52 && timer > 50 && reverse == 1 && step == 0 set znew to znew - 4 me.SetPos z zNew set step to 1 elseif timer <= 42 && timer > 40 && reverse == 1 && step == 1 set znew to znew - 4 me.SetPos z zNew set step to 2 elseif timer <= 32 && timer > 30 && reverse == 1 && step == 2 set znew to znew - 4 me.SetPos z zNew set step to 3 elseif timer <= 22 && timer > 20 && reverse == 1 && step == 3 set znew to znew - 4 me.SetPos z zNew set step to 4 elseif timer <= 12 && timer > 10 && reverse == 1 && step == 4 set znew to znew - 4 me.SetPos z zNew set step to 5 endif if reverse == 0 if timer < 60 set timer to timer + GetSecondsPassed else PrintToConsole"timer got 60" set reverse to 1 if step == 5 set step to 0 endif endif endif if reverse == 1 if timer > 0 set timer to timer - GetSecondsPassed else PrintToConsole"timer got to 0" set reverse to 0 if step == 5 set step to 0 endif endif endif END Oblivion is I know not top line for anyone any more, but I was hoping someone could help me with this. Edited October 16, 2013 by taglag Link to comment Share on other sites More sharing options...
QQuix Posted October 16, 2013 Share Posted October 16, 2013 This is a sample script to keep an object going up and down. Hope it can give you some ideas. Use at will. Note that using GetSecondsPassed as a multiplier for the speed gives you a smoother movement at any FPS begin gamemode 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 GetSelf 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 set xPosZ to xObject.getpos Z + xSpeed * getsecondspassed if xPosZ > xPosMax set xPosZ to xPosMax set xSpeed to -xStdSpeed endif if xPosZ < xPosMin set xPosZ to xPosMin set xSpeed to xStdSpeed endif xObject.setpos Z xPosZ xObject.reset3Dstateend Link to comment Share on other sites More sharing options...
taglag Posted October 17, 2013 Author Share Posted October 17, 2013 (edited) This is a sample script to keep an object going up and down. Hope it can give you some ideas. Use at will. Note that using GetSecondsPassed as a multiplier for the speed gives you a smoother movement at any FPS begin gamemode 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 GetSelf 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 set xPosZ to xObject.getpos Z + xSpeed * getsecondspassed if xPosZ > xPosMax set xPosZ to xPosMax set xSpeed to -xStdSpeed endif if xPosZ < xPosMin set xPosZ to xPosMin set xSpeed to xStdSpeed endif xObject.setpos Z xPosZ xObject.reset3Dstateend Thx U so much, It was just one of those thing's i had never tried, or thought about untill recently when I was picking at something. I knew about using activator's but was trying to avoid that, as it become to cumbersome moving the activator's and the Object if used in many places. I will surely give this a try.. Thx U again I was assuming the locals were like this ? REF xObject short xStdSpeed short xSpeed short xMaxDisplacement float xPosMax float xPosMin float xPosZ ; Edited October 17, 2013 by taglag Link to comment Share on other sites More sharing options...
taglag Posted October 17, 2013 Author Share Posted October 17, 2013 (edited) Thank you very much, I could not quite get what you had working, I am not a great scripter, but I managed to take what you taught me, and make this, which is not as clean as your's, but works pretty well for my needs. Thank you again SCN DZMVHeavyPress ; Float zStart Float zNew short once Short reverse float Maxz float Minz short ZSpeed Ref ME ;***Rotate axis, degrees/sec :if i need it Begin Onactivate Messagebox"You'll get a broken hand Dummy !" OK end Begin gamemode set me to getself if Me.getdistance player > 800 return else if once == 0 ; me.enable set zstart to me.getpos z set Minz to zstart set maxz to zstart + 15 set ZSpeed to ZSpeed + 3 set once to 1 endif endif ;***Toggle if me.getpos z >= maxz set reverse to 1 elseif me.getpos z <= Minz set reverse to 0 endif ;***UP*** if me.getpos z < maxz && reverse == 0 set znew to me.GetPos z + zspeed * getsecondspassed me.SetPos z znew endif ;***Down*** if me.getpos z > Minz && reverse == 1 set znew to me.GetPos z - zspeed * getsecondspassed me.SetPos z znew endif END I may stream line it a little more latter, but for now it seems okay. Edited October 17, 2013 by taglag Link to comment Share on other sites More sharing options...
QQuix Posted October 17, 2013 Share Posted October 17, 2013 Glad I could help.Have fun. . . Link to comment Share on other sites More sharing options...
Recommended Posts