YouGroove Posted August 9, 2011 Share Posted August 9, 2011 Wel i have a several questions : -When Loading a world in Lua , does it loads the entities also and their script or do we have to create them by code and place them in the world loaded by code ? - It is possible to detect in LUA a collision tha returns what otehr entitie is collided (like a dynamic one , like a character) ? By raycast ? by volume detection collision ? -It is possible in Lua to access other entities Lua variables after laoding a level. For example i made some NPC character i placed in the editor that has the variable "Life" for example. My main Lua script will have some function to load the level than manage a Third view controler , when i fire a weapon for example, It is possible to manage in Lua to retriev this variable "Life" of the other entitie and decrease it ? And after reaching zero, play death animation on otehr entitie ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
macklebee Posted August 9, 2011 Share Posted August 9, 2011 1) loadscene loads the model's mesh (with its material if it has one), script (if it has one), and PHY body (if it has one, if not creates a static one) 2) yes by collision 3) yes also please post programming questions in the appropriate forum board. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
YouGroove Posted August 9, 2011 Author Share Posted August 9, 2011 Thanks a lot macklebee I think i have all the answers i needed before engaging programming in Lua. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted August 9, 2011 Share Posted August 9, 2011 About your 3rd question here is what I've been doing. 1) Create a model that represents a character (or whatever) 2) Create a lua script for that model and in that scrip add variables specific to it: function class:CreateObject(model) local object=self.super:CreateObject(model) object.health = 100 3) Then in my main lua game file is where I create these models (although you could place them at design time also). I then either loop through a list I've stored the models in or if I pick with the mouse the entity to get the model which then you can use: objecttable[model].health = 20 So once you get a variable pointing to a model you can use it as a key to the objecttable table to get those model specific variables. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 9, 2011 Author Share Posted August 9, 2011 Thanks Rick ! In fact i really wanted t oavodi the "get Models" from the scene I thaught they could just interact between them and the player only by their "attached" scripts ! For example in the editor i place a model where i put the player code (Camera view, atacking code , collision with other entities etc ...) Than i put in the level some ennemies, i attach to each of them some action like "if player near -> attack ; if life to 0 , fall animation then remove from world) I thaught the main function would only be used to initialize the engine, laod the world, and manage menus or level changing. In fact it is same as with C# or C++ where you must lookup for all entities you have placed in the world than call the good code appropritae to the enity type ? I'll try it tonight. Perhaps it can be the other way, of placing all modes on the world editor and their code. Then just make a simple main to load the level ready to play without having to care about entities because their code have been edited from the world editor ! Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted August 9, 2011 Share Posted August 9, 2011 Yeah, you can do that also. Just note you'll have to tell the AI scripts who the "player" is. If you look here -> http://www.leadwerks.com/werkspace/files/category/6-scripts/ and look for things that start with Pi-, this is the route I was taking some time back. It was all script attachment based with one variable I think in the main script to tell if we were in design mode or gameplay mode since everything you put in Update() will run no matter what mode you are in and sometimes you wouldn't want that. Like in your example you probably wouldn't want your AI running around when in design mode. To let the AI scripts "know" who the player is you could use the link system (although that might get to be a pain to have to link the player to each enemy) or you could create a custom property that holds the name of the player object you have. You can see some examples I've done in the past with Pi- scripts where a small little demo is entirely done in model scripts (or what I call Thingoids) Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 9, 2011 Author Share Posted August 9, 2011 Thanks a lot Rick ! I'll dig and test these examples tonigh. Yes i will put a variable to stop NPC attacking in level editing mode indeed, or it will be a real warfare battle with NPC and me trying to adjust the level ! you could create a custom property that holds the name of the player object you have. Some engines proposes something similar to this , and this is what i'll choose. For example the name will simply be : "PLAYER" it wil lhave all player things , propeties , collision stuff etc ... Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
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.