Lsokoban level editor for Windows

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Lsokoban level editor for Windows

Post by cgruber »

Hi guys,
Just wanted to let you know I threw together a quick level editor for making new Lsokoban levels. It's very basic and only allows you to save files not load them but I think it's more than enough to whip out a couple levels in no time flat.

Just remember to save them to /levels directory and give them the next number up. If you want to share any levels post them here and I'll include them in the future.

http://stuff.hyperpixel.net/leveleditor.zip

Image

Here's a new map for level 5

gamefield = {
0,1,1,1,1,0,0,0,0,1,1,1,1,0,
1,-2,-2,0,0,1,0,0,1,0,0,-2,-2,1,
1,-2,2,0,2,0,1,1,0,2,0,2,-2,1,
0,1,0,2,0,2,0,0,2,0,2,0,1,0,
0,0,1,0,0,0,0,0,0,0,0,1,0,0,
0,0,0,1,-2,0,1,1,0,-2,1,0,0,0,
0,0,0,0,1,0,-1,0,0,1,0,0,0,0,
0,0,0,0,0,1,1,1,1,0,0,0,0,0
}
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Carl,

I am relatively new to Sokoban puzzle. Now, I have played the puzzle using Sokoban YASC (for Windows). I seemed to like it. Thought I would convert Skinner's Microban levels (the first 10) using your LevelEditor. They perfectly fit in your LSokoban's screen (8 by 14 tiles). You (and others) can get it at my webpage. The levels are good for beginners. Try them, huh?

Do you plan to upgrade your LevelEditor such as clearing all tiles, opening previous levels for re-editing, saving files with a new name, etc.?

With those features, I'll go ahead to add more levels to Skinner's Microban.

Thanks.
Geo Massar
Retired Engineer
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Forgot to mention another feature. Whenever the editor application is minimized or closed, the tile tool should be hidden.

Thanks.
Geo Massar
Retired Engineer
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

Thanks for the levels and feedback.

I think I can add everything you requested.. It was basically a quick hack to get a level editor working (~15 minutes in visual basic).

I'm gonna play those levels now and add then into the rotation.


One question, what do you mean by save as a different name?

Like a save as command on the file menu?
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Yes, just like a regular editor.

I have somewhat trouble with moving player around. Sometimes the player steps twice when I meant a single step. Maybe it was my PSP but I tested the motion on LP for Windows, the same effect. Maybe, modify your code as to keep single steps, one a time just like Shine's calculator.

Have fun!
Geo Massar
Retired Engineer
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

Just to verify your using version 0.4 and seeing that?
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Yep.

I just deliberately wrote a movetest script to see how the motion is improving. Here is a pair of codes, before and after versions, to get an idea.

Before version ...

Code: Select all

-- movetest.lua by Geo Massar

function move()
  local pad = Controls.read()

  if pad:right() then
    playerPos = playerPos + 1
    if playerPos > 13 then playerPos = 13 end
  end
  
  if pad:left() then
    playerPos = playerPos - 1
    if playerPos < 1 then playerPos = 1 end
  end
end

player = Image.load "player.png"
playerPos = 1

while true do
  screen&#58;clear&#40;&#41;
  move&#40;&#41;
  screen&#58;blit&#40;32*playerPos, 120, player&#41;
  screen.waitVblankStart&#40;5&#41;
  screen&#58;flip&#40;&#41;
end
And, the after version ...

Code: Select all

function move&#40;&#41;
  local pad = Controls.read&#40;&#41;

  if pad ~= oldpad then
    if pad&#58;right&#40;&#41; then
      playerPos = playerPos + 1
      if playerPos > 13 then playerPos = 13 end
    end

    if pad&#58;left&#40;&#41; then
      playerPos = playerPos - 1
      if playerPos < 1 then playerPos = 1 end
    end
    oldpad = pad
  end
end
The after version works much better but yet you have to press the same key repeatedly if you want to move the player in the same direction. Maybe, need more improvement. I'll try it once more and will let you know if you are interested.
Geo Massar
Retired Engineer
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

Maybe if it matches the oldvalue a delay should be inserted so you don't have to keep pressing it.

Found a weird bug. Ocassionally the game crashes saying the map file isnt there even though it is. If you press back and forth enough times it will show up.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Yes, I have seen the wierd bug.

I am working on the improvement. Looks like I got a solution.
Geo Massar
Retired Engineer
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

I got the working model. Let me know what you think.

Further improved...

Code: Select all

-- movetest.lua by Geo Massar

function move&#40;&#41;
  local pad = Controls.read&#40;&#41;

  if &#40;pad ~= oldpad&#41; or &#40;countpads > 5&#41; then     -- adjust the count limit as needed
    if pad&#58;right&#40;&#41; then
      playerPos = playerPos + 1
      if playerPos > 13 then playerPos = 13 end
    end

    if pad&#58;left&#40;&#41; then
      playerPos = playerPos - 1
      if playerPos < 1 then playerPos = 1 end
    end
    oldpad = pad
    countpads = 0
  else
    countpads = countpads + 1
  end
  
end

player = Image.load "player.png"
playerPos = 1
countpads = 0

while true do
  screen&#58;clear&#40;&#41;
  move&#40;&#41;
  screen&#58;blit&#40;32*playerPos, 120, player&#41;
  screen.waitVblankStart&#40;&#41;                  -- remove the 5 as it seems unnessary.
  screen&#58;flip&#40;&#41;
end
I'll call it a night. See ya tmw if you are around. :)
Geo Massar
Retired Engineer
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Carl,

I have modded your Lsokoban with the repeating mechanism mentioned in the other thread: http://forums.ps2dev.org/viewtopic.php?t=3423

It works flawless except the wierd bug you mentioned earlier. I'll try to solve it (I think I know the solution.)

I have added 10 more levels to Skinner's list. It is available in my webpage.

Thanks for the great puzzle in spite of its being a clone.
Geo Massar
Retired Engineer
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Here is the solution I think you might want to mod your LSokoban.

The code below is to load all levels at once and store them in a table (an array). For checkout, it prints all levels on the console using LP-Win32.

Use Lua's dostring() instead of dofile() to read one level a time into the system. Eq:

dostring(gamefields[level])

The "wierd bug" will be gone forever!

Have fun!

PS Triggers on PSP should advance levels at lightening speed.

Code: Select all

-- levelloader.lua by Geo Massar, 2005

gamefields = &#123;&#125;
level = 1
while true do
  levelfile = string.format&#40;"Levels/%d.lua", level&#41;
  f = io.open&#40;levelfile&#41;   -- as read by default
  if f then
    print&#40;"Reading "..levelfile&#41;
    gamefield = f&#58;read&#40;"*all"&#41;
    table.insert&#40;gamefields, gamefield&#41;
    level = level + 1
  else
    break                  -- no more left
  end
end

for level = 1, table.getn&#40;gamefields&#41; do
  print&#40;&#41;
  print&#40;"Level "..level&#41;
  print "--------------------"
  io.write&#40;gamefields&#91;level&#93;&#41;
end
Geo Massar
Retired Engineer
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

Nice I'll try it out.
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

added some of the new stuff you wanted.

http://stuff.hyperpixel.net/editor.zip

just replace the exe with this one.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Thanks for the modded editor. Will the next version include opening files for re-editting?

For your reward, I have added 10 more levels (total is 30 so far.)

However, I am rather unable to verify the last 10 levels due to the "wierd bug". Hope you would fix it soon.

There are about 100 levels available. As soon as the bug is killed, I 'll add many more levels in return. :)
Geo Massar
Retired Engineer
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

I've been working on opening files and it works most of the time but theres another bug to track down. :(
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

That io.open bug doesnt happen in lua player for windows.

BTW level 29 is interesting :)
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Try io.input() instead. However, you'll need to know how many files in advance to read in. Not pretty picture, tho',

The original level 29 was too big for 8 x 14 map. Maybe, the next major version will take either 8 x14 or 16 x 28. It will be a puzzle killer, indeed.
Geo Massar
Retired Engineer
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

I got so pissed off about this I stopped working on it but today I sat down and finally found the solution to that bug.

The fix is to use a local variable and set that to equal the result of the io.open
and then close the handler with variable.close(). Works perfect now
cgruber
Posts: 36
Joined: Tue Sep 06, 2005 6:38 am

Post by cgruber »

http://stuff.hyperpixel.net/lsokoban.zip

Version 0.5 with 29 playable levels and the control fix thanks to Geo
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

The control works MUCH better, indeed!

Thanks for your stubbornness to fix bugs. :)

For your reward, I'll send you another set of about 30 levels soon. Same author who designed the levels.

Hey, you folks, try this game for yourself. Rather addictive but challenge!
Geo Massar
Retired Engineer
Post Reply