<?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="Horseshoes" el:subtitle="" el:id="duffy163"/>
      <el:version el:score="1" el:release="1" el:revision="0" el:status="released"/>
      <el:author  el:name="Jacob Scott" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2007 Jacob Scott</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="0.92">
      </el:compatibility>
      <el:modes el:easy="false" el:single="true" el:network="false"/>
      <el:score el:easy="-" el:difficult="-"/>
    </el:info>
    <el:luamain><![CDATA[
rooms_wide=3
rooms_high=3

levelw=1+(19*rooms_wide)
levelh=1+(12*rooms_high)

create_world( levelw, levelh)
display.SetFollowMode(display.FOLLOW_SCROLLING)

fill_floor("fl-abyss",0,0,levelw,levelh)

function renderLine( line, pattern)
    for i=1, strlen(pattern) do
        local c = strsub( pattern, i, i)
        if c =="#" then
            set_stone( "st-death", i-1, line)
            abyss(i-1,line)
        elseif c =="*" then
            set_stone( "st-greenbrown", i-1, line)
            abyss(i-1,line)
        elseif c == "!" then
            abyss(i-1,line)
        elseif c == "o" then
            oxyd( i-1, line)
        elseif c=="z" then
            set_actor("ac-blackball", i,line+.5, {player=0, mouseforce=1})
            set_floor("fl-hay",i-1,line)
        elseif c == "@" then
            set_stone( "st-brownie", i-1, line)
        elseif c == "!" then
            abyss(i-1,line)
        elseif c == "~" then
            fill_floor("fl-water", i-1,line, 1,1)
        elseif c=="z" then
            set_actor("ac-blackball", i-.5,line+.5, {player=0})
            set_floor("fl-hay",i-1,line)
        elseif c == "S" then
            set_item("it-spring1",i-1,line)
            set_floor("fl-hay",i-1,line)
        elseif c == "s" then
            set_item("it-spring2",i-1,line)
            set_floor("fl-hay",i-1,line)
        elseif c=="+" then
            set_stone( "st-wood", i-1, line)
        elseif c=="." then
            set_floor("fl-hay",i-1,line)
        elseif c=="=" then
            set_floor("fl-space",i-1,line)
        elseif c=="L" then
            oneway(i-1,line, enigma.WEST)
            set_floor("fl-hay",i-1,line)
        elseif c=="U" then
            oneway(i-1,line, enigma.NORTH)
            set_floor("fl-hay",i-1,line)
        elseif c=="R" then
            oneway(i-1,line, enigma.EAST)
            set_floor("fl-hay",i-1,line)
        elseif c=="D" then
            oneway(i-1,line, enigma.SOUTH)
        elseif c=="W" then
            oneway(i-1,line, enigma.WEST)
            set_floor("fl-space",i-1,line)
        elseif c=="M" then
            set_item("it-magnet",i-1,line,{name="magnet"})
            magnet=enigma.GetNamedObject("magnet")
            enigma.SendMessage(magnet,"on",nil)
        elseif c=="N" then
            set_item("it-magnet",i-1,line,{name="magnet2"})
            set_floor("fl-space",i-1,line)
        elseif c=="P" then
            set_item("it-magnet",i-1,line,{name="magnet3"})
        elseif c=="Q" then
            set_item("it-magnet",i-1,line,{name="magnet4"})
        elseif c=="n" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc5"})
        elseif c=="p" then
            set_stone("st-switch", i-1,line, {action="onoff",target="magnet3"})
        elseif c=="q" then
            set_stone("st-switch", i-1,line, {action="onoff",target="magnet4"})
        elseif c=="r" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc1"})
        elseif c=="l" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc6"})
        elseif c=="u" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc2"})
        elseif c=="v" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc3"})
        elseif c=="w" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc4"})
        elseif c=="y" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc7"})
        elseif c=="x" then
            set_stone("st-switch", i-1,line, {action="callback",target="funcc8"})
        elseif c=="1" then
            set_item("it-magnet",i-1,line,{name="magnetx1"})
        elseif c=="2" then
            set_item("it-magnet",i-1,line,{name="magnetx2"})
        elseif c=="3" then
            set_item("it-magnet",i-1,line,{name="magnetx3"})
        elseif c=="4" then
            set_item("it-magnet",i-1,line,{name="magnetx4"})
        elseif c=="5" then
            set_item("it-magnet",i-1,line,{name="magnetx5"})
        elseif c=="6" then
            set_item("it-magnet",i-1,line,{name="magnetx6"})
        elseif c=="7" then
            set_item("it-magnet",i-1,line,{name="magnetx7"})
        elseif c=="8" then
            set_item("it-magnet",i-1,line,{name="magnetx8"})
        elseif c=="9" then
            set_item("it-magnet",i-1,line,{name="magnetx9"})
        elseif c=="0" then
            set_item("it-magnet",i-1,line,{name="magnetx0"})
        elseif c=="J" then
            set_item("it-extralife",i-1,line)
            set_floor("fl-hay",i-1,line)
        elseif c=="B" then
            set_floor("fl-bridge", i-1,line, {name="bridge1", type="yy"})
        end
    end
end

-- Floor:  " "
-- Border: "#"
-- Oxyd:   "o"

renderLine(00,"######***##****###*****####****###***####*******##########")
renderLine(01,"# .....=....==.....===......==.....=....J*vJ.....        #")
renderLine(02,"# . ***D****DD*****DDD******DD*****D****.*******........ #")
renderLine(03,"# . *......    ...s......===..L...     n.#      B      . #")
renderLine(04,"# . *.J.***                    ...     *.# ........... . #")
renderLine(05,"# . *...*    ############      === *****.# ...1....... . #")
renderLine(06,"# . * .   M         #p..#==========W==...# ..!....2.!. . #")
renderLine(07,"# M   ..    .....   #q..#==========WN=...# .....3..... . #")
renderLine(08,"# .    .. ...   .   #####      === #     # .4.......5. . #")
renderLine(09,"# .     ...     .              === ####### .....!..... = #")
renderLine(10,"# .             .              ... #       ...6...7... . #")
renderLine(11,"# ..==.J       ... r***        ... # ===.v !.......... . #")
renderLine(12,"# ..  .  .............*         .  # ===.. .....!!...! . #")
renderLine(13,"#     .  .     ... **.*         . ## ===.. ..8........ = #")
renderLine(14,"# ..  .  .      =   *.*   M     . #  ===.. ..........9 . #")
renderLine(15,"# ..==.. .      =   *.*         . #  =   . 0!...!....! . #")
renderLine(16,"# =   ..R.     ==   *.*  ****** . #  .   .   .......   . #")
renderLine(17,"# =   w  .     ==   *.****....* . *  . o...o .......   = #")
renderLine(18,"# .      .    ===   *....R.z......L...*******.......   . #")
renderLine(19,"# .     ... M ===   ******....*   *  ............     l. #")
renderLine(20,"# .     ...   ===        **U***   *  y                 . #")
renderLine(21,"# ..... ...  ====         *.* ************************x. #")
renderLine(22,"#   ...      ..           *.*    .............L......... #")
renderLine(23,"#   ...      ..           *.*    .*********************. #")
renderLine(24,"#   ===      ..           *.*    .* M   M              = #")
renderLine(25,"#    ===     ..            .     .                     . #")
renderLine(26,"#    ===     ..======    u...   ...=========...        . #")
renderLine(27,"#     ===    ..=======    .J.......=========.......... . #")
renderLine(28,"#     ===    .    ======  ...   ...=========...      . . #")
renderLine(29,"#      ==    .     =====   .                         . . #")
renderLine(30,"#      =...  .  P    ====  .          M   M          . . #")
renderLine(31,"# ....  ...  .        ===  .    * * * * * * *        . . #")
renderLine(32,"# .  ......  .    Q   ===  . ......................... . #")
renderLine(33,"# .          .        ...... . *****************       . #")
renderLine(34,"# ...=..=..=..        ...... ....s     ................J #")
renderLine(35,"#                             * * * * * * *              #")
renderLine(36,"##########################################################")

oxyd_shuffle()

set_floor("fl-hay",2,7)

magnet2 = enigma.GetNamedObject("magnet2")

function funcc1()
    oneway(25,18, enigma.WEST)
end

function funcc2()
    oneway(27,20, enigma.SOUTH)
end

enigma.SendMessage(magnet2,"on",nil)

magnetx1=enigma.GetNamedObject("magnetx1")
magnetx2=enigma.GetNamedObject("magnetx2")
magnetx3=enigma.GetNamedObject("magnetx3")
magnetx4=enigma.GetNamedObject("magnetx4")
magnetx5=enigma.GetNamedObject("magnetx5")
magnetx6=enigma.GetNamedObject("magnetx6")
magnetx7=enigma.GetNamedObject("magnetx7")
magnetx8=enigma.GetNamedObject("magnetx8")
magnetx9=enigma.GetNamedObject("magnetx9")
magnetx0=enigma.GetNamedObject("magnetx0")

bridge1=enigma.GetNamedObject("bridge1")

function funcc3()
    enigma.SendMessage(magnetx1,"onoff",nil)
    enigma.SendMessage(magnetx2,"onoff",nil)
    enigma.SendMessage(magnetx3,"onoff",nil)
    enigma.SendMessage(magnetx4,"onoff",nil)
    enigma.SendMessage(magnetx5,"onoff",nil)
    enigma.SendMessage(magnetx6,"onoff",nil)
    enigma.SendMessage(magnetx7,"onoff",nil)
    enigma.SendMessage(magnetx8,"onoff",nil)
    enigma.SendMessage(magnetx9,"onoff",nil)
    enigma.SendMessage(magnetx0,"onoff",nil)
    enigma.SendMessage(bridge1,"openclose",nil)
end

function funcc4()
    oneway(8,16, enigma.WEST)
end

function funcc5()
    enigma.SendMessage(magnet2,"onoff",nil)
    set_stone("st-greenbrown",23,5)
    set_stone("st-greenbrown",24,5)
    set_stone("st-greenbrown",23,8)
    set_stone("st-greenbrown",24,8)
    set_stone("st-greenbrown",25,8)
    set_stone("st-greenbrown",26,8)
    set_stone("st-greenbrown",27,8)
    set_stone("st-greenbrown",28,8)
    set_stone("st-greenbrown",29,8)
    set_stone("st-greenbrown",30,8)
    set_stone("st-greenbrown",34,8)
    set_stone("st-greenbrown",35,8)
    set_stone("st-greenbrown",36,8)
    set_stone("st-greenbrown",37,8)
    enigma.KillStone(24,6)
    enigma.KillStone(24,7)
    set_floor("fl-hay",24,6)
    set_floor("fl-hay",24,7)
    set_floor("fl-hay",15,22)
    set_floor("fl-hay",15,23)
end

function funcc6()
    oneway(46,22, enigma.EAST)
end

function funcc7()
    oneway(34,18, enigma.EAST)
end

function funcc8()
    enigma.SendMessage(magnetx1,"off",nil)
    enigma.SendMessage(magnetx2,"off",nil)
    enigma.SendMessage(magnetx3,"off",nil)
    enigma.SendMessage(magnetx4,"off",nil)
    enigma.SendMessage(magnetx5,"off",nil)
    enigma.SendMessage(magnetx6,"off",nil)
    enigma.SendMessage(magnetx7,"off",nil)
    enigma.SendMessage(magnetx8,"off",nil)
    enigma.SendMessage(magnetx9,"off",nil)
    enigma.SendMessage(magnetx0,"off",nil)
    enigma.SendMessage(bridge1,"open",nil)
end
    ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>

