Updated August 13, 2006
HOME PAGE > AUTHORS > PROSPERO > BOD PYTHON SCRIPTING (20)
Tut 20. A Painless Way to Install New Objects.![]()
I think I have finally found a good way to install new models
(objects or characters). Previously, in demo maps I have made, it was necessary
to manually copy .BOD files to the correct directory. The new method makes the
map completely plug'n'play. The maps must be made as a 'Mod' and installed from
the BODLoader 'Mods' directory.
Step1.
Make a folder in your map
named 'To3DObjs'. Put all your new .BOD files for Objects in here. For new
Characters, put the .BOD files in another folder named
To3DChars.
Step2.
At the end of the file 'BLModInfo.py', add this
code:
inststuff=0
if inststuff==0:
execfile("../../BODLoader/Mods/MyMapName/Installnewstuff.py")
instuff=1
else:
print "Install stuff already done"
import os
import shutil
import stat
def getmtime(filename):
st = os.stat(filename)
return st[stat.ST_MTIME]
Odst= ('../../3DObjs')
ObjFiles=os.listdir('../../BODLoader/Mods/WizardsDomain/To3DObjs')
for file in ObjFiles:
newfile = os.path.basename (file)
Osrc= ('../../BODLoader/Mods/WizardsDomain/To3DObjs/'+newfile)
if os.path.exists('../../3DObjs/'+newfile):
print "Exists file: ",newfile
# if file already exists in dest dir, check for for mod time
if getmtime('../../3DObjs/'+newfile) < getmtime(Osrc):
shutil.copy(Osrc,Odst)
print "overwriting : ",newfile
else:
print "NOT exists: ",newfile
#if file does not already exist at dest dir, copy it straight to dest dir
shutil.copy(Osrc,Odst)
print "copying: ",newfile
Cdst= ('../../3DChars')
if os.path.exists ("../../3dObjs/mynewobject.BOD"):
if not os.path.exists ("../../Config/mynewobject.cfg"):
listapp = open("../../BodLink.list", "a")
listapp.write("..\\..\\3dObjs\\mynewobject.BOD\n")
listapp.write("MyNewObject\n")
listapp.close()
cfgfile = open("../../Config/mynewobject.cfg","w")
cfgfile.write("The presense of this file ensures that the BodLink.list is not repeatedly appended.\n")
cfgfile.close()
import Reference Reference.DefaultObjectData['MyNewSword']= [Reference.OBJ_WEAPON, 2, 0, 2.0, Reference.THR_SPINNING, [Reference.W_FLAG_1H,]] Reference.DefaultSelectionData['MyNewSword']=(8.0,4000.0, "My New Sword") For savegame integrity, add the same code to a file 'ActorsInit.py' This is not strictly necessary, but the save will crash on load if the Player happens to have a new object in his inventory when you saved. New Characters need a lot more data. (See eariler tuts)