Notifications
Clear all

[Closed] Buttons not working

Hi all,

I’m progressing slowly with maxscript, Im currently stuck, my buttons don’t seem to be working in this simple script. Forgive me I’m new. I ran out of hairs on my head to pull out so I’m posting here!

Nothing happens when I press my buttons!!!

try (closeRolloutfloater ballholder) catch()

rollout balls “test”

(
button left “Left”

on my button pressed do
(
box()
)

button right "Right"

on my button pressed do
sphere()

)
ballholder = newrolloutfloater “Main” 500 565
addrollout balls ballholder

6 Replies
try (closeRolloutfloater ballholder) catch()

rollout balls "test"
(
button btn_left "Left"
button btn_right "Right"

on btn_left pressed do
(
box()
)

on btn_right pressed do
(
sphere()
)
)
ballholder = newrolloutfloater "Main" 500 565
addrollout balls ballholder

I’ve changed a few things in your script, it will work now, take a look at my Blog for beginners advice on MaxScript.

man that is terrible, I think I pasted the values from a tutorial over my script I didn’t notice the names were completely difference… define global fail variable here…

Thanks, and looking at your blog now…hair is growing back…

Much appreciated!

P.S is it true variables cannot be created within rollouts?

Like this?

try (closeRolloutfloater ballholder) catch()

rollout balls "test"
(
button btn_left "Left"
button btn_right "Right"

local p = 10

on btn_left pressed do
(
box()
print p
)

on btn_right pressed do
(
sphere()
print p
)
)
ballholder = newrolloutfloater "Main" 500 565
addrollout balls ballholder

Ahh, I see…

I am so close to achieving what I need and have learnt so much so far! can I please bug you for one last thing, in light of your variable definition I then wanted to use that variable to pass it as a ‘counter’, hiding objects as I hit buttons, however I am encountering problems with the IF statements? Which I can’t tell what is wrong! Really really appreciate it!!!

I have three objects named : a b c

Here is my code

try (closeRolloutfloater ballholder) catch()

rollout balls “test”
(

button btn_left “Left”
button btn_right “Right”

local varCounter
on btn_left pressed do
(
varCounter = varCounter+1
if varCounter == 1 then
unhide $a
hide $b
hide $c

else if varCounter == 2 then
hide $a
unhide $b
hide $c

else if varCounter == 3 then

hide $a
hide $b
unhide $c

)

on btn_right pressed do
(
varCounter = varCounter- 1

if varCounter == 3 then
hide $a
hide $b
unhide $c

else if varCounter == 2 then
hide $a
unhide $b
hide $c

else if varCounter == 1 then

unhide $a
hide $b
hide $c

)
)
ballholder = newrolloutfloater “Main” 500 565
addrollout balls ballholder

When doing if statements with multiple lines for each statement then you need to put some brackets in.

If a > 2 then
(
--do this
--and do this
)

If you want to have an else it can only be written as

if a > 2 then
(
--do this
)
else
(
-- do this instead
)

If many statements it is better to use Case Of

Case of
(
(a >2) : (
--do this
)
(a < 2) : (
--do this
)
(a == 2) : (
--do this
)

)

or…

Case a of
(
1 : (
--do this
)
2 : (
--do this
)
3 : (
--do this
)

)

Thank you so much! I’ll try rebuilding using this advice, very very grateful!!!

:wip: