Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init()
- {
- setupFunctionsArray();
- }
- setupFunctionsArray()
- {
- level.rollTheDiceFunctions = []; // Make an empty array
- level.rollTheDiceFunctions[level.rollTheDiceFunctions.size] = ::print; // Add the function reference to the array
- level.rollTheDiceFunctions[level.rollTheDiceFunctions.size] = ::print2; // Add the function reference to the array
- // Keep adding...
- }
- executeRandomFunction()
- {
- randomIndex = randomInt(level.rollTheDiceFunctions.size); // Get a random index of the array
- function = level.rollTheDiceFunctions[randomIndex]; // Get the random function
- self [[function]](); // Call the function with no parameters
- }
- print()
- {
- self iPrintln("Test");
- }
- print2()
- {
- self iPrintlnBold("Test");
- }
- keepingRollingTheDice()
- {
- level endon("game_ended");
- self endon("disconnect");
- while(true)
- {
- self executeRandomFunction();
- wait 0.05;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement