<?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="Hexagony" el:subtitle="" el:id="nat22"/>
      <el:version el:score="1" el:release="2" el:revision="1" el:status="released"/>
      <el:author  el:name="Nat Pryce" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2003 Nat Pryce</el:copyright>
      <el:license el:type="GPL version 2" el:open="true"/>
      <el:compatibility el:enigma="1.10">
        <el:dependency el:path="lib/libmaze" el:id="lib/libmaze" el:release="2" el:preload="true"/>
      </el:compatibility>
      <el:modes el:easy="true" el:single="true" el:network="false"/>
      <el:comments><el:code>New API converted by R. Bourquin</el:code></el:comments>
      <el:score el:easy="-" el:difficult="-"/>
    </el:info>
    <el:luamain><![CDATA[
wo["ConserveLevel"] = false

ti["~"] = {"fl_water"}
ti["-"] = cond(wo["IsDifficult"], {"fl_metal"}, {"fl_samba"})
ti["."] = ti["~"]
ti["#"] = cond(wo["IsDifficult"], {"st_fake_quake"}, {"st_panel"})
ti["O"] = {"st_oxyd"}
ti["@"] = ti["-"] .. {"#ac_marble_black", name="marble"}

maze = res.maze(ti, {area={".", "@"}, render={"-", "~", "-"}})

wo(maze, "~", {
    "######O#########################O######",
    "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#",
    "#~...................................~#",
    "#~...................................~#",
    "#~...................................~#",
    "#~...................................~#",
    "O~......@............................~O",
    "#~...................................~#",
    "#~...................................~#",
    "#~...................................~#",
    "#~...................................~#",
    "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#",
    "######O#########################O######"})

local number = 6
local radius = 2.0
local theta = 2.0*math.pi/number
local segment = 2.0*radius*math.sin(theta/2.0)
for i=0,number-1 do
    wo[no["marble"]+po(0.5,0.5)+po(radius*math.cos(i*theta), radius*math.sin(i*theta))] = {"ac_rotor", name="rotor#", range=2.0, strength=-40.0, gohome=false}
end
local rotors = no["rotor#*"]:sort("circular")
for i=0,#rotors-1 do
    wo:add({"ot_rubberband", anchor1=no["marble"], anchor2=rotors[i+1], length=radius, threshold=radius, strength=20.0})
    wo:add({"ot_rubberband", anchor1=rotors[i+1], anchor2=rotors[(i+1)%number+1], length=segment, threshold=segment, strength=20.0})
end

wo:shuffleOxyd()
 ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
