Jump to content


Photo

Need Help With Gml.


  • Please log in to reply
8 replies to this topic

#1 Zpace

Zpace

    GMC Member

  • GMC Member
  • 54 posts

Posted 21 March 2008 - 04:30 PM

What is the GML code for this function --> :P
Thanks.

Edited by Zpace, 21 March 2008 - 04:35 PM.

  • 0

#2 FinPker

FinPker

    GMC Member

  • New Member
  • 47 posts

Posted 21 March 2008 - 04:37 PM

variable=random(number of sides);

if variable=1

{

Actions

}

  • 0

#3 Zpace

Zpace

    GMC Member

  • GMC Member
  • 54 posts

Posted 21 March 2008 - 04:41 PM

variable=random(number of sides);
if variable=1
{
Actions
}


Thank you, well, that's what I thought but that seems so much more complicated ^^. Oh well, thanks.
  • 0

#4 FireWire Games

FireWire Games

    GMC Member

  • New Member
  • 1548 posts

Posted 21 March 2008 - 04:42 PM

Try using the switch functions. They can make your life a lot easier:
{
	myvar = floor(random(2));
	switch(myvar){
		case 0:
		show_message("myvar = 0");
		break;
		case 1:
		show_message("myvar = 1");
	}
}
Remember to add the break; after every case. You don't have to add it in the last one.

~FireWire Games

Edited by FireWire Games, 21 March 2008 - 04:43 PM.

  • 0

#5 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 21 March 2008 - 04:50 PM

@ Zpace

...do what FireWire said...his makes sure the number is NOT a decimal...and it truly makes life easier!

Edited by GMREC1111, 21 March 2008 - 04:50 PM.

  • 0

#6 Zpace

Zpace

    GMC Member

  • GMC Member
  • 54 posts

Posted 21 March 2008 - 05:07 PM

Try using the switch functions. They can make your life a lot easier:

{
	myvar = floor(random(2));
	switch(myvar){
		case 0:
		show_message("myvar = 0");
		break;
		case 1:
		show_message("myvar = 1");
	}
}
Remember to add the break; after every case. You don't have to add it in the last one.

~FireWire Games


Oh yeah, how could I forget the Case Switch :P . I guess I have already used all my braincells today ^^.


@ Zpace

...do what FireWire said...his makes sure the number is NOT a decimal...and it truly makes life easier!


Yeah or you can use the round(random(2)) to get the numbers 0, 1 or 2 right? :o
  • 0

#7 FireWire Games

FireWire Games

    GMC Member

  • New Member
  • 1548 posts

Posted 21 March 2008 - 05:08 PM

Yes, round(random(2)) should give you 0, 1, or 2 if I'm not mistaken.
  • 0

#8 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 21 March 2008 - 05:09 PM

ceil...round...floor...Theres a lot. round, rounds to the closest solid number I think. Ciel ALWAYS rounds up...floor rounds down?

Example...:

ceil = 1.24521 would take it to two?

floor = 1.99999 would take it to 1?

round = 1.5201 possibly goes to 2 and it it's 1.4524 maybe it goes to 1?

Edited by GMREC1111, 21 March 2008 - 05:12 PM.

  • 0

#9 Zpace

Zpace

    GMC Member

  • GMC Member
  • 54 posts

Posted 21 March 2008 - 05:16 PM

Yeah, thank you everyone for your help :P.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users