<?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="Cold Meditation" el:subtitle="Freeze by the Power of Light" el:id="20070314ral728"/>
      <el:version el:score="1" el:release="1" el:revision="$Revision: 67 $" el:status="released"/>
      <el:author  el:name="Ronald Lamprecht" el:email="ral@users.berlios.de"/>
      <el:copyright>Copyright © 2006 Ronald Lamprecht</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/andreas_itemfreeze" el:id="lib/andreas_itemfreeze" el:release="1" el:preload="true"/>
      </el:compatibility>
      <el:modes el:easy="true" el:single="true" el:network="false"/>
      <el:comments>
        <el:credits el:showinfo="true" el:showstart="false">Thanks to Nat Pryce for his libs and code examples</el:credits>
        <el:code>Lua 5.1</el:code>
      </el:comments>
      <el:score el:easy="18:53" el:difficult="54:52"/>
    </el:info>
    <el:luamain><![CDATA[
enigma.ConserveLevel = TRUE
math_floor = floor

set_oxyd = oxyd

function oxyd( x, y, tiles )
    return set_oxyd( x, y )
end

function nothing(x, y, tiles)
    -- create nothing
end

function horizontal_bolder(x,y,tiles)
    if random() >= 0.5 then
        return set_stone( "st-bolder-w", x, y )
    else
        return set_stone( "st-bolder-e", x, y )
    end
end

function vertical_bolder(x,y,tiles)
    if random() >= 0.5 then
        return set_stone( "st-bolder-n", x, y )
    else
        return set_stone( "st-bolder-s", x, y )
    end
end

function checkerboard_floor( type1, type2, attribs1, attribs2 )
    return function( x, y, tiles )
        if mod(x,2) == mod(y,2) then
            return set_floor( type1, x, y, attribs1 or {} )
        else
            return set_floor( type2, x, y, attribs2 or {} )
        end
    end
end

function floor( floor_type, attribs )
    return function( x, y, tiles )
        return set_floor( floor_type, x, y, attribs or {} )
    end
end

function stone( stone_type, attribs )
    return function( x, y, tiles )
        return set_stone( stone_type, x, y, attribs or {} )
    end
end

function item( item_type, attribs )
    return function( x, y, tiles )
        return set_item( item_type, x, y, attribs or {} )
    end
end

function actor( actor_type, attribs )
    return function( x, y, tiles )
        return set_actor( actor_type, x+0.5, y, attribs or {} )
    end
end

function gradient( gradient_type )
    return function( x, y, tiles )
        return set_floor( "fl-gradient", x, y, {type=gradient_type} )
    end
end

function inherit(tile_type)
    return function( x, y, tiles )
        return create_tile( tiles, x, y, tile_type )
    end
end

function group( array, constructor )
    return function( x, y, tiles )
        object = constructor( x, y, tiles )
        tinsert( array, object )
        return object
    end
end

function difficulty( d, constructor )
    if options.Difficulty == d then
        return constructor
    else
        return nothing
    end
end

function create_world_from_map( tiles, map )
    create_world( strlen(map[1]), getn(map) )
    
    for y = 1,getn(map) do
        local line = map[y]
        for x = 1,strlen(line) do
            local tile = strchar(strbyte(line,x))
            create_tile( tiles, x-1, y-1, tile )
        end
    end
end

function create_tile( tiles, x, y, tile_type )
    local constructors = tiles[tile_type]

    if constructors then
    for i = 1,getn(constructors) do
        constructors[i](x,y,tiles)
    end
    else
    error("invalid tile identifier " .. tile_type )
    end
end

oxyd_default_flavor = "a"

tiles = {}
tiles[" "] = {floor("fl-rough-blue")}
tiles["-"] = {floor("fl-abyss")}
tiles["#"] = {inherit(" "), stone("st-marble")}
tiles["h"] = {inherit("-"), item("it-hollow")}
tiles["x"] = {inherit(" "), item("it-extralife")}
tiles["T"] = {inherit(" "), stone("st-turnstile-green")}
tiles["L"] = {inherit(" "), stone("st-laser-n", {name="laser-left", on=0})}
tiles["K"] = {inherit(" "), stone("st-laser-s", {name="laser-right",on=0})}
tiles["k"] = {inherit(" "), stone("st-switch", {target="laser-right", action="onoff"})}
tiles["l"] = {inherit(" "), stone("st-switch", {target="laser-left", action="onoff"})}
tiles["M"] = {inherit(" "), stone("st-mirror-p-m")}
tiles["m"] = {inherit(" "), stone("st-mirror-p/")}
tiles["n"] = {inherit(" "), stone("st-mirror-p\\")}
tiles["o"] = {inherit(" "), stone("st-mirror-p|")}
tiles["P"] = {inherit("-"), stone("st-lightpassenger")}
tiles["G"] = {inherit(" "), stone("st-glass1_hole")}

tiles["1"] = {inherit(" "), actor("ac-whiteball-small", {player=0, essential=1})}

if difficult then
    tiles["R"] = {inherit("-"), stone("st-rotator_move-right")}
    tiles["r"] = tiles[" "]
    tiles["+"] = tiles["-"]
    tiles["N"] = {inherit("-"), stone("st-turnstile-n")}
    tiles["S"] = {inherit("-"), stone("st-turnstile-s")}
    tiles["w"] = tiles[" "]
    tiles["W"] = tiles[" "]
else
    tiles["r"] = {inherit(" "), stone("st-rotator_move-right")}
    tiles["R"] = tiles["-"]
    tiles["+"] = tiles[" "]
    tiles["N"] = {inherit(" "), stone("st-turnstile-n")}
    tiles["S"] = {inherit(" "), stone("st-turnstile-s")}
    tiles["w"] = {inherit("G"), item("it-wormhole", {targetx=2.5, targety=6.5, range=0.7, strength=1})}
    tiles["W"] = {inherit("G"), item("it-wormhole", {targetx=17.5, targety=6.5, range=0.7, strength=1})}
end

create_world_from_map( tiles, {
"###############K####",
"#m      ----      n#",
"#       ----       k",
"#      N----w      #",
"#  T   +--h-    M  #",
"#       -h--R      #",
"#o 1xr --P--- rx1 o#",
"#  1   R--h-    1  #",
"#  M    -h--+   T  #",
"#      W----S      #",
"l       ----       #",
"#n      ----      m#",
"####L###############"
})

set_itemfreeze(10, 2)
set_itemfreeze(9, 10)
if difficult then
    set_itemfreeze(9, 3)
    set_itemfreeze(10, 9)
else
    set_itemfreeze(9, 4)
    set_itemfreeze(10, 8)
end

itemfreeze_init(0, 0, 0.01)

oxyd_shuffle()
    ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
      <el:string el:key="subtitle">
        <el:english el:translate="true"/>
        <el:translation el:lang="de">Erstarre durch die Macht des Lichtes</el:translation>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>

