Learning new stuff...
Well, I have been playing with the editor, lua scripts, and integrating lua-scripted objects into a framewerk bmax program. There are some quirks that you have to work around and some modifications that need to be made to some things... First, it doesn't appear you can transfer certain aspects of lua framewerk to an external program that is using framewerk. Setting worlds appears to work but using a framewerk method in lua and expecting it to work in your external program does not.
Setting framewerk worlds between lua and the external bmax program requires that you set a global object in bmax, and retrieve the value in lua.
SetGlobalObject("world_main", fw.Main.world) SetGlobalObject("world_transparency", fw.transparency.world) SetGlobalObject("world_background", fw.background.world) SetGlobalObject("camera_main", fw.Main.camera) SetGlobalObject("camera_transparency", fw.transparency.camera) SetGlobalObject("camera_background", fw.background.camera) SetGlobalObject("renderer_world", fw.renderer)
Collisiontypes (more commonly known as entitytypes) are handled by the property settings in the Editor. But for the collisions to work in your external program, you still need to set all of the possible collision combinations in your external program.
Collisions(1, 1, 1) Collisions(1, 2, 1) Collisions(1, 3, 1) Collisions(2, 2, 1) Collisions(2, 3, 1) Collisions(3, 3, 1) etc...
The skybox setting inside the atmosphere gmf lua script, is using a framewerk method, so that it prevents your external program from using it... hence no skybox. So you could completely rewrite the lua script to do the stuff the old fashion way... inverted skybox, painting material... etc... or just parse thru the sbx file like we used to do with ProcessScene() as Josh recommends that we do in bmax.
Local scene:TEntity = LoadScene("abstract::testscene.sbx") Local entity:TEntity For entity = EachIn scene.kids Local skymaterial:String = entity.GetKey("skymaterial", "") If skymaterial <> "" skymaterial = "abstract::" + skymaterial fw.renderer.SetSkybox(LoadMaterial(skymaterial)) EndIf Next
Another example of lua framewerk causing issues combined with bmax is the oildrum's script where the collision functions sound emitter is using fw.listener to determine if it should play the sound or not. So the existing script needs to be modified to allow for use in the Editor as well as being used in an external program.
The bmax code needed:
SetGlobalObject("listener", CreateListener(fw.Main.camera))
The modified oildrum lua script's collision function here.
The goal with trying to get the standard Editor objects to work with bmax framewerk is to learn what works and what doesn't work. The lessons learned here will help bypass problems when creating scripts for my own custom objects. The final goal of course is to not only have them work in my game but the editor as well to allow me to share scripts with others in the forum.
4 Comments
Recommended Comments