<?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="The Flagstone Reaper" el:subtitle="" el:id="andreas09"/>
      <el:version el:score="1" el:release="2" el:revision="5" el:status="released"/>
      <el:author  el:name="Andreas Lochmann" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2005, 2009 Andreas Lochmann</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="1.10">
      </el:compatibility>
      <el:modes el:easy="true" el:single="true" el:network="false"/>
      <el:comments>
      </el:comments>
      <el:score el:easy="01:08" el:difficult="01:06"/>
    </el:info>
    <el:luamain><![CDATA[

clock_to_delta_pos = { [NORTH] = po(0, -1),
                       [EAST] = po(1, 0),
                       [SOUTH] = po(0, 1),
                       [WEST] = po(-1, 0) }
  
ti["~"] = {"fl_abyss"}
ti["_"] = {"fl_bast",     _floor = "~"}
ti["1"] = {"fl_sahara",   _floor = "_", _item = "it_magicwand"}
ti["2"] = {"fl_red",      _floor = "_", _item = "it_umbrella"}
ti["3"] = {"fl_bluegray", _floor = "_", _item = "it_sword"}
ti["4"] = {"fl_tigris",   _floor = "_", _item = "it_hammer"}
ti["5"] = {"fl_gray",     _floor = "_", _item = "it-pin"}      
ti["#"] = {"st_purplegray"}
ti["O"] = {"st_oxyd", flavor = "a", oxydcolor = OXYD_WHITE}
ti["@"] = {"#ac_marble", adhesion = 1}
ti["d"] = {"it_document", text = "text1"}
ti["T"] = {"st_timer", "timer", target = "callback_timer", interval = 0.8}
ti["C"] = {"st_fourswitch", "clock"}
ti["L"] = {"st_laser_s", "laser#"}
ti["S"] = {"st_switch", target = "laser#*"}
ti["G"] = {"st_passage_black", flavor = "frame"}
ti["B"] = {"st_break_black"}
ti["M"] = {"st_magic_brick"}
ti["K"] = {"st_knight"}

w, h = wo(res.random(ti, " ", {"1", "2", "3", "4", "5"}), " ", 
       {"T################LL#",
        "#C              Gd~S",
        "#               #BM#",
        "#               #KB#",
        "#               #BM#",
        "#               #KB#",
        "#               #BM#",
        "#               #KB#",
        "#               #BM#",
        "#   @           #KB#",
        "#               #BM#",
        "#               #OO#",
        "####################"})

wo:shuffleOxyd()

function callback_timer()
  if no["clock"]:exists() then
    local clock_state = no["clock"].state
    local old_pos = po(no["clock"])
    local clock_pos = old_pos + clock_to_delta_pos[clock_state]
    if clock_pos.x > 19 then  clock_pos.x = 19  end
    if clock_pos.x <  0 then  clock_pos.x =  0  end
    if clock_pos.y > 12 then  clock_pos.y = 12  end
    if clock_pos.y <  0 then  clock_pos.y =  0  end
    -- Change item (if existent)
    if fl(old_pos)._item and it(old_pos):exists() then
      wo[old_pos] = {fl(old_pos)._item}
    end
    -- Change floor
    if fl(old_pos)._floor then
      wo[old_pos] = ti[fl(old_pos)._floor]
    end
    -- Change direction (yes, prior to move)
    if wo["IsDifficult"] and (random(1,4) == 1) then
      if (clock_state == NORTH) or (clock_state == SOUTH) then
        clock_state = ({EAST, WEST})[random(2)]
      else
        clock_state = ({NORTH, SOUTH})[random(2)]
      end
    end
    -- Move stone
    if not st(clock_pos):exists() then
      wo[old_pos] = {"st_nil"}
      wo[clock_pos] = ti["C"]
    end
    -- Adapt direction
    no["clock"].state = clock_state
  end
end

    ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="true"/>
        <el:translation el:lang="de">Der Fliesen-Mäher</el:translation>
      </el:string>
      <el:string el:key="text1">
        <el:english el:translate="true" el:comment="Difficult to translate. If you have no idea, just say: Why on this side does this message sit? The Reaper has a use for it">No hint today ...    Those flagstones pass away ...    The docu stands alone ...    Why is it so alone?    --    This hint today ...    Why is it on this side ...    The reaper passing by ...    Could know the reason why!     (orig. by Herman's Hermits)   </el:english>
        <el:translation el:lang="de">Warum ist der Hinweis auf dieser Seite?        Sollte der Mäher das vielleicht wissen?</el:translation>
      </el:string> 
    </el:i18n>
  </el:protected>
</el:level>
