io.output(south)
local rooms = {}
rooms[1] = {
south=3,
east=2
}
rooms[2] = {
south=4,
west=1
}
rooms[3] = {
north=1,
east=4
}
currentRoom = 1
repeat
local move = io.read("*all")
local room = rooms[currentRoom][move]
if room == nil then
room = currentRoom
print("Invalid move")
elseif room == 4 then
print("Congratulations, you won!")
end
currentRoom = room or currentRoom
until currentRoom == 4
To embed this program on your website, copy the following code and paste it into your website's HTML: