Notifications
Clear all

[Closed] Maxscript if statment on checkbox help

I’m relatively new to scripting and am trying to write a script (or at least section of it) that takes a checkbox and looks at the value; if its unticked it will disable the current objects bump or if its ticked it will enable it

this is the script I got so far (it is inside a rollout UI). I don’t not know if this is the wrong way to approach this or if it is just the wrong way round. To note bobo11 is the value in which the object’s bump multiplier is set to


checkbox bump “Bump” triState:1

on bump changed theState do
(
if bump.state = false then messagebox "bump off" $.material.bump.multiplier = 0 else messagebox "bump on" $.material.bump.multiplier = bobo11
)

any help will be much appreciated thanks

4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

your syntax is wrong… it can’t work like that…
should be:


checkbox bump "Bump" checked:on --triState:1 -- doesn't make any sense in your case
	
on bump changed state do
(
	if not state then 
	(
		messagebox "bump off" 
		$.material.bump.multiplier = 0
	)
	else 
	(
		messagebox "bump on" 
		$.material.bump.multiplier = bobo11
	)
)


not got max on this PC but that looks alright to me , I know Ive done things like that before and its worked ok.

Your code:

checkbox bump "Bump" triState:1
     	
     	on bump changed theState do
     	(
     if bump.state = false then messagebox "bump off" $.material.bump.multiplier = 0 else messagebox "bump on" $.material.bump.multiplier = bobo11
     	)
How I would do it:
checkbox bump "Bump" triState:1
      	
      	on bump changed theState do
      	(
    		if theState then
    		(
    			 messagebox "bump on" 
    			 $.material.bump.multiplier = bobo11
    		)
    		else
    		(
    			 messagebox "bump off"
    			$.material.bump.multiplier = 0
    		)
      	)
The only real mistake I see in your code is "if bump.state = false " :  "=" is for assignment, you need "==" for comparison :deal: ( if bump.state == false instead of if bump.state = false )

Cheers guys for that guys. Erics approach seemed to work fine