315 |
return 2 -- unknown |
return 2 -- unknown |
316 |
end |
end |
317 |
|
|
318 |
|
maxoxyds = 999 |
319 |
|
|
320 |
function install_oxyds(w,h) -- uses Nat's method (see nat7.lua) |
function install_oxyds(w,h) -- uses Nat's method (see nat7.lua) |
321 |
for x=1,w do |
for x=1,w do |
322 |
for y=1,h do |
for y=1,h do |
405 |
end |
end |
406 |
|
|
407 |
-- delete superfluous oxyds |
-- delete superfluous oxyds |
408 |
while ((positions>triggers) or (mod(positions,2)==1)) do |
while ((positions>triggers) or (positions>maxoxyds) or (mod(positions,2)==1)) do |
409 |
tremove(position,random(1,positions)); |
tremove(position,random(1,positions)); |
410 |
positions = positions - 1 |
positions = positions - 1 |
411 |
end |
end |
414 |
error("No oxyds.") |
error("No oxyds.") |
415 |
end |
end |
416 |
|
|
417 |
|
if (maxoxyds>positions) then |
418 |
|
maxoxyds = positions |
419 |
|
end |
420 |
|
|
421 |
-- now really set oxyds |
-- now really set oxyds |
422 |
for p=1,positions do |
for p=1,positions do |
423 |
local xd,yd = position[p][1],position[p][2] |
local xd,yd = position[p][1],position[p][2] |
492 |
|
|
493 |
function play_sokoban(level,num) |
function play_sokoban(level,num) |
494 |
local w,h = get_map_size(level) |
local w,h = get_map_size(level) |
495 |
local tries = 100 |
local tries = 80 |
496 |
local ok = 0 |
local ok = 0 |
497 |
|
|
498 |
while (tries > 0 and ok == 0) do |
while ((tries > 0) and (maxoxyds > 0) and (ok == 0)) do |
499 |
init(num-1) |
init(num-1) |
500 |
randomseed(enigma.GetTicks()) |
randomseed(enigma.GetTicks()) |
501 |
-- rs_create_world(level,cells,spacecell,spacecell) |
-- rs_create_world(level,cells,spacecell,spacecell) |
526 |
ok = correct_door_positions() |
ok = correct_door_positions() |
527 |
if (ok == 0) then debug("re-initializing.."); end |
if (ok == 0) then debug("re-initializing.."); end |
528 |
tries = tries - 1 |
tries = tries - 1 |
529 |
|
if (maxoxyds > 2) then |
530 |
|
maxoxyds = maxoxyds - 1 |
531 |
|
end |
532 |
end |
end |
533 |
|
|
534 |
if (ok==0) then |
if (ok==0) then |