<?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="4 - 8 - 4" el:id="20070821dpl003"/>
      <el:version el:score="3" el:release="3" el:revision="5" el:status="released"/>
      <el:author  el:name="Dominik Leipold"/>
      <el:copyright>Copyright © 2008 Dominik Leipold</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="1.00">
       <el:dependency el:path="lib/libpuzzle_2" el:id="lib/libpuzzle" el:release="2" el:preload="true"/>
      </el:compatibility>
      <el:modes el:easy="true" el:single="true" el:network="false" el:scoreunit="duration" el:scoretarget="time"/>
      <el:comments>
        <el:credits el:showinfo="true" el:showstart="false">
          Thanks to Ronald, Taztunes and Moneymaker for testing and great suggestions.
        </el:credits>
      </el:comments>
      <el:score el:easy="20:25" el:difficult="34:31"/>
    </el:info>
    <el:luamain><![CDATA[
enigma.Brittleness=0
if difficult then
  enigma.SlopeForce=15.0
else
  enigma.SlopeForce=1.0
end

gdoor = 0
gdoorb = 0

function renderLine(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i-1,line)
elseif c == "+" then
 set_stone ("st-plain",i-1,line)
elseif c == "=" then
 set_floor ("fl-normal",i-1,line)
elseif c == "X" then
 set_actor("ac-blackball",i-1,line+0.5,{player=0})
 set_floor ("fl-normal",i-1,line)
elseif c == "O" then
 set_item ("it-extralife",i-1,line)
elseif c == "b" then
 set_floor ("fl-bridge-open",i-1,line,{type="y",name="bridgeB"})
elseif c == "%" then
 set_stone ("st-oneway-n",i-1,line)
 set_floor ("fl-normal",i-1,line)
elseif c == "d" then
 if difficult then
   set_actor ("ac-rotor",i-0.5,line+0.5,{range=2,force=5})
 else
   set_actor ("ac-rotor",i-3.5,line+0.5,{range=2,force=5})
 end
 set_floor ("fl-normal",i-1,line)
elseif c == "*" then
 set_stone ("st-plain_break",i-1,line)
 set_floor ("fl-normal",i-1,line)
elseif c == "f" then
 set_item ("it-puller-n",i-1,line)
 set_floor ("fl-normal",i-1,line)
 set_stone ("st-plain_break",i-1,line)
elseif c == "!" then
 set_stone ("st-black2",i-1,line)
 set_floor ("fl-normal",i-1,line)
elseif c == "x" then
 gdoor = gdoor + 1
 set_stone ("st-door_a",i-1,line,{name="doorG"..tostring(gdoor)})
 set_floor ("fl-normal",i-1,line)
elseif c == "y" then
 gdoorb = gdoorb + 1
 set_stone ("st-door_c",i-1,line,{name="doorGb"..tostring(gdoorb)})
 set_floor ("fl-normal",i-1,line)
elseif c == "z" then
 set_stone ("st-door_c",i-1,line,{name="doorGc"})
 set_floor ("fl-normal",i-1,line)
elseif c == "g" then
 set_actor ("ac-top",i-0.5,line+0.5,{range=10,force=150})
 set_floor ("fl-normal",i-1,line)
 set_item ("it-trigger",i-1,line,{action="openclose",target="doorGc"})
elseif c == "Y" then
 set_item ("it-trigger",i-1,line,{action="callback",target="opencloseGG"})
elseif c == "Z" then
 set_stone ("st-rock3_move",i-1,line)
 set_floor ("fl-normal",i-1,line)
 set_item ("it-coin4",i-1,line,{value=0.1})
elseif c == "t" then
 set_floor ("fl-thief",i-1,line,{friction=4.0,mousefactor=2.0})
elseif c == "T" then
 set_floor ("fl-normal",i-1,line)
 set_item ("it-document",i-1,line,{text="textthief"})
elseif c == "F" then
 set_stone ("st-floppy",i-1,line,{action="callback",target="opencloseJM"})
elseif c == "G" then
 set_stone ("st-switch_black",i-1,line,{action="callback",target="opencloseG"})
elseif c == "j" then
 set_stone ("st-door-h",i-1,line,{name="doorJ"})
 set_floor ("fl-normal",i-1,line)
elseif c == "k" then
 set_stone ("st-bug",i-1,line)
 set_floor ("fl-normal",i-1,line)
 set_item ("it-sensor",i-1,line,{action="open",target="doorK"})
elseif c == "K" then                                                        
 set_stone ("st-door_b",i-1,line,{name="doorK"})
 set_floor ("fl-normal",i-1,line)
elseif c == "m" then
 set_stone ("st-door-v",i-1,line,{name="doorM"})
 set_floor ("fl-normal",i-1,line)
end
end
end

create_world (96,61)
fill_floor ("fl-abyss",0,0,96,61)
oxyd_default_flavor = "d"

if enigma.CreatingPreview then
  set_actor("ac-blackball", 76.6, 17.5)
end

--             012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
renderLine(05,"                   +                                                                            ")
renderLine(06,"                   =                                                                            ")
renderLine(07,"                   +                      O                                                     ")
renderLine(12,"                           +=+                        +=++++++++++++++++j+                 +=+  ")
renderLine(13,"                           +=++++++++++++++++++++++++ +==================+                      ")
renderLine(14,"                           +========================+ +=++++++++++++++++=+                      ")
renderLine(15,"                        +++++++++++++++++++++++++++=+ +=+         +======+                      ")
renderLine(16,"                        ***+                      +=+ +=+++++++++++=++F+++                      ")
renderLine(17,"                        +**+              +++++++++=+ +=============+++++++++                   ")
renderLine(18,"                        +*f+              +=========+ +=+++++++++++=========m                   ")
renderLine(19,"                   ++++++++++++++++++++++++=+++++++++ +=+         +=+++++++++                   ")
renderLine(20,"                   =========================+         +=+         +=+                           ")
renderLine(21,"                   ++++++++=+++++++++++++++++++++++++++=+         +=+                           ")
renderLine(22,"                          +=+===========================+         +=+                           ")
renderLine(23,"                          +=+=+++++++++++++++++++++++++++         +=+                           ")
renderLine(24,"                          +b==+                                   +=+                           ")
renderLine(25,"                          +=+++                                   +=+                           ")
renderLine(26,"                          +=+                                     +=+                           ")
renderLine(27,"                          +=+++++++++++++++++++++++++++++++++++++++=+                           ")
renderLine(28,"                          +=========================================+                           ")
renderLine(29,"                   ++++++++++++++++++++++++++======++++++++++++++++++++++++++                   ")
renderLine(30,"                   =============================X============================                   ")
renderLine(31,"                   ++++++++++++++++++++++++++======++++++++++++++++++++++++++                   ")
renderLine(32,"                                             +====+                                             ")
renderLine(33,"                                              +==+                                              ")
renderLine(34,"                                              +==+                                              ")
renderLine(35,"                                              +==+                                              ")
renderLine(36,"                                          +++++==+++++++++++++++                                ")
renderLine(37,"                                          +====================+                                ")
renderLine(38,"                           +++         ++++=++++++++++++++++++=+                                ")
renderLine(39,"                           + +         +====+                +=++++++++++++++                   ")
renderLine(40,"                   +++++++++%+++++++++++=+++++++++++         +==============k                   ")
renderLine(41,"                   !============d=======!+=========+         +++++=++++++++=+                   ")
renderLine(42,"             O     +++++++++++++++++++++++=========+             +=+      +=+                   ")
renderLine(43,"                                    +=======g======+             +=+      +=+                   ")
renderLine(44,"                        +++++++++++++xxx++++G+++xxx+             +=+      +=+                   ")
renderLine(45,"                        +ttttttttT=================+             +=+      +=+                   ")
renderLine(46,"                        +t++++++++++++++++++++++++!+++++++++++++++=++++++++=+                   ")
renderLine(47,"                        +!+                      +==========================+                   ")
renderLine(48,"     +=+                +z+                      ++++=++++++++++++K++++++++++                   ")
renderLine(52,"                                                                 O                              ")
renderLine(55,"                                                                            +                   ")
renderLine(56,"                                                                            =                   ")
renderLine(57,"                                                                            +                   ")
--             012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
if difficult then
renderLine(42,"                                   y                                                            ")
renderLine(43,"                                +Y+!                                                            ")
renderLine(44,"                                 Z y        +                                                   ")
end

function opencloseJM()
  SendMessage ("doorJ","openclose")
  SendMessage ("doorM","openclose")
end
function opencloseG()
  for i = 1,gdoor do
    SendMessage ("doorG"..tostring(i),"openclose")
  end  
end
function opencloseGG()
  for i = 1,gdoorb do
    SendMessage ("doorGb"..tostring(i),"openclose")
  end
end
opencloseG()

-- -----------------------------------------------------------------------------

function renderLinea(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i,line+1)
elseif c == "+" then
 set_stone ("st-yellow",i,line+1)
elseif c == "1" then
 set_stone ("st-stone_break",i,line+1)
elseif c == "2" then
 set_stone ("st-break_invisible",i,line+1)
elseif c == "3" then
 set_stone ("st-door-v",i,line+1,{name="cdoorA"})
elseif c == "4" then
 set_stone ("st-coinslot",i,line+1,{action="open",target="cdoorA"})
elseif c == "5" then
 set_stone ("st-door-v",i,line+1,{name="kdoorA"})
elseif c == "6" then
 set_stone ("st-key",i,line+1,{keycode=1,action="openclose",target="kdoorA"})
end
end
end

fill_floor ("fl-himalaya",1,1,18,11)
--              012345678901234567
renderLinea(00,"++++++++++++++++++")
renderLinea(01,"+o      + +   +  +")
renderLinea(02,"+  +  +  +  +  + +")
renderLinea(03,"+ +    +   + +   +")
renderLinea(04,"++      + +   + ++")
renderLinea(05,"+        +     +  ")
renderLinea(06,"+       + +   +  +")
renderLinea(07,"+ +    +   + +  ++")
renderLinea(08,"+  +  +  +  +  + +")
renderLinea(09,"+   +   + +     o+")
renderLinea(10,"++++++++++++++++++")
--              012345678901234567
if difficult then
renderLinea(01,"   3        5   o ")
renderLinea(02,"         6        ")
renderLinea(05,"         4        ")
renderLinea(06," 2                ")
renderLinea(09," o            1   ")
end

-- -----------------------------------------------------------------------------

function renderLineb(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i,line+13)
elseif c == "+" then
 set_stone ("st-rock1",i,line+13)
elseif c == "S" then
 set_stone ("st-spitter",i,line+13)
elseif c == "s" then
 set_item ("it-extralife",i,line+13)
elseif c == "a" then
 set_floor ("fl-bridge-open",i,line+13,{type="a",name="bbridge1"})
elseif c == "b" then
 set_floor ("fl-bridge-open",i,line+13,{type="a",name="bbridge2"})
elseif c == "c" then
 set_floor ("fl-bridge-open",i,line+13,{type="a",name="bbridge3"})
elseif c == "d" then
 set_floor ("fl-bridge-open",i,line+13,{type="a",name="bbridge4"})
elseif c == "1" then
 set_item ("it-trigger",i,line+13,{action="openclose",target="bbridge1"})
elseif c == "2" then
 set_item ("it-trigger",i,line+13,{action="openclose",target="bbridge2"})
elseif c == "3" then
 set_item ("it-trigger",i,line+13,{action="openclose",target="bbridge3"})
elseif c == "4" then
 set_item ("it-trigger",i,line+13,{action="openclose",target="bbridge4"})
elseif c == "q" then
 set_stone ("st-puzzle-es",i,line+13)
elseif c == "w" then
 set_stone ("st-puzzle-ew",i,line+13)
elseif c == "e" then
 set_stone ("st-puzzle-sw",i,line+13)
elseif c == "r" then
 set_stone ("st-puzzle-ns",i,line+13)
elseif c == "t" then
 set_stone ("st-puzzle-ne",i,line+13)
elseif c == "z" then
 set_stone ("st-puzzle-nw",i,line+13)
elseif c == "i" then
 set_stone ("st-puzzle-s",i,line+13)
elseif c == "p" then
 set_stone ("st-puzzle-n",i,line+13)
elseif c == "u" then
 set_stone ("st-wood",i,line+13)
elseif c == "*" then
 set_stone ("st-puzzle-hollow",i,line+13)
elseif c == "." then
 set_floor ("fl-abyss",i,line+13)
end
end
end

fill_floor ("fl-rock",1,13,18,11)
if difficult then
--              012345678901234567
renderLineb(-1,"                      d")
renderLineb(00,"++++++++++++++++++     ")
renderLineb(01,"+          r++   +    c")
renderLineb(02,"+    w +++     w*      ")
renderLineb(03,"+      we      sS+   ab")
renderLineb(04,"+++++   r     qss+")
renderLineb(05,"+..1    *     r+++")
renderLineb(06,"+......    +  *  +")
renderLineb(07,"+2...3.+r  +    z ")
renderLineb(08,"+......+tw*+  ++++")
renderLineb(09,"+..4...+u  +     +")
renderLineb(10,"++++++++++++++++++")
--              012345678901234567
else
--              012345678901234567
renderLineb(00,"++++++++++++++++++     ")
renderLineb(01,"+          r++   +    c")
renderLineb(02,"+      +++wz           ")
renderLineb(03,"+      we       ++   ab")
renderLineb(04,"+++++++ r      ss+")
renderLineb(05,"+..1    *     i+++")
renderLineb(06,"+.. . .    +  p  +")
renderLineb(07,"+......+r  +      ")
renderLineb(08,"+2...3.+tw*+  ++++")
renderLineb(09,"+......+u  +     +")
renderLineb(10,"++++++++++++++++++")
--              012345678901234567
end
puzzle({"###"}, {3,15}, "bluepuzzle", "none")
if difficult then
puzzle({"###"}, {4,16}, "bluepuzzle", "none")
else
puzzle({"##"}, {4,16}, "bluepuzzle", "none")
end

-- -----------------------------------------------------------------------------

function renderLinec(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i,line+25)
elseif c == "A" then
 set_stone ("st-bigbrick-es",i,line+25)
elseif c == "B" then
 set_stone ("st-bigbrick-ew",i,line+25)
elseif c == "C" then
 set_stone ("st-bigbrick-sw",i,line+25)
elseif c == "D" then
 set_stone ("st-bigbrick-ns",i,line+25)
elseif c == "E" then
 set_stone ("st-bigbrick-ne",i,line+25)
elseif c == "F" then
 set_stone ("st-bigbrick-nw",i,line+25)
elseif c == "G" then
 set_stone ("st-bigbrick-n",i,line+25)
elseif c == "H" then
 set_stone ("st-bigbrick-s",i,line+25)
elseif c == "i" then
 set_stone ("st-puzzle2-s",i,line+25)
 set_floor ("fl-abyss",i,line+25)
elseif c == "j" then
 set_stone ("st-puzzle2-ns",i,line+25)
 set_item ("it-crack3",i,line+25)
elseif c == "k" then
 set_stone ("st-puzzle2-n",i,line+25)
 set_floor ("fl-abyss",i,line+25)
elseif c == "X" then
 set_stone ("st-switch",i,line+25,{action="openclose",target="bridgeB"})
elseif c == "x" then
 set_item ("it-key",i,line+25,{keycode=6})
elseif c == "d" then
 set_item ("it-document",i,line+25,{text="textc1"})
elseif c == "O" then
 set_floor ("fl-abyss",i,line+25)
elseif c == "Q" then
 set_item ("it-crack3",i,line+25)
end
end
end

fill_floor ("fl-brick",1,25,18,11)
--              012345678901234567
renderLinec(00,"ABBBBBBBBBBBBBBBBC")
if difficult then
renderLinec(01,"D        OOiOOO  D")
renderLinec(02,"D       dOOOOOO  D")
renderLinec(03,"D        QQjQQQ  D")
renderLinec(04,"D       xOOOOOO  G")
renderLinec(05,"DX       OOkOOO   ")
renderLinec(06,"D        OOOOOO  H")
renderLinec(07,"D        QQQOOO  D")
renderLinec(08,"D        OOQOOO  D")
renderLinec(09,"D        OOQQQQ  D")
else
renderLinec(01,"D        OOOOOO  D")
renderLinec(02,"D        OOOOOO  D")
renderLinec(03,"D        OOOOOO  D")
renderLinec(04,"Dd       OOOOOO  G")
renderLinec(05,"DX          OOO   ")
renderLinec(06,"Dx       OO OOO  H")
renderLinec(07,"D        OO      D")
renderLinec(08,"D        OOOOOO  D")
renderLinec(09,"D        OOOOOO  D")
end
renderLinec(10,"EBBBBBBBBBBBBBBBBF")
--              012345678901234567
puzzle({"##"," #","##"}, {2,29}, "redpuzzle", "permutation")
if difficult then
  puzzle({"####  ","  ### ","    # ","   ###","    # ","  ### ","####  "}, {2,27}, "redpuzzle", "permutation",60)
  puzzle({"   +","####","#  +","####","   +"}, {9,26}, "redpuzzle", "permutation",20)
else
  puzzle({"###   ","  ##  ","   #  ","   #  ","   #  ","  ##  ","###   "}, {2,27}, "redpuzzle", "permutation",20)  
end

-- -----------------------------------------------------------------------------

function renderLined(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i,line+37)
elseif c == "+" then
 set_stone ("st-greenbrown",i,line+37)
elseif c == "*" then
 set_stone ("st-rock1",i,line+37)
 set_floor ("fl-water",i,line+37)
elseif c == "!" then
 set_stone ("st-rock1_move",i,line+37)
 if difficult then
   set_item ("it-coin4",i,line+37,{value=0.1})
 end
elseif c == "=" then
 set_floor ("fl-water",i,line+37)
elseif c == "w" then
 set_stone ("st-wood",i,line+37)
elseif c == "O" then
 set_stone ("st-white3",i,line+37)
 set_item ("it-key",i,line+37,{keycode=4})
elseif c == "X" then
 set_stone ("st-key",i,line+37,{keycode=4,action="openclose",target="doorE"})
elseif c == "x" then
 set_stone ("st-door-h",i,line+37,{name="doorE"})
elseif c == "$" then
 if difficult then
   set_item ("it-coin4",i,line+37,{value=0.1})
 end
 set_stone ("st-wood",i,line+37)
elseif c == "d" then
 set_item("it-document",i,line+37,{text="textd1"})
end
end
end

fill_floor ("fl-leaves",1,37,18,11)
--              012345678901234567
renderLined(00,"++++++++++++++++++")
renderLined(01,"+==        *=*===+")
renderLined(02,"+==+ w$+=========+")
renderLined(03,"+=* ww===*== w = +")
renderLined(04,"+=== =**===w$w    ")
renderLined(05,"+=*==*=X*=*+   ==+")
renderLined(06,"+==*============ +")
renderLined(07,"+  w=  ==*=   +  +")
renderLined(08,"+ +  + ======*===+")
renderLined(09,"+       +========+")
renderLined(10,"+++++x++++++++++++")
--              012345678901234567
if difficult then
renderLined(01,"    O    w=       ")
renderLined(05,"              !   ")
else
renderLined(08,"    w             ")
renderLined(05,"      d           ")
renderLined(06,"              *   ")
end

-- -----------------------------------------------------------------------------

function renderLinee(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i,line+49)
elseif c == "+" then
 set_stone ("st-yellow",i,line+49)
elseif c == "1" then
 set_stone ("st-stone_break",i,line+49)
elseif c == "2" then
 set_stone ("st-break_invisible",i,line+49)
elseif c == "3" then
 set_stone ("st-door-h",i,line+49,{name="cdoorE"})
elseif c == "4" then
 set_stone ("st-coinslot",i,line+49,{action="open",target="cdoorE"})
elseif c == "5" then
 set_stone ("st-door-h",i,line+49,{name="kdoorE"})
elseif c == "6" then
 set_stone ("st-key",i,line+49,{keycode=1,action="openclose",target="kdoorE"})
end
end
end

fill_floor ("fl-himalaya",1,49,18,11)
--              012345678901234567
renderLinee(00,"+++++ ++++++++++++")
renderLinee(01,"+      +   +   +o+")
renderLinee(02,"+  + + + + + + + +")
renderLinee(03,"+ +  ++  +   +   +")
renderLinee(04,"+ + + + + + + + ++")
renderLinee(05,"++  ++  ++  ++  ++")
renderLinee(06,"++ + + + + + + + +")
renderLinee(07,"+   +   +  ++  +++")
renderLinee(08,"+ + + + + + + + ++")
renderLinee(09,"+o+   +   +      +")
renderLinee(10,"++++++++++++++++++")
--              012345678901234567
if difficult then
renderLinee(01," o 1              ")
renderLinee(02,"         6      3 ")
renderLinee(08," 2      4    5    ")
renderLinee(09,"                o ")
end

-- -----------------------------------------------------------------------------

function renderLinef(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+19,line+1)
elseif c == "+" then
 set_stone ("st-bumps",i+19,line+1)
elseif c == "X" then
 set_stone ("st-key",i+19,line+1,{keycode=6,action="openclose",target="doorA"})
elseif c == "x" then
 set_stone ("st-door-v",i+19,line+1,{name="doorA"})
elseif c == "Y" then
 set_item ("it-trigger",i+19,line+1,{action="openclose",target="fd"})
elseif c == "y" then
 set_stone ("st-door-v",i+19,line+1,{name="fd"})
elseif c == "h" then
 set_item ("it-hammer",i+19,line+1)
elseif c == "l" then
 set_stone ("st-bolder-w",i+19,line+1)
elseif c == "r" then
 set_stone ("st-bolder-e",i+19,line+1)
elseif c == "a" then
 set_stone ("st-puzzle2-ns",i+19,line+1)
elseif c == "b" then
 set_stone ("st-puzzle2-sw",i+19,line+1)
elseif c == "c" then
 set_stone ("st-puzzle2-ew",i+19,line+1)
end
end
end

fill_floor ("fl-bumps",20,1,18,11)
--              012345678901234567
renderLinef(00,"++++++++++++++++++")
if difficult then
renderLinef(01,"+r         Y    l+")
renderLinef(02,"++ ++++    ++++ ++")
renderLinef(03,"+       cb       +")
renderLinef(04,"++       a       +")
else
renderLinef(01,"+r       Y Y Y  l+")
renderLinef(02,"++ ++++    ++++ ++")
renderLinef(03,"+        b       +")
renderLinef(04,"++      c a      +")
end
renderLinef(05,"x                +")
renderLinef(06,"+                +")
renderLinef(07,"+    +           +")
renderLinef(08,"+++++        +++++")
renderLinef(09,"+X  +        y  h+")
renderLinef(10,"+++ ++++ +++++++++")
if not difficult then
set_floor ("fl-bumps",23,12)
end
--              012345678901234567
puzzle({"#            # ","#            # ","#            ##","+         ### #","#     #+# # # #","# ##+ # # # ###",
  "### # # # #    ","    ### # #    ","        ###    "},{22,2}, "redpuzzle", "none")

-- -----------------------------------------------------------------------------

function renderLineg(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+19,line+49)
elseif c == "+" then
 set_stone ("st-greenbrown",i+19,line+49)
elseif c == "1" then
 set_stone ("st-blocker",i+19,line+49,{name="gb1"})
elseif c == "2" then
 set_stone ("st-blocker",i+19,line+49,{name="gb2"})
elseif c == "c" then
 set_item ("it-crack2",i+19,line+49)
elseif c == "=" then
 set_floor ("fl-water",i+19,line+49)
elseif c == "w" then
 set_stone ("st-white4",i+19,line+49)
elseif c == "y" then
 if difficult then
   set_stone ("st-yinyang3",i+19,line+49)
 else
   set_stone ("st-black4",i+19,line+49)
 end
 set_item ("it-seed",i+19,line+49)
elseif c == "F" then
 set_stone ("st-flash",i+19,line+49)
elseif c == "W" then
 set_actor ("ac-whiteball",i+19.5,line+49.5)
 if difficult then
   set_item ("it-magicwand",i+19,line+49)
 else
   set_item ("it-key",i+19,line+49,{keycode=4})
 end
elseif c == "R" then
 set_item ("it-ring",i+19,line+49)
elseif c == "r" then
 set_item ("it-cross",i+19,line+49)
elseif c == "p" then
 set_item ("it-pencil",i+19,line+49)
elseif c == "d" then
 set_item ("it-document",i+19,line+49,{text="textg1"})
elseif c == "x" then
 set_stone ("st-switch_white",i+19,line+49,{action="callback",target="opengv"})
elseif c == "X" then
 set_item ("it-vortex-closed",i+19,line+49,{name="vortexD",targetx=5.5,targety=38.5})
 set_stone ("st-white4",i+19,line+49)
elseif c == "A" then
 set_floor ("fl-leavese1",i+19,line+49)
elseif c == "B" then
 set_floor ("fl-leavese3",i+19,line+49)
elseif c == "C" then
 set_floor ("fl-leavese2",i+19,line+49)
elseif c == "D" then
 set_floor ("fl-leavese4",i+19,line+49)
end
end
end

fill_floor ("fl-leavesb",20,49,18,11)
--              012345678901234567
renderLineg(00,"+++++ ++++++++++++")
renderLineg(01,"+r    +  +r+ +r  +")
renderLineg(02,"+ F ++++AB + +++ +")
renderLineg(03,"+R d+ + CD++ +   +")
renderLineg(04,"+++++ y +  =w   w+")
renderLineg(05,"+X+   + +++++++y +")
renderLineg(06,"+ + + + w +   + =+")
renderLineg(07,"+= w+ + +   + +x +")
renderLineg(08,"++y++ +++++++ ++2+")
renderLineg(09,"+     1         W+")
renderLineg(10,"++++++++++++++++++")
--              012345678901234567
if difficult then
renderLineg(03,"              p   ")
else
renderLineg(01,"            r     ")
renderLineg(03,"     r            ")
renderLineg(09,"       r          ")
end

function opengb(value,sender)
  SendMessage(enigma.GetNamedObject("gb1"),"open")
  SendMessage(enigma.GetNamedObject("gb2"),"open")
  local x,y=enigma.GetPos(sender)
  enigma.KillItem(x,y)
end

gtset = 0

function opengv()
  if gtset == 0 then 
    set_item ("it-trigger",21,56,{invisible=1,action="callback",target="opengb"})
    gtset = 1
  end
  SendMessage(enigma.GetNamedObject("vortexD"),"openclose")
end

-- -----------------------------------------------------------------------------

function renderLineh(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+38,line+1)
elseif c == "X" then
 set_item ("it-floppy",i+38,line+1)
elseif c == "A" then
 set_stone ("st-bigbluesand-es",i+38,line+1)
elseif c == "B" then
 set_stone ("st-bigbluesand-ew",i+38,line+1)
elseif c == "C" then
 set_stone ("st-bigbluesand-sw",i+38,line+1)
elseif c == "D" then
 set_stone ("st-bigbluesand-ns",i+38,line+1)
elseif c == "E" then
 set_stone ("st-bigbluesand-ne",i+38,line+1)
elseif c == "F" then
 set_stone ("st-bigbluesand-n",i+38,line+1)
elseif c == "G" then
 set_stone ("st-bigbluesand-w",i+38,line+1)
elseif c == "H" then
 set_stone ("st-bigbluesand-e",i+38,line+1)
elseif c == "I" then
 set_stone ("st-bigbluesand-new",i+38,line+1)
elseif c == "J" then
 set_stone ("st-bigbluesand-esw",i+38,line+1)
elseif c == "K" then
 set_stone ("st-bigbluesand-nw",i+38,line+1)
elseif c == "L" then
 set_stone ("st-bigbluesand-s",i+38,line+1)
elseif c == "M" then
 set_stone ("st-blue-sand",i+38,line+1)
elseif c == "N" then
 set_stone ("st-bigbluesand-nsw",i+38,line+1)
elseif c == "1" then
 set_stone ("st-oneway_black-n",i+38,line+1)
elseif c == "0" then
 set_stone ("st-oneway_black-e",i+38,line+1)
elseif c == "2" then
 set_stone ("st-oneway_black-w",i+38,line+1)
elseif c == "q" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd1"})
elseif c == "w" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd2"})
elseif c == "e" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd3"})
elseif c == "r" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd4"})
elseif c == "t" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd5"})
elseif c == "z" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd6"})
elseif c == "i" then
 if difficult then
   set_stone ("st-laserswitch",i+38,line+1,{action="openclose",target="hd7"})
 else
   set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd7"})
 end
elseif c == "a" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd8"})
elseif c == "p" then
 set_stone ("st-floppy",i+38,line+1,{action="openclose",target="hd9"})
elseif c == "d" then
 if difficult then
   set_item ("it-crack3",i+38,line+1)
 else
   set_item ("it-crack2",i+38,line+1)
 end
elseif c == "k" then
 set_stone ("st-laser-e",i+38,line+1,{name="hlas"})
elseif c == "l" then
 set_stone ("st-switch",i+38,line+1,{action="onoff",target="hlas"})
elseif c == "y" then
 set_stone ("st-door-h",i+38,line+1,{name="hd1"})
elseif c == "x" then
 set_stone ("st-door-h",i+38,line+1,{name="hd2"})
elseif c == "c" then
 set_stone ("st-door-v",i+38,line+1,{name="hd3"})
elseif c == "v" then
 set_stone ("st-door-h",i+38,line+1,{name="hd4"})
elseif c == "b" then
 set_stone ("st-door-v",i+38,line+1,{name="hd5"})
elseif c == "n" then
 set_stone ("st-door-v",i+38,line+1,{name="hd6"})
elseif c == "," then
 set_stone ("st-door-v",i+38,line+1,{name="hd7"})
elseif c == "s" then
 set_stone ("st-door-v",i+38,line+1,{name="hd8"})
elseif c == "." then
 set_stone ("st-door-h",i+38,line+1,{name="hd9"})
elseif c == "Y" then
 set_item ("it-key",i+38,line+1,{keycode=10})
elseif c == "Z" then
 set_item ("it-pipe-v",i+38,line+1)
elseif c == "W" then
 set_item ("it-pipe-es",i+38,line+1)
end
end
end

fill_floor ("fl-white",39,1,18,11)
--              012345678901234567
renderLineh(00,"ABBGaHBBBBBBBBBBBC")
renderLineh(01,"D 2s      r   w  D")
renderLineh(02,"D AC   vL c LxHG D")
renderLineh(03,"D EIJ   EBG D    D")
renderLineh(04,"D Z     e   EGyMtD")
renderLineh(05,"D H    iHBB XXXX D")
renderLineh(06,"D      b    qMzL D")
renderLineh(07,"D  HN  L      WD1D")
renderLineh(08,"D   EBBIBBBBBBBKdD")
renderLineh(09,"D   n    Z   ,Y0 D")
renderLineh(10,"EBBBBBBBBBBBBBBG F")
--              012345678901234567
if difficult then
renderLineh(02,"      M           ")
renderLineh(03,"     Gp           ")
renderLineh(04,"    F             ")
renderLineh(05," . Gk      G      ")
renderLineh(06,"    L      l      ")
else
renderLineh(02,"      L           ")
renderLineh(03,"     BK           ")
renderLineh(04,"    D             ")
renderLineh(05,"   BN      C      ")
renderLineh(06,"    D      F      ")
end

-- -----------------------------------------------------------------------------

function renderLinei(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+38,line+49)
elseif c == "+" then
 set_stone ("st-redrock",i+38,line+49)
elseif c == "=" then
 set_floor ("fl-water",i+38,line+49)
elseif c == "e" then
 set_item ("it-document",i+38,line+49,{text="texti1"})
elseif c == "X" then
 set_item ("it-cherry",i+38,line+49)
elseif c == "x" then
 set_stone ("st-bolder",i+38,line+49,{name="bolderx",direction=EAST})
elseif c == "Y" then
 set_item ("it-seed_volcano",i+38,line+49)
elseif c == "d" then
 set_item ("it-document",i+38,line+49,{text="texti2"})
elseif c == "y" then
 set_stone ("st-bolder",i+38,line+49,{name="boldery",direction=NORTH})
 set_floor ("fl-water",i+38,line+49)
elseif c == "Z" then
 set_item ("it-drop",i+38,line+49)
elseif c == "z" then
 set_stone ("st-bolder",i+38,line+49,{name="bolderz",direction=NORTH})
 set_floor ("fl-water",i+38,line+49)
elseif c == "1" then
 set_item ("it-sensor",i+38,line+49,{action="callback",target="ixw"})
 if not difficult then
   set_floor ("fl-samba1",i+38,line+49)
 end
elseif c == "2" then
 set_item ("it-sensor",i+38,line+49,{action="callback",target="ixe"})
 if not difficult then
   set_floor ("fl-samba2",i+38,line+49)
 end
elseif c == "3" then
 set_item ("it-sensor",i+38,line+49,{action="callback",target="iys"})
elseif c == "4" then
 set_item ("it-sensor",i+38,line+49,{action="callback",target="iyn"})
elseif c == "5" then
 set_item ("it-sensor",i+38,line+49,{action="callback",target="izs"})
 if not difficult then
   set_floor ("fl-samba1",i+38,line+49)
 end
elseif c == "6" then
 set_item ("it-sensor",i+38,line+49,{action="callback",target="izn"})
 if not difficult then
   set_floor ("fl-samba2",i+38,line+49)
 end
end
end
end

if difficult then
  for x = 39,56 do
    for y = 49,59 do
      if random (1,10) == 1 then
	    set_floor ("fl-samba",x,y)
	  else
	    set_floor ("fl-sand",x,y)
	  end
    end
  end
else
  fill_floor ("fl-sand",39,49,18,11)
end
--              012345678901234567
if difficult then
renderLinei(00,"++++++++++++++e+++")
renderLinei(01,"+X===   ===1=31 =+")
renderLinei(02,"+    x+  == =53  +")
renderLinei(03,"+4== 1=1==1   ===+")
renderLinei(04,"+===3== ==  = =3=+")
renderLinei(05,"+351  5    ==    +")
renderLinei(06,"+=+=3 == ==2= ==++")
renderLinei(07,"+=y== ==5==5= ==z+")
renderLinei(08,"+d6==     =    ==+")
renderLinei(09,"+Y    == == ==  Z+")
renderLinei(10,"++++++++++++++++++")
else
renderLinei(00,"++++++++++++++e+++")
renderLinei(01,"+X===   ===1= 1 =+")
renderLinei(02,"+    x+ 6== =5   +")
renderLinei(03,"+X== 1=1==1   ===+")
renderLinei(04,"+=== == ==  = = =+")
renderLinei(05,"+  15      ==   2+")
renderLinei(06,"+===  == ==2= ==++")
renderLinei(07,"+=6== == ==5= ==z+")
renderLinei(08,"+  ==     =    ==+")
renderLinei(09,"+=    == == ==  Z+")
renderLinei(10,"++++++++++++++++++")
end
--              012345678901234567

function ixw()
  SendMessage ("bolderx","direction",WEST)
end
function ixe()
  SendMessage ("bolderx","direction",EAST)
end
function iyn()
  SendMessage ("boldery","direction",NORTH)
end
function iys()
  SendMessage ("boldery","direction",SOUTH)
end
function izn()
  SendMessage ("bolderz","direction",NORTH)
end
function izs()
  SendMessage ("bolderz","direction",SOUTH)
end

-- -----------------------------------------------------------------------------

function renderLinej(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+57,line+1)
elseif c == "+" then
 set_stone ("st-stone2",i+57,line+1)
elseif c == "#" then
 set_stone ("st-glass1",i+57,line+1)
 set_item ("it-pipe-v",i+57,line+1)
 set_floor ("fl-space",i+57,line+1)
elseif c == "N" then
 set_stone ("st-mail-n",i+57,line+1)
elseif c == "E" then
 set_stone ("st-mail-e",i+57,line+1)
elseif c == "W" then
 set_stone ("st-mail-w",i+57,line+1)
elseif c == "v" then
 set_item ("it-pipe-v",i+57,line+1)
elseif c == "V" then
 set_item ("it-pipe-v",i+57,line+1)
 set_floor ("fl-space",i+57,line+1)
elseif c == "h" then
 set_item ("it-pipe-h",i+57,line+1)
elseif c == "n" then
 set_item ("it-pipe-n",i+57,line+1)
elseif c == "e" then
 set_item ("it-pipe-e",i+57,line+1)
elseif c == "s" then
 set_item ("it-pipe-s",i+57,line+1)
elseif c == "w" then
 set_item ("it-pipe-w",i+57,line+1)
elseif c == "p" then
 set_item ("it-pipe-es",i+57,line+1)
elseif c == "t" then
 set_item ("it-pipe-ne",i+57,line+1)
elseif c == "q" then
 set_item ("it-pipe-sw",i+57,line+1)
elseif c == "j" then
 set_item ("it-pipe-wn",i+57,line+1)
elseif c == "b" then
 set_item ("it-blackbomb",i+57,line+1)
elseif c == "B" then
 set_item ("it-whitebomb",i+57,line+1)
elseif c == "d" then
 set_item ("it-dynamite",i+57,line+1)
end
end
end

fill_floor ("fl-plank",58,1,18,11)
fill_floor ("fl-space",62,2,13,6)
--              012345678901234567
renderLinej(00,"++++++++++++++++++")
renderLinej(01,"+  Ehqhhhhhhhqtjp+")
renderLinej(02,"+  +v BvB q BvB h+")
renderLinej(03,"+  Ehhhwhhjhqtqhj+")
renderLinej(04,"+ ++p qBp vBn vBv+")
renderLinej(05,"+ t+vBv vBp sBt v+")
renderLinej(06,"+  Ejhthhhvhvjvhq+")
renderLinej(07,"+  +N+N+N+N+N+++V+")
if difficult then
renderLinej(08,"++       v     +V+")
renderLinej(09,"+ddd+    +hhh+ +V+")
else
renderLinej(08,"++  v  v     v +V+")
renderLinej(09,"+ddd+  +hhhhh+ +V+")
end
renderLinej(10,"++++++++++++++ +#+")
--              012345678901234567

-- -----------------------------------------------------------------------------

krand = random (1,12)
kkhole = 0

function renderLinek(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+57,line+49)
elseif c == "+" then
 set_stone ("st-rock8",i+57,line+49)
elseif c == "0" then
 set_stone ("st-disco-dark",i+57,line+49)     
elseif c == "!" then
 set_floor ("fl-abyss",i+57,line+49)
elseif c == "d" then
 set_item ("it-document",i+57,line+49,{text="textk1"})
 set_stone ("st-black3",i+57,line+49)
elseif c == "X" then
 kkhole = kkhole + 1
 if kkhole == krand then
   set_stone ("st-key",i+57,line+49,{keycode=11,action="openclose",target="doorP"})
 else
   set_stone ("st-key",i+57,line+49)
 end
elseif c == "x" then
 set_stone ("st-door-v",i+57,line+49,{name="doorP"})
elseif c == "1" then
 set_stone ("st-door-h",i+57,line+49,{name="kd1"})
 set_item ("it-sensor",i+57,line+49,{action="open",target="kd1"})
 set_floor ("fl-bridge-closed",i+57,line+49,{type="a"})
elseif c == "2" then
 set_stone ("st-door-v",i+57,line+49,{name="kd2"})
 if difficult then
   set_floor ("fl-bridge-open",i+57,line+49,{type="a",name="kbr"})
  else
   set_floor ("fl-bridge-closed",i+57,line+49,{type="a",name="kbr"})
  end
elseif c == "3" then
 set_stone ("st-door-v",i+57,line+49,{name="kd3"})
 set_floor ("fl-bridge-closed",i+57,line+49,{type="a"})
elseif c == "4" then
 set_stone ("st-door-v",i+57,line+49,{name="kd4"})
 set_floor ("fl-bridge-closed",i+57,line+49,{type="a"})
elseif c == "5" then
 set_stone ("st-door-h",i+57,line+49,{name="kd5"})
 set_floor ("fl-bridge-closed",i+57,line+49,{type="a"})
 if difficult then
   set_item ("it-rubberband",i+57,line+49,{target="kh4",length=3,strength=30,minlength=2})
 else
   set_item ("it-rubberband",i+57,line+49,{target="kh4",length=3,strength=30,minlength=1})
 end
elseif c == "6" then
 set_stone ("st-door-v",i+57,line+49,{name="kd6"})
 set_floor ("fl-bridge-closed",i+57,line+49,{type="a"})
elseif c == "7" then
 set_stone ("st-door-v",i+57,line+49,{name="kd7"})
elseif c == "q" then
 set_floor ("fl-abyss",i+57,line+49)
 set_item ("it-trigger",i+57,line+49,{action="openclose",target="kd2"})
elseif c == "w" then
 set_floor ("fl-abyss",i+57,line+49)
 set_item ("it-trigger",i+57,line+49,{action="openclose",target="kd3"})
elseif c == "e" then
 set_floor ("fl-abyss",i+57,line+49)
 set_stone ("st-timeswitch",i+57,line+49,{delay=2.0,action="openclose",target="kd4"})
elseif c == "r" then
 set_floor ("fl-abyss",i+57,line+49)
 set_item ("it-trigger",i+57,line+49,{action="open",target="kd6"})
elseif c == "z" then
 set_item ("it-trigger",i+57,line+49,{action="openclose",target="kbr"})
elseif c == "h" then
 set_actor ("ac-horse",i+57.5,line+49.5,{name="kh1"})
elseif c == "i" then
 set_actor ("ac-horse",i+57.5,line+49.5,{name="kh2"})
elseif c == "j" then
 if difficult then
   set_actor ("ac-horse",i+57.5,line+49.5,{name="kh3",force=7,target1="64 53",target2="66 54",target3="66 53",target4="64 54"})
 else
   set_actor ("ac-horse",i+57.5,line+49.5,{name="kh3",force=4,target1="64 53",target2="66 54",target3="66 53",target4="64 54"})
 end
elseif c == "k" then
 set_actor ("ac-horse",i+57.5,line+49.5,{name="kh4"})
elseif c == "*" then
 set_floor ("fl-abyss",i+57,line+49)
 set_stone ("st-grate3",i+57,line+49)
elseif c == "S" then
 set_floor ("fl-abyss",i+57,line+49)
 set_stone ("st-scissors",i+57,line+49)
elseif c == "$" then
 if difficult then
   set_item ("it-key",i+57,line+49,{keycode=1})
 end
elseif c == "t" then
 set_item ("it-trigger",i+57,line+49,{action="open",target="kd5"})
elseif c == "8" then
 set_item ("it-sensor",i+57,line+49,{action="open",target="kd7"})
end
end
end

fill_floor ("fl-mortar",58,49,18,11)
--              012345678901234567
renderLinek(00,"++++++++ +++++++++")
renderLinek(01,"+       d7     *S+")
renderLinek(02,"+1+++++++++5++++++")
renderLinek(03,"+    2   48  +X X+")
renderLinek(04,"+h  i+j  +   6  X+")
renderLinek(05,"+  ! +   + **+X X+")
renderLinek(06,"+ !q!+!!!+ *r+X X+")
renderLinek(07,"+ !w!+!e!+ *++X  x")
renderLinek(08,"+  ! +!!!+ * +X X+")
renderLinek(09,"+    3  t+ *k+X$X+")
renderLinek(10,"++++++++++++++++++")
--              012345678901234567
if difficult then
renderLinek(06,"    z             ")
end
renderLinek(03," 0000 000 000  0  ")
renderLinek(04," 0000 000 000 00  ")
renderLinek(05," 0000 000 0    0  ")
renderLinek(06," 0000 000 0 0  0  ")
renderLinek(07," 0000 0 0 0    00 ")
renderLinek(08," 0000 000 0 0  0  ")
renderLinek(09," 0000 000 0 0  0  ")
enigma.AddRubberBand (enigma.GetNamedObject("kh1"),enigma.GetNamedObject("kh2"),50,3,1)

-- -----------------------------------------------------------------------------

function renderLinel(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+76,line+1)
elseif c == "+" then
 set_stone ("st-yellow",i+76,line+1)
elseif c == "1" then
 set_stone ("st-stone_break",i+76,line+1)
elseif c == "2" then
 set_stone ("st-break_invisible",i+76,line+1)
elseif c == "3" then
 set_stone ("st-door-h",i+76,line+1,{name="cdoorL"})
elseif c == "4" then
 set_stone ("st-coinslot",i+76,line+1,{action="open",target="cdoorL"})
elseif c == "5" then
 set_stone ("st-door-h",i+76,line+1,{name="kdoorL"})
elseif c == "6" then
 set_stone ("st-key",i+76,line+1,{keycode=1,action="openclose",target="kdoorL"})
end
end
end

fill_floor ("fl-himalaya",77,1,18,11)
--              012345678901234567
renderLinel(00,"++++++++++++++++++")
renderLinel(01,"+   ++ ++++  ++ o+")
renderLinel(02,"+ ++    ++  ++++ +")
renderLinel(03,"+ +++        ++  +")
renderLinel(04,"+ ++    ++      ++")
renderLinel(05,"+      +  +      +")
renderLinel(06,"++      ++     +++")
renderLinel(07,"+++ ++        ++++")
renderLinel(08,"++  +++ ++     +++")
renderLinel(09,"+o  ++ ++++ ++   +")
renderLinel(10,"++++++++++++++* *+")
--              012345678901234567
if difficult then
renderLinel(01," o                ")
renderLinel(02,"                3 ")
renderLinel(03," 5                ")
renderLinel(05,"       6  4       ")
renderLinel(08,"   1              ")
renderLinel(09,"                o ")
end

set_item ("it-trigger",91,11,{invisible=1,action="callback",target="lclose"})
set_item ("it-trigger",93,11,{invisible=1,action="callback",target="lclose"})
function lclose()
  set_stone ("st-yellow",91,11)
  set_stone ("st-yellow",93,11)
end

-- -----------------------------------------------------------------------------

ms = 1
mc = 0

function renderLinem(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+76,line+13)
elseif c == "+" then
 set_stone ("st-wood_001",i+76,line+13)
elseif c == "x" then
 set_stone ("st-door-h",i+76,line+13,{name="doorL"})
elseif c == "k" then
 set_stone ("st-key",i+76,line+13,{keycode=10,action="openclose",target="doorL"})
elseif c == "-" then
 set_floor ("fl-darkgray",i+76,line+13,{friction=4.5})
 set_item ("it-trigger",i+76,line+13,{invisible=1,action="callback",target="mflipper"})
elseif c == "B" then
 set_floor ("fl-black",i+76,line+13,{friction=4.5})
 set_stone ("st-chess_black",i+76,line+13)
 set_item ("it-trigger",i+76,line+13,{invisible=1,action="callback",target="mcatch"})
elseif c == "b" then
 set_stone ("st-chess_black",i+76,line+13)
elseif c == "w" then
 set_stone ("st-chess_white",i+76,line+13)
elseif c == "O" then
 set_stone ("st-timeswitch",i+76,line+13,{delay=0.5,action="callback",target="mflipall"})
elseif c == "X" then
 set_stone ("st-grate1",i+76,line+13)
elseif c == "Y" then
 set_item ("it-brush",i+76,line+13)
elseif c == "~" then
 set_stone ("st-glass1",i+76,line+13)
 set_item ("it-pipe-h",i+76,line+13)
elseif c == "!" then
 set_floor ("fl-abyss",i+76,line+13)
elseif c == "W" then
 set_stone ("st-wood",i+76,line+13)
elseif c == "*" then
 set_stone ("st-wood_001",i+76,line+13)
 set_item ("it-pipe-h",i+76,line+13)
elseif c == "#" then
 set_stone ("st-glass1",i+76,line+13)
 set_item ("it-pipe-sw",i+76,line+13)
elseif c == "." then
 set_item ("it-puller-w",i+76,line+13)
elseif c == "J" then
 set_item ("it-pipe-wn",i+76,line+13)
 set_stone ("st-grate1",i+76,line+13)
elseif c == "P" then
 set_item ("it-pipe-es",i+76,line+13)
 set_stone ("st-grate1",i+76,line+13)
elseif c == "j" then
 set_item ("it-pipe-wn",i+76,line+13)
elseif c == "t" then
 set_item ("it-pipe-ne",i+76,line+13)
elseif c == "v" then
 set_item ("it-pipe-v",i+76,line+13)
end
end
end

for x=77,94 do
  for y=13,23 do
    set_floor ("fl-light",x,y,{friction=4.5})
  end
end
--              012345678901234567
renderLinem(00,"~~*********~#++w++")
renderLinem(01,"+XXOXX+XXXXPJ-+ X+")
renderLinem(02,"+X+++ ++  +v!W+X++")
renderLinem(03,"+X  +X +  +tj++ X+")
renderLinem(04,"+X - - -+- X  w X+")
renderLinem(05,"Xb + w+ + -+ +x+X+")
renderLinem(06,"+X++w + + X++  X++")
if difficult then
renderLinem(07,"+X  ++.w   - +kYX+")
renderLinem(08,"+X -b ++-+X-+  BX+")
renderLinem(09,"+XXXXXX+wXXXXbXXX+")
else
renderLinem(07,"+X  ++.      +k X+")
renderLinem(08,"+X -b ++-+X +  BX+")
renderLinem(09,"+XXXXXX+XXXXXbXXX+")
end
renderLinem(10,"++++++++++++++++++")
--              012345678901234567

function mflipper(value,sender)
  local x,y=enigma.GetPos(sender)
  if(enigma.GetStone(x,y) ~= nil) then
    myst=enigma.GetStone(x,y)
    if(enigma.GetKind(myst) == "st-chess") then
      SendMessage(myst,"flip")
	  enigma.KillItem(x,y)
	  set_floor("fl-light",x,y,{friction=4.5})
    end
  end
end

if difficult then mr = 13 else mr = 14 end

function mflipall()
  ms = 1 - ms
  if ms == 1 then 
    for x=78,93 do
      for y=mr,22 do
        if(enigma.GetStone(x,y) ~= nil) then
          myst=enigma.GetStone(x,y)
          if(enigma.GetKind(myst) == "st-chess") then
            SendMessage(myst,"flip")
          end
        end
      end
    end
  end
end

function mcatch()
  if(enigma.GetStone(92,21) ~= nil) then
    myst=enigma.GetStone(92,21)
    if(enigma.GetKind(myst) == "st-chess") then
      mc = mc + 1
	  if (mc==2) then
	    set_stone ("st-wood_001",92,21)
	  end
    end
  end
end

-- -----------------------------------------------------------------------------

function renderLinen(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+76,line+25)
elseif c == "+" then
 set_stone ("st-metal",i+76,line+25)
elseif c == "x" then
 set_stone ("st-grate1",i+76,line+25)
elseif c == "X" then
set_actor ("ac-bug",i+76.5,line+25.5,{name="bugN"})
elseif c == "8" then
 set_stone ("st-block",i+76,line+25)
elseif c == "Q" then
 set_stone ("st-shogun-s",i+76,line+25)
elseif c == "A" then
 set_item ("it-shogun-s",i+76,line+25,{action="open",target="nd1"})
elseif c == "B" then
 set_item ("it-shogun-s",i+76,line+25,{action="open",target="nd2"})
elseif c == "a" then
 set_stone ("st-door-v",i+76,line+25,{name="nd1"})
elseif c == "b" then
 set_stone ("st-door-h",i+76,line+25,{name="nd2"})
end
end
end

fill_floor ("fl-metal",77,25,18,11)
--              012345678901234567
renderLinen(00,"++++++++++++++++++")
renderLinen(01,"+A     xx  a  +  +")
renderLinen(02,"+ ++++ ++Q+++ +X +")
renderLinen(03,"+ ++++ ++ +++ +b++")
renderLinen(04,"+ 8     +  Q     +")
renderLinen(05,"x x ++ +x x+++++ +")
renderLinen(06,"+ +8++++  x+ 8 8 +")
renderLinen(07,"+x+       + 8 8 8+")
renderLinen(08,"+B  8+++++   8 8 +")
renderLinen(09,"+++ 8x      8 8 ++")
renderLinen(10,"++++++++++++++++++")
--              012345678901234567
if difficult then
renderLinen(06," 8                ")
renderLinen(08,"           8      ")
end

-- -----------------------------------------------------------------------------

ohl = 0
oht = 0
ol1 = 0
ol2 = 0
ol3 = 0
ol4 = 0
omac = 1

function renderLineo(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+76,line+37)
elseif c == "+" then
 set_stone ("st-rock2",i+76,line+37)
elseif c == "!" then
 set_floor ("fl-abyss",i+76,line+37)
elseif c == "0" then
 set_stone ("st-turnstile-green",i+76,line+37)
elseif c == "1" then
 set_stone ("st-turnstile-n",i+76,line+37)
elseif c == "2" then
 set_stone ("st-turnstile-e",i+76,line+37)
elseif c == "3" then
 set_stone ("st-turnstile-s",i+76,line+37)
elseif c == "4" then
 set_stone ("st-turnstile-w",i+76,line+37)
elseif c == "5" then
 set_stone ("st-turnstile",i+76,line+37)
elseif c == "B" then
 set_stone ("st-bug",i+76,line+37)
elseif c == "t" then
 set_stone ("st-door-v-open",i+76,line+37,{name="od1"})
 set_floor ("fl-gradient",i+76,line+37,{type=3})
elseif c == "T" then
 set_item ("it-trigger",i+76,line+37,{action="openclose",target="od1"})
elseif c == "u" then
 set_stone ("st-door-v",i+76,line+37,{name="od2"})
elseif c == "$" then
 set_stone ("st-black3",i+76,line+37)
elseif c == "," then
 set_stone ("st-chargeminus",i+76,line+37)
elseif c == "." then
 set_stone ("st-chargeplus",i+76,line+37)
elseif c == "-" then
 set_stone ("st-chargezero",i+76,line+37)
elseif c == "h" then
 ohl = ohl + 1
 set_item ("it-hollow",i+76,line+37,{name="oh"..tostring(ohl)})
elseif c == "H" then
 oht = oht + 1
 set_item ("it-trigger",i+76,line+37,{action="trigger",target="oh"..tostring(oht)})
elseif c == "m" then
 set_item ("it-magnet",i+76,line+37,{name="om",range=5})
elseif c == "M" then
 set_stone ("st-switch_black",i+76,line+37,{action="onoff",target="om"})
elseif c == "w" then
 set_floor ("fl-gradient",i+76,line+37,{type=2})
elseif c == "a" then
 set_floor ("fl-gradient",i+76,line+37,{type=4})
elseif c == "s" then
 set_floor ("fl-gradient",i+76,line+37,{type=3})
elseif c == "y" then
 set_floor ("fl-gradient",i+76,line+37,{type=1})
elseif c == "W" then
 set_floor ("fl-gradient",i+76,line+37,{type=2})
 set_item ("it-trigger",i+76,line+37,{action="callback",target="olight4"})
elseif c == "A" then
 set_floor ("fl-gradient",i+76,line+37,{type=4})
 set_item ("it-trigger",i+76,line+37,{action="callback",target="olight3"})
elseif c == "S" then
 set_floor ("fl-gradient",i+76,line+37,{type=3})
 set_item ("it-trigger",i+76,line+37,{action="callback",target="olight1"})
elseif c == "Y" then
 set_floor ("fl-gradient",i+76,line+37,{type=1})
 set_item ("it-trigger",i+76,line+37,{action="callback",target="olight2"})
elseif c == "X" then
 set_actor ("ac-bug",i+76.5,line+37.5,{name="bugO"})
 set_floor ("fl-gradient",i+76,line+37,{type=3})
elseif c == "x" then
 set_item ("it-sensor",i+76,line+37,{action="callback",target="orubber"})
 set_floor ("fl-gradient",i+76,line+37,{type=3})
elseif c == "C" then
 set_stone ("st-bug",i+76,line+37)
 set_floor ("fl-gradient",i+76,line+37,{type=3})
elseif c == "L" then
 set_stone ("st-switch_black",i+76,line+37,{on=1,action="callback",target="omachine"})
elseif c == "k" then
 set_item ("it-key",i+76,line+37,{keycode=11})
 set_stone ("st-turnstile-s",i+76,line+37)
end
end
end

fill_floor ("fl-gravel",77,37,18,11)
--              012345678901234567
renderLineo(00,"+,.+++++++++++++++")
renderLineo(01,"+  +   tsCxXhhhhh+")
renderLineo(02,"+  +  0+++++hhhhh+")
renderLineo(03,"   +  3    Lhhhhh+")
renderLineo(04,"+  +++5 402++++ y+")
renderLineo(05,"-     3 BkB    +y+")
renderLineo(06,"+++++++B +$+ +++y+")
renderLineo(07,"+HHHHH+ B$ 1!+sSy+")
renderLineo(08,"+HHHHH+B 5402+W+Y+")
renderLineo(09,"+HHHHHu B3 3!+wAa+")
renderLineo(10,"+++ + ++++++++++++")
--              012345678901234567
if difficult then
renderLineo(01,"     !            ")
renderLineo(02,"     T            ")
renderLineo(03,"           L      ")
renderLineo(04,"               +  ")
renderLineo(05,"             +m   ")
renderLineo(10,"   M +            ")
else
renderLineo(01,"       !          ")
renderLineo(03,"           +      ")
renderLineo(04,"               s  ")
renderLineo(05,"                m ")
renderLineo(10,"   + M            ")
end

function orubber()
  enigma.KillItem (87,38)
  enigma.AddRubberBand (enigma.GetNamedObject("bugN"),enigma.GetNamedObject("bugO"),100,1.5,1)
  SendMessage ("od2","open")
  if not difficult then
    SendMessage ("od1","close")
  end
end

function olight1()
  if ol1 == 0 then
    SendMessage(enigma.GetStone(59,52),"lighten")
  else
	SendMessage(enigma.GetStone(59,52),"darken")
  end
  ol1 = 1 - ol1
end
function olight2()
  if ol2 == 0 then
    SendMessage(enigma.GetStone(64,52),"lighten")
  else
    SendMessage(enigma.GetStone(64,52),"darken")
  end
  ol2 = 1 - ol2
end
function olight3()
  if ol3 == 0 then
    SendMessage(enigma.GetStone(68,52),"lighten")
    SendMessage(enigma.GetStone(70,55),"lighten")
    SendMessage(enigma.GetStone(70,57),"lighten")
  else
    SendMessage(enigma.GetStone(68,52),"darken")
    SendMessage(enigma.GetStone(70,55),"darken")
    SendMessage(enigma.GetStone(70,57),"darken")
  end
  ol3 = 1 - ol3
end
function olight4()
  if ol4 == 0 then
    SendMessage(enigma.GetStone(72,53),"lighten")
  else
    SendMessage(enigma.GetStone(72,53),"darken")
  end
  ol4 = 1 - ol4
end

function omachine()
  if omac == 0 then
    enigma.SlopeForce=15.0
  else
    enigma.SlopeForce=0.0
  end
  omac = 1 - omac
end

-- -----------------------------------------------------------------------------

function renderLinep(line, pattern)
for i=1, strlen(pattern) do
local c = strsub( pattern, i, i)

if c == "o" then
 oxyd(i+76,line+49)
elseif c == "+" then
 set_stone ("st-yellow",i+76,line+49)
elseif c == "1" then
 set_stone ("st-stone_break",i+76,line+49)
elseif c == "2" then
 set_stone ("st-break_invisible",i+76,line+49)
elseif c == "3" then
 set_stone ("st-door-v",i+76,line+49,{name="cdoorP"})
elseif c == "4" then
 set_stone ("st-coinslot",i+76,line+49,{action="open",target="cdoorP"})
elseif c == "5" then
 set_stone ("st-door-h",i+76,line+49,{name="kdoorP"})
elseif c == "6" then
 set_stone ("st-key",i+76,line+49,{keycode=1,action="openclose",target="kdoorP"})
end
end
end

fill_floor ("fl-himalaya",77,49,18,11)
--              012345678901234567
renderLinep(00,"++++++++++++++++++")
renderLinep(01,"+o         +     +")
renderLinep(02,"+  +++++++ + +++++")
renderLinep(03,"+     +    +    ++")
renderLinep(04,"+++++ + +++++++ ++")
renderLinep(05,"+     +    +    ++")
renderLinep(06,"+ ++++++++ + +++++")
renderLinep(07,"      +    +    ++")
renderLinep(08,"+++++ + +++++++ ++")
renderLinep(09,"+     +         o+")
renderLinep(10,"++++++++++++++++++")
--              012345678901234567
if difficult then
renderLinep(01,"                o ")
renderLinep(02,"            5     ")
renderLinep(03,"   2              ")
renderLinep(06,"         4   6    ")
renderLinep(09," o  1         3   ")
end

-- -----------------------------------------------------------------------------

oxyd_shuffle()

]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
      <el:string el:key="textc1">
        <el:english>Start the next explosion at brick 17 (counting from left)!</el:english>
        <el:translation el:lang="de">Die nächste Explosion bei Stein 17 von links starten!</el:translation>
      </el:string>
      <el:string el:key="textd1">
        <el:english>Hint: The white ball's got the key.</el:english>
        <el:translation el:lang="de">Tipp: Die weiße Kugel hat den Schlüssel.</el:translation>
      </el:string>
      <el:string el:key="textg1">
        <el:english>Use of ring only allowed on marked areas.</el:english>
        <el:translation el:lang="de">Benutzung des Rings nur auf markierten Flächen erlaubt.</el:translation>
      </el:string>
      <el:string el:key="texti1">
        <el:english>Take your time ...</el:english>
        <el:translation el:lang="de">Nimm dir Zeit ...</el:translation>
      </el:string>
      <el:string el:key="texti2">
        <el:english>Caution! Don't use for bridge-building!</el:english>
        <el:translation el:lang="de">Vorsicht! Nicht zum Brückenbau verwenden!</el:translation>
      </el:string>
      <el:string el:key="textk1">
        <el:english>Looks pretty dark!</el:english>
        <el:translation el:lang="de">Sieht ja ziemlich düster aus!</el:translation>
      </el:string>
      <el:string el:key="textthief">
        <el:english>Prevent theft! Don't leave valuables in your inventory!</el:english>
        <el:translation el:lang="de">Stopp dem Diebstahl! Lassen Sie keine Wertsachen im Inventar!</el:translation>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
