Jump to content

Maxscript Help


Swobbly Minogue
 Share

You are about to reply to a thread that has been inactive for 3829 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi,

This is not related to SL but I have leant so much from the folks in these forums over the years that I am going to ask for help here anyway as you guys rock! 

 

I am currently studying a design course that includes a Maxscript unit. So far things are just not "clicking" which is slowing my learning. This problem is confounded by the fact that my lecturer has very poor English and even when he explains things in great detail, it leaves many of his students befuddled. I am really hoping someone will be kind enough to spare some time here to help me out.

Anyway, here is my specific problem:

Initially I had to write a script that uses a 'for' loop to create 100 boxes at random positions. I did this (as you will see below).

I then have to create a rollout with a button that when pressed, executes the above mentioned 'for' loop. I Did that.

I then need to add a spinner that would allow the user to set how many random boxes are generated when the button is pressed. This is where I am having issues. I cannot work out how to link the spinner to the button to achieve the desired result. If someone could help with this then that would be great.

After I have the spinner working I need to do the following: Add a 'dice roll' stopping condition, using a 20 sided dice. So the script stops looping if a 20 is rolled. There is a second stopping condition too, and that is if the number of boxes specified by the the user have been created then the script needs to stop. If neither of these conditions are true then the script will keep looping until a condition is met. I have no idea how to go about writing this, so any help would be much appreciated.

 Here is what I have written so far:

 

[CODE]

resetMaxFile #noprompt --resets the scence without a prompt

try (destroydialog myrollout) catch ()

rollout myrollout "testing" width:350 height:713

(

button but_01 "Random Boxes" pos:[37,7] width:88 height:21

spinner spn-01 "Box Qty" pos:[136,8] width:46 height:16 range:[0,100,50]

               

                on but_01 pressed do

                (mybox = box length:10 width:10 height:10 wirecolor:blue --new box

                                                for i = 1 to 100 do --repeat 100 times, for each iteration

                                                (

                                                                box_copy = copy mybox --create a copy of the original box

                                                                box_copy.pos  = random [-20, -20, 0] [80, 80, 0]) --place a random position within the defined coords

                                                )

)

createdialog myrollout 200 200

[/CODE]

 

If anyone has the time and knowledge to help then I would be very grateful.

Thanks.

Link to comment
Share on other sites

try (destroydialog myrollout) catch ()rollout myrollout "testing" width:450 height:713(button but_01 "Random Boxes"  width:88 height:21spinner spinnerAmount "Box Qty" width:46 height:16 range:[0,100,50]	on but_01 pressed do	(		mybox = box length:10 width:10 height:10 wirecolor:blue --new box		for i = 1 to spinnerAmount.value as integer - 1  do --repeat as often as defined by spinnerAmount's value (-1, otherwise one more would be created)		(			theDiceValue = random 1 20 --roll the dice: create a random number between 1 and 20 (1 and 20 are included)			if theDiceValue == 20 then 							--if dice is the "stop-number 20"...			(				print "The dice rolled 20, stopping creating."--...print the info				exit													  --...and exit the loop			)			else			(				print ("The dice rolled " + theDiceValue as string + ", creating a box.")--print what number the dice had rolled				box_copy = copy mybox --create a copy of the original box				box_copy.pos  = random [-20, -20, 0] [80, 80, 0]) --place a random position within the defined coords			)		)		)createdialog myrollout 200 200

 

Link to comment
Share on other sites

Thankyou ever so much Marielle! I cannot believe I did not try putting the spinner value in the place you put it, I spent hours trying different layouts and it did not occur to me to put it there, which seems stupid in hindsight.

Thankyou also for showing me how to add the random dice value I really appreciate your effort.

 

Thanks also to Kwak for your input :o)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3829 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...