[Closed] Argument Count Error Help
Hi all,
New to maxscript, I’ve been following some of Bobo’s explanations on scriptspot, however I’m stuck with an error I’m not understanding at all. Everything works fine until the button is pressed then I get an error Argument count error: hide wanted 1, got 5 <<…
As far as I’m concerned Hide should be happy he’s getting 4 more than what was originally intended…anyway I’m stumped… what am I missing?
Script below.
try (closeRolloutfloater ballholder) catch()
ballheight = 1
print ballheight
rollout balls “test”
(
button btn_left “Left”
button btn_right “Right”
on btn_left pressed do
(
ballheight = ballheight+1
case ballheight of
(
1 :unhide $1 hide $2 hide $3
2 :hide $1 unhide $2 hide $3
3 :hide $1 hide $2 unhide $3
)
)
on btn_right pressed do
(
sphere()
)
)
ballholder = newrolloutfloater “Main” 500 565
addrollout balls ballholder
case ballheight of
(
1 :(unhide $1; hide $2; hide $3)
2 :(hide $1; unhide $2; hide $3)
3 :(hide $1; hide $2; unhide $3)
)
You need some separation between your maxscript commands. A command in MaxScript must end in either a line break or a ; character.
a = 1 b = 2 c = 3 <– invalid
a = 1; b = 2; c = 3 <– valid
Or… I prefer to use multi-lines… much easier to read and de-bug.
case ballheight of
(
1 :(
unhide $1
hide $2
hide $3
)
2 :(
hide $1
unhide $2
hide $3
)
3 :(
hide $1
hide $2
unhide $3
)
)
I prefer a multi-action
case ballheight of
(
1 :
(
unhide $1
hide #($2,$3)
)
2 :
(
unhide $2
hide #($1,$3)
)
3 :
(
unhide $3
hide #($1,$2)
)
)
there is a problem with tabulation on my phone…
Just to help you understand the error,
error Argument count error: hide wanted 1, got 5 <<...
This is saying this because you’ve done this line…
unhide $1 hide $2 hide $3
unhide is a max function which expects only 1 argument, which is a node or collection of nodes, you have passed 5 arguments.
let’s do something funny:
for b in #{1..3} do (if b == ballheight then unhide else hide) (execute ("$" + b as string))
or funnier:
for b in #{1..3} do (execute ("$" + b as string)).ishidden = (b == ballheight)
Shorter…
hide #($1, $2,$3)
case ballheight of
(
1 :
(
unhide $1
)
2 :
(
unhide $2
)
3 :
(
unhide $3
)
)
ok. now be serious.
let’s do it in general case…
to_hide = #()
to_unhide = #()
for node in <nodes> do append (if <condition is true> then to_unhide else to_hide) node
hide to_hide
unhide to_unhide