ID:160972
 
How can you make it so in order to do a task in the game.(I.E. Training) you must push the correct arrow keys that show on the screen...if you mess up u stop or fail?
override client/Move()
You program it in.

For example:
var/points = 0
for() // infinite loop, similar to while(1)
var
min = rand(1,10) // You'll see...
max = rand(11,20)
value = input(src,"Type in a number between [min] and [max]!","#") as null|num // 'as num' will make it so you can enter only numbers (including negatives). the 'null' part gives a cancel button - which when clicked, returns null.

if(value && value >= min && value <= max) // the "value" part checks if the value is "true", a non-false value [false values are 0, null and ""]. These values, which only have 'true' and 'false', are called boolean.
src << "Correct!"
points++
else // if value is a false value or if it was out of range
src << "Incorrect!"
break // Breaks the loop
src << "The total points you have collected is [points]!" // this message is outside the loop, so it is displayed when the loop is done
In response to GhostAnime
umm anyway i can do this with arrow keys and so that a pic of the arrow to press pops up?
In response to Zizwa
As Jemai1 said, you can catch what direction the client used through client/Move() (arrow pressed).

1. You have to have some sort of system to keep waiting for an input, which an infinite loop - or at least while()- should be used for.

2. When an input is detected, somehow get your running procedure to recognize the value entered. A variable containing the value pressed would be most useful.

3. When the loop recognizes that a value is entered, check if it is correct. If not, stop. If so, continue on (and maybe give a bonus).

4. After point #3 (after value obtained and checked) and somewhere before point #2 (before the next input wait), reset the recognition variable and randomly pick a direction (pick or even "1<<rand(0,3)" will do so) and reflect the chosen value to the arrow icon (which should be either an /image or a HUD object - set the dir of the arrow icon to the direction to make it easier on yourself).
In response to GhostAnime
An infinite loop would be inappropriate to use.
In response to Jemai1
As you can see, his suggested loop isn't truly infinite (it only loops until an invalid input is given - he did accidentally say more along the lines of "until [any] input is given" in his latest post), though. In his code, you can see that he just moved the condition from instead of in the loop construct, to within the actual code itself (by using break), so the loop isn't infinite throughout the whole game session, it just continues to prompt the player until he gives invalid input and loses.
In response to Kaioken
Let me rephrase that. A loop, infinite or not, that waits for a valid input is inappropriate to use.

Like what I've said, what the OP needs to do is override the client/Move().

Let me make my self clear.
mob
var
training
dir_to_press
verb
Toggle_Training()
training = !training
src << "You [training?"started":"stopped"] training."
if(training) Pressed(null)
proc
Pressed(Dir)
if(Dir && Dir != dir_to_press)
src << "Wrong."
training = FALSE
dir_to_press = null
else
if(Dir)
src << "Correct!"
// exp increase here
// level up check here
dir_to_press = pick(NORTH,SOUTH,EAST,WEST)
switch(dir_to_press)
if(NORTH)
src << "Up"
if(SOUTH)
src << "Down"
if(WEST)
src << "Left"
if(EAST)
src << "Right"

client
Move(Loc,Dir)
if(mob.training)
mob.Pressed(Dir)
else return ..()
In response to Jemai1
Jemai1 wrote:
Let me rephrase that. A loop, infinite or not, that waits for a valid input is inappropriate to use.

Ah, I see, 'cause he wanted the input to be given through the arrow keys. I assumed GhostAnime got the concept right but you were criticizing the code implementation; my mistake.
In response to Kaioken
Kaioken wrote:
Ah, I see, 'cause he wanted the input to be given through the arrow keys. I assumed GhostAnime got the concept right but you were criticizing the code implementation

Exactly.