<?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="Magic Trinity" el:subtitle="" el:id="duffy146" />
      <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:modes el:easy="false" el:single="true" el:network="false" />
      <el:score el:easy="-" el:difficult="-" />
    </el:info>
    <el:luamain><![CDATA[
rooms_wide=1
rooms_high=1

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

create_world( levelw, levelh)
enigma.ConserveLevel=FALSE

fill_floor("fl-hay", 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-greenbrown", i-1, line)
        elseif c == "o" then
            oxyd( i-1, line)
        elseif c == "*" then
            set_stone( "st-brownie", i-1, line)
        elseif c == "!" then
            abyss(i-1,line)
        elseif c == "~" then
            set_floor("fl-water",i-1,line)
        elseif c=="z" then
            set_actor("ac-blackball", i-.5,line+.5, {player=0})
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funccreset"})
        elseif c=="y" then
            set_actor("ac-whiteball", i-1,line+.5, {player=1})
        elseif c == "g" then
            draw_stones("st-grate1",{i-1,line}, {1,1}, 1)
        elseif c=="+" then
            set_stone( "st-wood", i-1, line)
        elseif c=="=" then
            set_floor("fl-space",i-1,line)
        elseif c=="A" then
            doorh(i-1,line,{name="d1"})
        elseif c=="B" then
            doorh(i-1,line,{name="d2"})
        elseif c=="1" then
            set_floor("fl-leaves",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc1"})
        elseif c=="2" then
            set_floor("fl-wood",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc2"})
        elseif c=="3" then
            set_floor("fl-sand",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc3"})
        elseif c=="4" then
            set_floor("fl-bluegreen",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc4"})
        elseif c=="5" then
            set_floor("fl-metal",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc5"})
        elseif c=="6" then
            set_floor("fl-tigris",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc6"})
        elseif c=="7" then
            set_floor("fl-sahara",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc7"})
        elseif c=="8" then
            set_floor("fl-red",i-1,line)
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funcc8"})
        elseif c=="0" then
            set_item("it-trigger",i-1,line,{invisible=1,action="callback",target="funccreset"})
        end
    end
end

renderLine(00,"####################")
renderLine(01,"# 0 353243286376 #o#")
renderLine(02,"# 0 681328343643 #A#")
renderLine(03,"# 0 576856714536 # #")
renderLine(04,"# 0 213473876714 # #")
renderLine(05,"# 0 452652742475 # #")
renderLine(06,"# z 681534656261   #")
renderLine(07,"# 0 423676384676 # #")
renderLine(08,"# 0 687231725357 # #")
renderLine(09,"# 0 715376132678 # #")
renderLine(10,"# 0 626742627137 #B#")
renderLine(11,"# 0 267128176726 #o#")
renderLine(12,"####################")

oxyd_shuffle()

d1=enigma.GetNamedObject("d1")
d2=enigma.GetNamedObject("d2")

enigma.SendMessage(d1,"open",nil)
enigma.SendMessage(d2,"open",nil)

ffc=0
function funccreset()
    c1=0
    c2=0
    c3=0
    c4=0
    c5=0
    c6=0
    c7=0
    c8=0
    if ffc==1 then
        ffc=0
        enigma.SendMessage(d1,"open",nil)
        enigma.SendMessage(d2,"open",nil)
    end
end

function funcccheck()
    if ((c1>2 or c2>2 or c3>2 or c4>2 or c5>2 or c6>2 or c7>2 or c8>2) and ffc==0) then
        ffc=1
        enigma.SendMessage(d1,"close",nil)
        enigma.SendMessage(d2,"close",nil)
    end
end

ff1=0
c1=0
function funcc1()
    if ff1==0 then
        ff1=1
        c1=c1+1
    else
        ff1=0
    end
    funcccheck()
end

ff2=0
c2=0
function funcc2()
    if ff2==0 then
        ff2=1
        c2=c2+1
    else
        ff2=0
    end
    funcccheck()
end

ff3=0
c3=0
function funcc3()
    if ff3==0 then
        ff3=1
        c3=c3+1
    else
        ff3=0
    end
    funcccheck()
end

ff4=0
c4=0
function funcc4()
    if ff4==0 then
        ff4=1
        c4=c4+1
    else
        ff4=0
    end
    funcccheck()
end

ff5=0
c5=0
function funcc5()
    if ff5==0 then
        ff5=1
        c5=c5+1
    else
        ff5=0
    end
    funcccheck()
end

ff6=0
c6=0
function funcc6()
    if ff6==0 then
        ff6=1
        c6=c6+1
    else
        ff6=0
    end
    funcccheck()
end

ff7=0
c7=0
function funcc7()
    if ff7==0 then
        ff7=1
        c7=c7+1
    else
        ff7=0
    end
    funcccheck()
end

ff8=0
c8=0
function funcc8()
    if ff8==0 then
        ff8=1
        c8=c8+1
    else
        ff8=0
    end
    funcccheck()
end
    ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="true" />
        <el:translation el:lang="de">Magische Dreifaltigkeit</el:translation>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
