Post tutorial RSS Level Editing Scripting by Prospero. Part. 1

I thought I would start this topic to answer scripting questions and do mini tutorials on various Python stuff for the benefit of mappers. (This is just how I do things, and I don't know everything by any means.) (caravel. Maybe it could be made into a 'sticky'.)

Posted by on - Basic Client Side Coding


OK, you have made a map, compiled and loaded it and your Player char is stood alone wondering how to fill this new world with interesting stuff.

All the gameplay flow is controlled from a file:

Create a file with this exact name and save it to your map folder in BODLOader/Maps.

This file is one of the Key files that is executed again when loading a saved game. For that reason it must always have this name. All your other .py files that create objs, etc are only executed on first load.

In a basic map you will have three essential files: # initiates the map and loads all the files needed for your map. # creates the Player character
MyMap.lvl # loads all the texture files + dome (sky) and .bw (compiled 'Blade World' file)

*I will use the term MyMap to refer to the name of your map folder.(case sensitive)

The BODLoader will create these files automatically if they don't exist in the BODLoader/Maps/MyMap folder. NEVER edit your files in the main Maps folder. ALWAYS edit in the BODLoader and unistall/install your map to test it. If you don't stick to this practice you risk hours of work being overwritten by older files. (Yes, I have done this more than a few times. )

Next, open the file and add this line at the end:


All the files you create will be executed from here, but keep DefFuncs
at the top of the list.

Now open

There is nothing to add yet, but for a start you can add the code to enable the savegame.

First add this:

python code:
import GameText

You will need lots of imports as you proceed, but at the moment you only need this one. An import statement allows you to access to all the code in the imported file from the file it is imported to. If you try to do this for example:

python code:

without importing the file, you will cause an error. Python reads code from the top of a file down, so put you imports before you use their code. (usually they are all at the top of the file.)

Underneath the GameText import add:

python code:
GameText.MapList["MYMAP"] = ["MyMap"]

First box is a CAPITALIZED version of your map name.

Save and load your map (remember to uninst/inst). If all is well, your map will appear in the save menu screen. Try saving/loading the map. You should have no probs at this point as there is nothing else in the map to foul things up. Making the save games reliable can get very tricky as you add more things.....

Try the F1 key. This code also enables the Travel Book.

To be continued.....

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.