basic question

I am making my first script which simply moves a model up or down based on an input to a textbox. I have not figured out how to read the integer typed in the textbox. The reference said that suffix .text would would give it, but it didn't seem to work. All help would be greatly appreciated. Thanks in advance.

rollout mover_script "make stuff move" width:159 height:315
(

button btn1 "move up" pos:[9,7] width:66 height:19
button btn2 "move down" pos:[9,30] width:66 height:19
edittext tbox "" pos:[8,142] width:143 height:20
on mover_script open do
global amount = 12
on btn1 pressed do
$.pos.z += amount
on btn2 pressed do
$.pos.z -= amount
on tbox entered text do
amount = tbox.text
)floater= newrolloutfloater "..." 159 315
addrollout mover_script floater

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ASX's picture

Trying the first

Trying the first method,
rollout mover_script "make stuff move" width:159 height:315
(

button btn1 "move up" pos:[9,7] width:66 height:19
button btn2 "move down" pos:[9,30] width:66 height:19
edittext tbox "" pos:[8,142] width:143 height:20
on mover_script open do
global amount = 12
on btn1 pressed do
$.pos.z += amount
on btn2 pressed do
$.pos.z -= amount
on tbox entered text do
tbox.text as amount
)floater= newrolloutfloater "..." 159 315
addrollout mover_script floater

I am given an error.
Type conversion needs a class argument, got:12

:)

jos's picture

<number> as <class>

you should look at this :

http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012//index.ht...

tbox.text as float

not as amount! -> error you've got 12 = you want to convert tbox.text to 12 (because global amount = 12) 

jos's picture

casting

you've got an error : incompatible types: 0.0, and ""

this mean $.pos.z wants a float as input 1.2, but a textbox is type of string "blabla"

you can simply solve this by use this code :

tbox.text as float and your code will work.

I recommend you to use a spinner in this case. default type of spinner is float.

here as simple as it can :

rollout mover_script "make stuff move"

(

button btnUp "move up" across:2

button btnDown "move down"

edittext tbox ""

spinner spnAmount "Amount :"

on btnUp pressed do

(

--$.pos.z += tbox.text as float

$.pos.z += spnAmount.value

)

on btnDown pressed do

(

--$.pos.z -= tbox.text as float

$.pos.z -= spnAmount.value

)

)

createDialog mover_script 200 100

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.