The Daily Click ::. Forums ::. Klik Coding Help ::. Using the Python Object in a Level Editor
 

Post Reply  Post Oekaki 
 

Posted By Message

Dysposin



Registered
  15/07/2007
Points
  6
12th April, 2011 at 14:19:53 -

I'm making a level editor with MMF2, and I planned using the Python object for handling the data, math etc. as it has proven to be a pain in the ass with MMF in the past. My Python skills are pretty average (I'm able to make the code I need for this myself), however I'm having problems with using the Python with MMF. As there's no documentation for the Python object (none that I've heard of), it's been pretty much trial and error mixed with trying to understand the examples provided with the object.

My plan is to give the coordinates and the tile type as arguments to my Python class, and when drawing the level, get them back as the return value of a function. I think I've got giving the arguments worked out, yet I'm having huge problems with the return value. Spesifically, how to get a simple (X, Y, Type) string from a list holding the level data.

Any help is appreciated!

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49566

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
12th April, 2011 at 17:00:41 -

I've done a little python with Lacewing, but I haven't tried it with mmf yet.

Have you thought about using lua? Here's a cool example of an editor that uses lua, maybe it'll help:

http://create-games.com/download.asp?id=8324

 
n/a

Dysposin



Registered
  15/07/2007
Points
  6
13th April, 2011 at 11:08:38 -

Yes, I've looked in to Lua too. I'd rather use Python, as I'm familiar with it already, but I'll take a look in that example. As I have understood, LUA shouldn't be that hard either and I've meant to learn to use it as well. Thanks for the tip!

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
13th April, 2011 at 11:20:18 -

I was going to say much the same thing - if you were using Lua, I might know just enough to help, but I've never even tried Python.
I wish there was a javascript extension...

 
n/a

Dysposin



Registered
  15/07/2007
Points
  6
13th April, 2011 at 11:33:22 -

Well, I had a quick look in to the syntax of LUA and I think I should be able to script what I need with it (basically all I need is an array to store the level and functions to read and write it in the format I'm using, nothing fancier).

 
n/a

Dysposin



Registered
  15/07/2007
Points
  6
14th April, 2011 at 16:05:22 -

Well, I went ahead and started coding the necessary functions in Lua. After a few hours of reading different tutorials and beating my head to the wall, I have a start for the level loading function: http://pastebin.com/zBWnfkTc
There's just a quite trivial problem: for some reason, while adding the tables inside the level{} -table (lines 9 - 16), it adds an empty element to the beginning (so print(level[1][n]) results as nil. This of course doesn't cause problems since I could just ignore the first element in the table, but still it bothers me. Any insight on this?

 
n/a
   

Post Reply



 



Advertisement

Worth A Click