Maxscript Unable to Convert Type to Float

Code:

oldvalue = me.value at time (F-1)
newvalue = me.value
if oldvalue >= newvalue
oldvalue + newvalue

It throws the error "unable to convert type undefined to type FLOAT".

If I remover the comparison at line 3 then it works just fine, but if I have that >= statement then it throws the error

I am having trouble accessing a value and if then ing that value

my question in demonstration and detail
www.youtube.com/embed/5_Jcy0LZYaM

Comments

Comment viewing options

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

...

I saw that you already started this thread on CGTalk but anyway...
This expression works for me

old = at time (F-1)
new = me.value
if old >= new then old + new else new

This is not common topic and I suggest you to see other threads on CG Talk about using audio controller.

bga

autodidactdystopia's picture

I found this thread

http://forums.cgsociety.org/showthread.php?f=86&t=969963&highlight=audio...

Seems to be exactly what im looking for but its for maya. talks about custom attributes on a "locator" in maya.

very neat, as this is literally the exact thing im looking for but I cant use it as I don't know of any equivalent functionality in max.

I have ae and sounkeys and the "integrate" functionality is exactly what im trying to mimic in max, an ever growing value as opposed to a value that shoots up to 100 and back to 0

would you happen to know anything about maya?

:D im gonna keep scouring threads see if I can come up with anything else

-auto

barigazy's picture

...

Are DenisT already suggest you to use CA?

bga

autodidactdystopia's picture

I found it!

WOOT!

solution posted by lo

http://forums.cgsociety.org/showthread.php?f=98&t=1023117&page=2&pp=15&h...

progressive controller :D

after a quick pm I was instructed on how to use it and whammo :D

IM SO HAPPY RIGHT NOW!

thank you for all of your help!

:D :D :D

for others searching

here is the script

p = helix name:"path" radius1:20 radius2:10 height:50 turns:2 bias:-0.2 direction:0 pos:[0,0,0] wirecolor:yellow
s = sphere name:"happyball" radius:3 smooth:on segs:32 pos:[0,0,0] isselected:on wirecolor:green
c = s.pos.controller = Path_Constraint path:p
 
b = box name:"boombox" width:10 length:10 height:10 pos:[30,0,0] wirecolor:orange
a = b.pos.controller.z_position.controller = AudioFloat()
 
v = c.percent.controller = float_script()
v.AddObject "audio" a
 
scr = ""
scr += "local value = 0\n"
scr += "for i = animationRange.start.frame to F do at time i value = value + audio.value\n"
scr += "value\n"
 
v.SetExpression scr

run script at beginning of scene will create a box and helix and a sphere
there should be an audio float on the z axis of the box
put audio in there
wire param to the object you want to control via sphere or boombox>transform>percent and wire to whatever you want to control

make sure to divide the output or the results will be too fast,

I had to divide by 200 to get it to recognizable levels :D

WOOT!

autodidactdystopia's picture

I think so

But when I implement his script it throws the same errors I was getting before.

no "-" function for undefined

I have no idea how I would import data from a soundkeys generated file into max.

If there were a way to import a text file into a custom attribute curve then I think that might work...

Im sorry if im a little confused. Ive only recently dove down this road to try and achieve this in max.

autodidactdystopia's picture

:D

well thank you.

I have tried the new script in the configuration in the file.

Ive scoured the web looking for this answer haha but unfortunately this script seems to not be filtering out negative trending values.

I added this script to the script controller and assigned me variable to the audio float controller using assign controller as any other configuration results in the error circular dependency.

I also used the debug feature to get readouts on old and new
and when I do so the same value is displayed.

while I for the first time get no errors. It seems that nothing is happening to the data any differently then if I had not written a script at all. :(

My objective has proven to be a hard one and ill continue searching cgtalk scriptspot and creativecow :)

my goal is to integrate the data from the audio float into the value of the rotation

Pseudocode

If tellingmetorotateclockwise then rotate clockwise

else if tellingmetorotatecounterclockwise then do nothing or flip the value and rotate clockwise

in other words continually rotating clockwise to the beat. never returning to the beginning state. and never rotating counter clockwise.

this has been a huge problem for me haha ive probably spent over 100 hours already attempting to figure this out on my own, and have come up short

I really thank you for your time off to go read audio float threads ;)

-auto

Comment viewing options

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