Rick Posted December 1, 2009 Share Posted December 1, 2009 Here is something that might be of interest and should allow for some more dynamic behavior controlled from the editor. You can call functions by just knowing the string name of it. function HelloWorld(name) print("Hello "..name) end _G["HelloWorld"]("Rick") With this you can have a model class that has 2 properties. One for a lua file and one for a function name. In the Spawn() you can run a dofile() on the lua file to load it, and inside the update you can read the function name and call it from the string name. This would allow 1 model class to have different behaviors based on what you setup via the editor. So let's say I'm making an rpg game. I have a rat model that I really like and would like to use a few times. Let's say I want a "Small Rat" that has basic attacks. Then later in my game I want to use the same rat model but want it to have more functionality and call it "Big Rat". With this I can have 2 separate lua files that control the behavior of the rat and in the editor assign what lua file gets played with each instance. Very cool. This will also be useful for volume triggers because you can use the same trigger model but have it run different things, because the trigger model is generic and what happens in each trigger would be unique. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.