def RegisterThemeHall(interface): theme = wrapper.Theme.Interface(interface)### TILES # ...### STATICS # ...### DYNAMICS### type image_id move_type speed range power hp theme.DynamicObj(DT.Hero, IDI.HERO.TYPE_01[0], MoveType.WALK, 3.5, 0, 2, 200) theme.DynamicObj(DT.Hero, IDI.HERO.TYPE_02[0], MoveType.WALK, 3.5, 0, 2, 200) theme.DynamicObj(DT.Monster, IDI.MONSTER.GREEN[0], MoveType.WALK, 3.0, 200, 2, 75) theme.DynamicObj(DT.Monster, IDI.MONSTER.MUCILAGE[0], MoveType.WALK, 1.5, 130, 10, 80) theme.DynamicObj(DT.Monster, IDI.MONSTER.RADIO[0], MoveType.WALK, 1.0, 150, 10, 120) theme.DynamicObj(DT.Monster, IDI.MONSTER.MAGE[0], MoveType.WALK, 1.0, 200, 15, 150) theme.DynamicObj(DT.Missile, IDI.MISSILE.PULSE[0], MoveType.FLY, 7.0, 110, 30, 0) theme.DynamicObj(DT.Missile, IDI.MISSILE.MUCILAGE[0], MoveType.FLY, 5.0, 140, 20, 0) theme.DynamicObj(DT.Missile, IDI.MISSILE.MAGIC[0], MoveType.FLY, 8.0, 400, 45, 0)#RegisterThemeHall()def RegisterThemeStore(interface): # ...#RegisterThemeStore()def RegisterThemeCellar(interface): # ...#RegisterThemeCellar()RegisterFunction = {}RegisterFunction[0x00] = RegisterThemeCellarRegisterFunction[0x01] = RegisterThemeStoreRegisterFunction[0x02] = RegisterThemeHalldef Register(theme_pointer, theme_id): """ Loads current type data. 'data_pointer' is a pointer to data interface in C/C++ code. """ try: RegisterFunction[theme_id](theme_pointer) except: raise#Register()
I know, ugly, but those times it worked nice for me and the deadline was approaching (I wrote the glue code by hand). now the problem is that the object definition is opened and limited by the 'theme.DynamicObj()' function. using the technique mentioned above, those ugly lines will be changed to something as follows (because I'm lazy that ugly stuff with function array is still there):
def RegisterThemeHall(interface): theme = wrapper.Theme.Interface(interface) # ...### DYNAMICS theme.DynamicObj(DT.Hero.Type01) theme.DynamicObj(DT.Hero.Type02) theme.DynamicObj(DT.Monster.Green) theme.DynamicObj(DT.Monster.Mucilage) theme.DynamicObj(DT.Monster.Radio) theme.DynamicObj(DT.Monster.Mage) theme.DynamicObj(DT.Missile.Pulse) theme.DynamicObj(DT.Missile.Mucilage) theme.DynamicObj(DT.Missile.Magic)#RegisterThemeHall()
the only reason that I founded this thread is that I was wondering whether it's necessary to register newly added objects. whether there is no technique to bypass the cursed land.
suppose that we are using a scripting language for defining our new objects (than it's opened for extern contributors and fans[smile]). today I'm using Lua, so here is something:
-- Registers all objects defined in "obj_dir" directoryfunction registerObjectDir(_obj_dir) local directoryList = io.dircontents(_obj_dir) for objectFile in directoryList do registerObject(objectFile) endend
you have an idea. but how to write something as about in C++ that only one thing to add new object is to link it with new object compiled in .o file?