This is a short script made by FL for use in "The Plan's Simple" as part of Summer Jam #8.
If you don't want to download everything else in the resource pack, you are in the right place.
Paste this script above Main (I put it in the minigames section):
In an event:
1. Generate a random number between 0-9999 and assign it to a variable (in this example, 98).
2. Set a jump label "start guessing".
3. Prompt player to input a 4-digit number (it is an event command) and assign it to a variable (in this example, 99).
4. Check if the two variables are equal in an event conditional branch.
5. If they are, tell them they have cracked the code.
6. If aren't, call the script 'print_guesses_from_var(98,99)'. Then jump to the label "start guessing".
There are some more advanced things you can do. For example, I set a variable to count how many guesses it takes. I also set a branch giving the player a tip after that count reaches 5. See the included images for examples.
If you want to make it look like you are doing the hacking on a Rotom, like in our game, You can use the attached image and the Display image event command.
Finally, If you make improvements please share them back to me and I will update this thread with your contribution and credits.
If you don't want to download everything else in the resource pack, you are in the right place.
Paste this script above Main (I put it in the minigames section):
Script:
def print_guesses_from_var(password_var, guess_var)
pbMessage(get_guesses(pbGet(password_var),pbGet(guess_var),4))
end
def get_guesses(password, guess, digits)
password_array = get_digits_array(password, digits)
guess_array = get_digits_array(guess, digits)
value_count = (password_array&guess_array).size
position_count = (0...digits).count{|i| password_array[i]==guess_array[i]}
return "<c3=46D622,101010>#{value_count} correct number(s) included, \n#{position_count} number(s) placed correctly.</c3>"
if Input.trigger?(Input::BACK)
return false
end
end
def get_digits_array(value, digits)
return (0...digits).map{|n| value / (10**n) % 10}
end
In an event:
1. Generate a random number between 0-9999 and assign it to a variable (in this example, 98).
2. Set a jump label "start guessing".
3. Prompt player to input a 4-digit number (it is an event command) and assign it to a variable (in this example, 99).
4. Check if the two variables are equal in an event conditional branch.
5. If they are, tell them they have cracked the code.
6. If aren't, call the script 'print_guesses_from_var(98,99)'. Then jump to the label "start guessing".
There are some more advanced things you can do. For example, I set a variable to count how many guesses it takes. I also set a branch giving the player a tip after that count reaches 5. See the included images for examples.
If you want to make it look like you are doing the hacking on a Rotom, like in our game, You can use the attached image and the Display image event command.
Finally, If you make improvements please share them back to me and I will update this thread with your contribution and credits.
- Credits
- FL
The Plan's Simple