<?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="Welcome to the Machine" el:subtitle="" el:id="ralf03"/>
      <el:version el:score="2" el:release="3" el:revision="3" el:status="released"/>
      <el:author el:name="Ralf Westram" el:email="amgine@reallysoft.de" el:homepage=""/>
      <el:copyright>Copyright © 2003 Ralf Westram</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="1.10">
        <el:dependency el:path="lib/libmap" el:id="lib/libmap" el:release="1 " el:preload="true"/>
      </el:compatibility>
      <el:modes el:easy="false" el:single="true" el:network="false"/>
      <el:score el:easy="-" el:difficult="-"/>
    </el:info>
    <el:luamain><![CDATA[
wo["FollowGrid"] = false
wo["FollowMethod"] = FOLLOW_SCROLL

ti[" "] = {"fl_sahara"}
ti["-"] = {"fl_tigris"}
ti["="] = {"fl_bluegray"}
ti["#"] = {"st_tigris"}
ti["A"] = {"st_granite"}
ti["B"] = {"st_purplegray"}
ti["C"] = {"st_metal"}
ti["D"] = {"st_plaster"}
ti["."] = {"st_nil"}
ti["S"] = {"st_switch", target="rotate", instant=true, safeaction=true}
ti["1"] = {"st_oxyd", flavor="a", name="center1#", _kind=1}
ti["2"] = {"st_oxyd", flavor="a", name="center2#", _kind=2}
ti["3"] = {"st_oxyd", flavor="a", name="center3#", _kind=3}
ti["4"] = {"st_oxyd", flavor="a", name="center4#", _kind=4}
ti["d"] = {"it_document", text="text1"}
ti["e"] = {"it_document", text="text2"}
ti["@"] = {"ac_marble_black"}

wo(ti, " ", {
    "##############################",
    "#  ---    ---    ---    ---  #",
    "# -----  -----  -----  ----- #",
    "#---=------=------=------=---#",
    "#--=2=----=4=----=1=----=3=--#",
    "#---=------=------=------=---#",
    "# -----  -----  -----  ----- #",
    "#  ---    ---    ---    --- d#",
    "#  ---    ---    ---    ---  #",
    "# -----  -----  -----  ----- #",
    "#---=------=------=------=---#",
    "#--=4=----=3=----=2=----=4=--#",
    "#---=------=------=------=---#",
    "# -----  -----  -----  ----- #",
    "#e ---    ---    ---    ---  #",
    "#  ---    ---  @ ---    ---  #",
    "# -----  -----  -----  ----- #",
    "#---=------=------=------=---#",
    "#--=3=----=1=----=1=----=2=--#",
    "#---=------=------=------=---#",
    "# -----  -----  -----  ----- #",
    "#  ---    ---    ---    ---  #",
    "##############################"})

local rotation = {MAP_IDENT, MAP_ROT_CW, MAP_ROT_180, MAP_ROT_CCW}
local direction = {MAP_ROT_CW, MAP_ROT_CCW, MAP_ROT_CW, MAP_ROT_CCW}

local part1 = {"    A  ", " SAAAA ", "AA   AA", "     A ", "AA   A ", " AA AA ", "  A A  "}
local part2 = {"    B  ", " SBBBB ", " B   BB", "     B ", "BB   B ", " BB BB ", "  B B  "}
local part3 = {"    C  ", " SCCCC ", "CC   CC", "     C ", "CC   C ", " CC CC ", "  C C  "}
local part4 = {"    D  ", " SDDDD ", "DD   DD", "     D ", "DD   D ", " DD DD ", "  D D  "}
local part5 = {"    .  ", " ..... ", "..   ..", "     . ", "..   . ", " .. .. ", "  . .  "}

local parts = {wo:newMap(" ", part1), wo:newMap(" ", part2), wo:newMap(" ", part3), wo:newMap(" ", part4), wo:newMap(" ", part5)}

function rotate(value, sender)
    local centerstone = no["center?#*"]:nearest(sender)
    local kind = centerstone["_kind"]
    local similarcenters = st(no["center"..kind.."#*"])
    local old_rotation = rotation[kind]
    rotation[kind] = rotation[kind]^direction[kind]
    for center in similarcenters do
        wo:drawMap(ti, po(center)-po(3, 3), parts[5]^old_rotation)
        wo:drawMap(ti, po(center)-po(3, 3), parts[kind]^rotation[kind])
    end
end

-- init:
local centers = no["center?#*"]
for center in centers do
    wo:drawMap(ti, po(center)-po(3, 3), parts[center["_kind"]]^rotation[center["_kind"]])
end

wo:shuffleOxyd()
 ]]></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">Sections which have the same color always turn at the same time and in the same way.</el:english>
      </el:string>
      <el:string el:key="text2">
        <el:english el:translate="true">Maintenance code: metal-stone-stone-stone-red-yellow-yellow-red-red-stone-stone.</el:english>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
