-
Notifications
You must be signed in to change notification settings - Fork 2
Functions
ProgCraft programs are written in vanilla Ruby so most features are available. Ruby documentation
Call : walk_forward()
Effect : Move Robert one square in front of him
Input : any
Return : any
# Example : Move Robert by 4 squares
walk_forward()
walk_forward()
walk_forward()
walk_forward()Call : turn_right()
Effect : Rotate Robert to his right
Input : any
Return : any
# Example : Turn around
turn_right()
turn_right()Call : turn_left()
Effect : Rotate Robert to his left
Input : any
Return : any
# Example : Turn around
turn_left()
turn_left()Call : gps_x()
Effect : any
Input : any
Return : Robert's x position in integer
# Example : Say Robert's position
posx = gps_x()
say("Robert x position is : #{posx}")Call : gps_y()
Effect : any
Input : any
Return : Robert's y position in integer
# Example : Say Robert's position
posy = gps_y()
say("Robert x position is : #{posy}")Call : is_clear_path()
Effect : any
Input : any
Return : true if the square in front of Robert can be crossed, otherwise returns false
# Example : Move forward while path in front is clear
while(is_clear_path() == true)
walk_forward()
endCall : is_clear_right()
Effect : any
Input : any
Return : true if the square in right of Robert can be crossed, otherwise returns false
# Example : Turn right if path is clear
if(is_clear_right() == true)
turn_right()
endCall : is_clear_left()
Effect : any
Input : any
Return : true if the square in right of Robert can be crossed, otherwise returns false
# Example : Turn left if path is clear
if(is_clear_left() == true)
turn_left()
endCall : compass()
Effect : any
Input : any
Return : Robert's direction. Possible values are north, south, west or east
# Example : Say Robert direction
say("Robert look at #{compass()}")Call : ask(String)
Effect : Robert ask a text to user by WhatsArbre
Input : String
Return : any
# Example : Robert ask and say your name
firstname = ask("What is your name ?")
say("Hello #{firstname}")Call : ask_number(String)
Effect : Robert ask a number to user by WhatsArbre
Input : String
Return : any
# Example : Robert ask how many step do you want that he does
step = ask_number("How many step do you want ?")
while(step >= 0)
walk_forward()
step -= 1
endCall : say(String)
Effect : Robert say something by WhatsArbre
Input : any
Return : String
# Example : Robert greets you
firstname = ask("What is your name ?")
say("Hello #{firstname}")Call : detection()
Effect : Return what is under Robert
Input : any
Return : String name of object
# Example : Take if Robert is on an apple
if(detection() == "Apple")
take()
endCall : take()
Effect : Robert takes the object under him if there is one
Input : any
Return : any
# Example : Take if Robert is on an apple
if(detection == "Apple")
take()
endCall : drop()
Effect : Robert drops the last object added to his inventory
Input : any
Return : any
# Example : Drop a number of items asked by player
count = ask_number(`How many object do you want drop ?`)
while(step >= 0)
drop()
walk_forward()
end