Blade of Darkness holds true to the greatest of hack and slash legends, combining sorcery, knights, and swords with god forsaken enemies that deserve to have their arms slashed off with a broadsward. Blade of Darkness looked excellent in 2001, and still delivers its gore well today. Holding True to it's genre it offers modders both custom maps and scripts. Relevent Links Fansite Mod List Modding Community

Post tutorial Report 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

Tut1.

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:

DefFuncs.py

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:

cfg.py # initiates the map and loads all the files needed for your map.
pj.py # 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 cfg.py file and add this line at the end:

execfile("DefFuncs.py")

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

Now open DefFuncs.py

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:
darfuncs.HideBadGuy("Ork1")


without importing the file darfuncs.py, 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

Your comment will be anonymous unless you join the community. Or sign in with your social account: