Monday, July 27, 2009

Simple Programming question....?

The language is a Lua Script and C++ ... but anybody could probably answer because it is more or less a what to do question...





I have a print within a method, How would i randomize the print so that when the finite state machine moves to the next method/state it chooses between 3 possible prints.





example of code...








State_GoHome = {}








State_GoHome["Enter"] = function(miner)





*print statement 1 of 3 * make this print a random statement....*





end











I have a method that makes a random number already...





Let me know if you need more info or want to see actual code...

Simple Programming question....?
TL;DR
Reply:you could use a switch/case statement:


switch(your_random_number%3) {


case 0:


case 1:


case 2:


}


No comments:

Post a Comment