<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<el:level xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://enigma-game.org/schema/level/1 level.xsd" xmlns:el="http://enigma-game.org/schema/level/1">
  <el:protected>
    <el:info el:type="level">
      <el:identity el:title="Color Maze" el:subtitle="" el:id="pulley16"/>
      <el:version el:score="3" el:release="3" el:revision="10" el:status="released"/>
      <el:author  el:name="Mark Pulley" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2008 Mark Pulley</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="1.10"/>
      <el:modes el:easy="false" el:single="true" el:network="false"/>
      <el:comments>
        <el:credits el:showinfo="true" el:showstart="false">New API translation by Ronald Lamprecht</el:credits>
      </el:comments>      
      <el:score el:easy="-" el:difficult="0:22"/>
    </el:info>
    <el:luamain><![CDATA[
wo["ConserveLevel"] = false
wo["FollowGrid"] = false
wo["FollowMethod"] = FOLLOW_SCROLL

ti[" "] = {"fl_fake_abyss"} .. ti({"st_lightglass"})

ti["!"] = {"fl_blueslab", "blue#", _color="blue"}
ti["@"] = {"fl_pinkbumps", "orange#", _color="orange"}
ti["#"] = {"fl_redslab", "red#", _color="red"}
ti["$"] = {"fl_lawn_b", "green#", _color="green"}

ti["b"] = ti["!"] .. {"st_door", flavor="d", faces="ns", state=OPEN}
ti["B"] = ti["!"] .. {"st_door", flavor="d", faces="ew", state=OPEN}
ti["o"] = ti["@"] .. {"st_door", flavor="d", faces="ns", state=OPEN}
ti["O"] = ti["@"] .. {"st_door", flavor="d", faces="ew", state=OPEN}
ti["r"] = ti["#"] .. {"st_door", flavor="d", faces="ns", state=OPEN}
ti["R"] = ti["#"] .. {"st_door", flavor="d", faces="ew", state=OPEN}
ti["g"] = ti["$"] .. {"st_door", flavor="d", faces="ns", state=OPEN}
ti["G"] = ti["$"] .. {"st_door", flavor="d", faces="ew", state=OPEN}

ti["d"] = {"it_document", text="text1"}
ti["5"] = ti["b"] .. ti["d"]
ti["6"] = ti["O"] .. ti["d"]
ti["7"] = ti["r"] .. ti["d"]
ti["8"] = ti["G"] .. ti["d"]

ti["x"] = {"it_sensor", invisible=true, target="gates"}
ti["*"] = ti["x"] .. {"#ac_marble_black", "me"}

ti["?"] = {"st_oxyd_a"}

wo(ti, " ", {
--      |         1    1   |2    2
--      |1   5    0    5   |0    5
       "                           ",
       " xO@OxR#RxO@OxB!BxR#RxB!Bx ", --01
       " b   r   g   g   b   g   r ", 
       " !   #   $   $   !   $   # ", 
       " b   r   g   g   b   g   r ", 
       " xR#RxB!BxO@OxG$GxO@OxO@Ox ", --05
       " g   g   r   g   g   b   b ", 
       " $   $   #   $   $   !   ! ", 
       " g   g   r   g   g   b   b ", 
       " xR#RxO@OxG$GxR#RxG$GxR#Rx ", 
       " g   b   b   o       b   r ", --10
       " $   !   !   @       !   # ", 
       " g   b   5   o   ?   b   r ", --
       " xO@OxO@6*8$Gx   xG$GxR#Rx ", 
       " r   b   7   b   ?   o   o ", 
       " #   !   #   !       @   @ ", --15
       " r   b   r   b       o   o ", 
       " xG$GxB!BxR#RxO@OxR#RxG$Gx ", 
       " g   o   o   g   g   o   b ", 
       " $   @   @   $   $   @   ! ", 
       " g   o   o   g   g   o   b ", --20
       " xB!BxO@OxR#RxR#RxO@OxB!Bx ", 
       " o   r   g   g   b   b   g ", 
       " @   #   $   $   !   !   $ ", 
       " o   r   g   g   b   b   g ", --
       " xR#RxB!BxB!BxR#RxO@OxR#Rx ", --25
       "                           "} -- 
--      |         1    1   |2    2
--      |1   5    0    5   |0    5
)

last = it(no["me"])   -- the position of the last visited sensor
move = 0              -- the count of link moves
sequence = {}         -- the sequence of the 4 colors that the user did choose

function gates(value, sender)
    if (last - sender) ~= po(0,0) then
        local middle = last + (sender - last)/2
        local color = fl(middle)["_color"]
        if color == nil then return end  -- someone cheated, avoid throwing an exception
        st(no[color.."#*"]):close()
        sequence[move%4] = color
        if sequence[(move+1)%4] ~= nil then
            st(no[sequence[(move+1)%4].."#*"]):open()
        end
        move = move + 1
        last = sender
    end
end
    ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
      <el:string el:key="text1">
        <el:english el:translate="true">This is a color maze. You have to work out what order you need to traverse the colored floors in order to reach the oxyds.</el:english>
      </el:string> 
    </el:i18n>
  </el:protected>
</el:level>
