home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 August / GSSH0804.iso / Geschicklichkeit / Enigma / Enigma-081.exe / data / levels / ralf12.lua < prev    next >
Text File  |  2003-09-21  |  4KB  |  174 lines

  1. -- A level for Enigma
  2. -- Name:        -- puzzle meditation --
  3. -- Filename:    ralf12.lua
  4. -- Copyright:     (C) Jun 2003 Ralf Westram
  5. -- Contact:     amgine@reallysoft.de
  6. -- License:     GPL v2.0 or above
  7.  
  8. dofile(enigma.FindDataFile("levels/ralf.lua"))
  9.  
  10. --debug_mode()
  11.  
  12. level={
  13.    "!!#!@@########@@!#!!",
  14.    "!!+!@@  ....  @@!+!!",
  15.    "#+++U   ****   U+++#",
  16.    "!!+#  $$++*+$$  #+!!",
  17.    "@@T   $ ++++     T@@",
  18.    "@@.  *++    ++*  .@@",
  19.    "#.b.***+ bb +***.b.#",
  20.    "@@.  *++    ++*  .@@",
  21.    "@@T     ++++ $   T@@",
  22.    "!!+#  $$+*++$$  #+!!",
  23.    "#+++U   ****   U+++#",
  24.    "!!+!@@  ....  @@!+!!",
  25.    "!!#!@@########@@!#!!",
  26. }
  27.  
  28. state={}
  29. group={1,2,2,1,3,4,5,5,6,6,3,4,7,8,8,7} -- trigger->target
  30. count={0,0,0,0,0,0,0,0} -- how many triggers of each group are active (2 exist per group)
  31.  
  32. difficult=nil
  33. if (options.Difficulty==2) then difficult=1 end
  34.  
  35. triggers=0
  36. targets=0
  37.  
  38. function trigger_group(num)
  39.    local target = enigma.GetNamedObject("target"..num)
  40.    enigma.SendMessage(target,"openclose",nil)
  41. end
  42.  
  43. function trigger(num)
  44.    local newstate = 1-state[num]
  45.    local offset = 1
  46.    if (newstate==0) then offset=-1 end
  47.  
  48.    local g = group[num]
  49.    if (count[g]==2) then
  50.       trigger_group(g) -- deactivate target
  51.    end
  52.    count[g] = count[g]+offset
  53.    if (count[g]==2) then
  54.       trigger_group(g) -- activate target
  55.    elseif (count[g]>2 or count[g]<0) then
  56.       error("group count overflow")
  57.    end
  58.  
  59.    state[num] = newstate
  60. end
  61.  
  62. function set_trigger(x,y)
  63.    triggers = triggers + 1
  64.    state[triggers] = 0
  65.    local funcn = "trig_"..triggers
  66.    dostring(funcn.." = function() trigger("..triggers..") end")
  67.    set_item("it-trigger",x,y,{action="callback",target=funcn});
  68. end
  69. function set_target(x,y,t)
  70.    targets = targets + 1
  71.    set_stone("st-door_b",x,y,{name="target"..targets,type="v"});
  72. end
  73. function set_targetv(x,y) set_target(x,y,"v") end
  74. function set_targeth(x,y) set_target(x,y,"h") end
  75.  
  76. cells={}
  77.  
  78. cells[" "] = cell{floor="fl-hay"}
  79. cells["!"] = cell{floor="fl-abyss"}
  80. cells["#"] = cell{parent=cells[" "],stone="st-brick"}
  81. cells["b"] = cell{parent=cells[" "],actor={"ac-whiteball-small", {player=0}}}
  82. cells["."] = cell{parent={cells[" "],set_trigger}}
  83. cells["T"] = cell{parent={cells[" "],set_targeth}}
  84. cells["U"] = cell{parent={cells[" "],set_targetv}}
  85. cells["o"] = cell{oxyd}
  86.  
  87. cells["w"] = cell{parent=cells[" "], item="it-magicwand"}
  88.  
  89. puzzles1 = {}
  90. puzzles2 = {}
  91. bigbricks = {}
  92.  
  93. cells["*"]=cell{parent={{add_multicell, puzzles1}}}
  94. cells["+"]=cell{parent={{add_multicell, puzzles2}}}
  95. cells["@"]=cell{parent={{add_multicell, bigbricks}}}
  96.  
  97. if (difficult) then
  98.    cells["$"]=cells["+"]
  99. else
  100.    cells["$"]=cells[" "]
  101. end
  102.  
  103. rs_create_world(level,cells)
  104.  
  105. render_puzzles(puzzles1)
  106. render_puzzles(puzzles2, puzzle2)
  107. render_puzzles(bigbricks, bigbrick)
  108.  
  109. function scrambleDiff(x,y,d) if (difficult) then enigma.AddScramble(x,y,d) end end
  110. function scrambleEasy(x,y,d) if (not difficult) then enigma.AddScramble(x,y,d) end end
  111. function scrambleBoth(x,y,d) enigma.AddScramble(x,y,d) end
  112.  
  113. -- tiles in corners:
  114. enigma.SetScrambleIntensity(30)
  115.  
  116. scrambleBoth(2,3,"n")
  117. scrambleBoth(3,2,"w")
  118.  
  119. scrambleBoth(2,9,"s")
  120. scrambleBoth(3,10,"w")
  121.  
  122. scrambleBoth(17,3,"n")
  123. scrambleBoth(16,2,"e")
  124.  
  125. scrambleBoth(17,9,"s")
  126. scrambleBoth(16,10,"e")
  127.  
  128. -- tile(s) in center:
  129. --  north
  130. scrambleEasy(8,3,"e")
  131. scrambleBoth(8,4,"n")
  132. scrambleEasy(8,4,"e")
  133. scrambleBoth(9,4,"n")
  134. scrambleBoth(11,4,"w")
  135. scrambleBoth(11,4,"n")
  136.  
  137. -- west
  138. scrambleEasy(7,5,"s")
  139. scrambleBoth(7,5,"w")
  140. scrambleBoth(7,7,"n")
  141. scrambleBoth(7,7,"w")
  142.  
  143. -- east
  144. scrambleBoth(12,5,"s")
  145. scrambleBoth(12,5,"e")
  146. scrambleEasy(12,7,"n")
  147. scrambleBoth(12,7,"e")
  148.  
  149. -- south
  150. scrambleBoth(8,8,"s")
  151. scrambleBoth(8,8,"e")
  152. scrambleBoth(10,8,"s")
  153. scrambleEasy(11,8,"w")
  154. scrambleBoth(11,8,"s")
  155. scrambleEasy(11,9,"w")
  156.  
  157. -- outer corners
  158. scrambleDiff(13,3,"w")
  159. scrambleDiff(6,3,"e")
  160. scrambleDiff(6,3,"s")
  161. scrambleDiff(6,9,"e")
  162. scrambleDiff(13,9,"w")
  163. scrambleDiff(13,9,"n")
  164.  
  165. oxyd_shuffle()
  166.  
  167. -- Added hollows (dh)
  168.  
  169. set_item("it-hollow", 2, 2)
  170. set_item("it-hollow", 2, 10)
  171. set_item("it-hollow", 17, 2)
  172. set_item("it-hollow", 17, 10)
  173.  
  174.