<?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="Collapsing Building" el:subtitle="" el:id="20081018pulley001"/>
      <el:version el:score="1" el:release="1" el:revision="1" el:status="released"/>
      <el:author  el:name="Mark Pulley" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2009 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="true" el:single="true" el:network="false"/>
      <el:score el:easy="2:34" el:difficult="1:21"/>
    </el:info>
    <el:luamain><![CDATA[
wo["MaxOxydColor"] = OXYD_BROWN

ti[" "] = {"fl_blueslab"}
ti["="] = {"st_puzzle_blue", cluster=1}
ti["+"] = {"st_puzzle_blue", cluster=1, hollow=true}
ti["-"] = {"st_puzzle_blue", cluster=2}
if wo ["IsDifficult"] then
    ti["#"] = {"st_greenbrown"}
else
    ti["#"] = ti[" "] .. {"st_oxyd_e", "oxydextra#", target = "oxyd_callback"}
end
ti["L"] = {"st_rotator_cw"}
ti["R"] = {"st_rotator_ccw"}
ti["S"] = {"st_switch", action="callback", target="collapse", safeaction=true}
ti["O"] = {"st_oxyd_e", name="oxydleft#", target="oxyd_callback"}
ti["o"] = {"st_oxyd_e", name="oxydright#", target="oxyd_callback"}
ti["*"] = {"st_oxyd_e", name="oxydend#", target="oxyd_callback"}
ti["@"] = {"#ac_marble_black", 0.5, 0.0}

wo(ti, " ", {
    "--------------------",
    "-*                *-",
    "-        ++        -",
    "-        ++        -",
    "-        ==        -",
    "-        ==        -",
    "-        ==        -",
    "-        ==        -",
    "-        ==        -",
    "-        ==        -",
    "-        ==        -",
    "-*       ==       *-",
    "--------L==R--------",
    "#        ++        #",
    "#=++============++=o",
    "O   +          +   #",
    "#=++============++=o",
    "O   +          +   #",
    "#=++============++=o",
    "O   +          +   #",
    "#=++============++=o",
    "O   +          +   #",
    "#=++============++=o",
    "O   +          +   #",
    "S=++============++=o",
    "O   +          +   S",
    "S=++============++=o",
    "O   +          +   S",
    "S=++============++=o",
    "O   +          +   S",
    "S=++============++=o",
    "O   +          +   S",
    "S=++=====++=====++=o",
    "O @ +          +   S",
    "====================",
    "====================",
    "===================="})

if wo ["IsDifficult"] then
    wo:shuffleOxyd({"oxydleft#*", max=0}, {"oxydright#*", max=0}, {"oxydend#*", min=2})
else
    wo:shuffleOxyd()
end
no["oxyd*"][1]:peepall()

function oxyd_callback(value, sender)
    local name = sender.name
    if sender.state == OXYDPAIR then
        wo[sender] = {"it_seed_greenbrown"}
        wo[last_oxyd] = {"it_seed_greenbrown"}
        it(grp(sender, last_oxyd)):grow()
        if not wo["IsDifficult"] then
            wo:shuffleOxyd()
            no["oxyd*"][1]:peepall()
        end
    elseif sender.state == OPEN then
        last_oxyd = sender
    end
end

function collapse(value, sender)
    st(4, sender.y):kill()
    st(15, sender.y):kill()
    if not wo["IsDifficult"] then
        wo:shuffleOxyd()
        no["oxyd*"][1]:peepall()
    end
    wo[sender] = {"it_seed_greenbrown"}
    it(sender):grow()
end
 ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
