ScriptSpot

Forum topic · General Scripting

A condition for if value incresed

By vrman · 2013-07-28

Description

hi guys , i created a script controller for Z position , i want to run script only when my object moves in +Z . i don`t want to use time (to check a value in previous frame and know it rise or not ) , because i need a interactive controller , in time u need to click on play button.

is there any solution ?

Comments (2)

Budi G · 2013-08-07

Hi vrman, I'll trying to help you.

This Script will create New Spinner controll on base Object and Assign Float Sctipt Controller for Z position.


---------------------------------------- Example: Create New 'Spinner' - Custom Attribute on Base Object first
fn Add_Attributes obj =
( -- start fn
   PoscontrollerData= attributes TheController
    ( -- attributes
       parameters main rollout:params
       ( 
	     hitspeed type:#float ui:hits default:1 animatable:true 
       )
       rollout params "Position Parameters"
       (
         spinner hits "Hit Speed" type:#float range:[-100,100,1] -- New 'Spinner'
       )
    ) -- attributes
 CustAttributes.add obj PoscontrollerData #Unique BaseObject:true
) -- end fn

Add_Attributes $ -- Execute Add_Attributes Function


---------------------------------------- Example: Assign Float Script into Z Position
fn Assign_FloatScript obj =
( -- start fn
   ctrl = float_script()
   obj.pos.controller.Z_Position.controller = ctrl
   ctrl.addTarget "speed" $.baseObject.TheController[1] -- Add Target Variable with New 'Spinner' Object
   ctrl.script = "currenttime*Speed"-- Set Expression
) -- end fn

Assign_FloatScript $ -- Execute Add_Attributes Function

to use it:
- Create object (ex: Teapot) and select the object First.
then run a script.

- Then Click on play button ... so you can control the speed
by "Hit Speed" Spinner (its animatable if need it).

well.. is this what you need ?

Regards

vrman · 2014-07-06

thank u so much Budi , yes thats what i want .