Chris Vossen Posted March 2, 2013 Author Share Posted March 2, 2013 Hi, I'm getting the following error in lua; 'attempt to index global 'Map' (a nil value). function App:Start() --Set the application title self.title="MyGame" --Create a window self.window=Window:Create(self.title,0,0,1024,768,Window.Titlebar+Window.Center+8) --self.window:HideMouse() --Create the graphics context self.context=Context:Create(self.window,0) if self.context==nil then return false end --Create a world self.world=World:Create() --Load a map return Map:Load("Maps\start.map") end Try: adding in an extra backslash return Map:Load("Maps\\start.map") Quote Link to comment Share on other sites More sharing options...
ZeroByte Posted March 2, 2013 Share Posted March 2, 2013 Just wanted to say thank's for this awesome documentation Chris, so far it's answered all my questions! Quote Win 7 64, LE 2.31, Liquid Cooled I7-960 @ 4.00GHz, 6GB DDR3 Ram @ 1600mhz, BFG GTX295, Sound Blaster X-FI. Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 2, 2013 Share Posted March 2, 2013 How do i de-attach scripts from objects in the editor? Thanks Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 2, 2013 Author Share Posted March 2, 2013 How do i de-attach scripts from objects in the editor? Thanks Andy In the Scene browser click on the object that has the script attached to it, right click on the script tab (example if the script is called animationmanager the tab will be called animationmanager) then chose delete. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 2, 2013 Share Posted March 2, 2013 Awesome handfull new shader I have some problem to understand that bit of code : function EnemyForEachEntityInAABBDoCallback(entity,extra) if extra.goblinai.target==nil then if extra~=entity then if entity.player~=nil then extra.goblinai.target=entity.player end end end end What is goblinai ? the name of script file ? target is the global variable in this script instance ? Why having all that tests why not directly do : extra.goblinai.target=entity.player caus extra will always be an entity passed throught the function ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
MCP Posted March 2, 2013 Share Posted March 2, 2013 A couple of Android queries: 1) Will it be possible to change the build target from the default to 4.x.x Jellybean for instance? 2) Will it be possible to incorporate the Google licensing api if required? 3) If needs be am I free to modify the android manifest? Thanks. Quote "If our brains were simple enough for us to understand them, we'd be so simple that we couldn't." - Ian Stewart 1995. Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 2, 2013 Author Share Posted March 2, 2013 Awesome handfull new shader I have some problem to understand that bit of code : function EnemyForEachEntityInAABBDoCallback(entity,extra) if extra.goblinai.target==nil then if extra~=entity then if entity.player~=nil then extra.goblinai.target=entity.player end end end end What is goblinai ? the name of script file ? target is the global variable in this script instance ? Why having all that tests why not directly do : extra.goblinai.target=entity.player caus extra will always be an entity passed throught the function ? Quick Answer: goblinai is the name of the script attached to the goblin entity. The declaration of target was actually a slip up on my part, it should have been declared at the top of the script as Script.target = nil. This brings up a good point on how flexible Lua is (which can get you into trouble sometimes) since self.target is not declared anywhere, when something is assigned to it lua creates the variable on the fly. It will not be global because of the prefix "self". Long Answer: To fully understand this code you have to look at these two chunks of code: --Check for a new target in the area if not self.target then if time-self.lastCheckForTargetTime>500 then self.lastCheckForTargetTime=time local position = self.entity:GetPosition(true) local aabb = AABB() aabb.min.x=position.x-self.sightRadius aabb.min.y=position.y-self.sightRadius aabb.min.z=position.z-self.sightRadius aabb.max.x=position.x+self.sightRadius aabb.max.y=position.y+self.sightRadius aabb.max.z=position.z+self.sightRadius aabb:Update() self.entity.world:ForEachEntityInAABBDo(aabb,"EnemyForEachEntityInAABBDoCallback",self.entity) if self.target then self.entity:EmitSound(self.sound.attack[math.random(0,#self.sound.attack)]) self.currentState=self.state.chase self.entity:Follow(self.target.entity,self.speed,self.maxaccel) --self.entity:SetMass(self.mass) self.followingTarget=true end end end and function EnemyForEachEntityInAABBDoCallback(entity,extra) if extra.goblinai.target==nil then if extra~=entity then if entity.player~=nil then extra.goblinai.target=entity.player end end end end Basically if the goblin does not have a target assigned an AABB (axis aligned bounding box) is created around the goblin with a height, width, and depth of the goblins sight radius. self.entity.world:ForEachEntityInAABBDo(aabb,"EnemyForEachEntityInAABBDoCallback",self.entity) The foreachentityinaabbdo function is then called on the newly created aabb. The call back function name "EnemyForEachEntityInAABBDoCallback" is passed in as parameter 2, this means that for every entity within the aabb the callback function "EnemyForEachEntityInAABBDoCallback" will be called. Finally parameter 3 is self.entity which in this case refers to the specific goblin model that the script is attached to. Now the function "EnemyForEachEntityInAABBDoCallback(entity,extra)" extra is the extra passed in from earlier (the goblin model) and entity an entity that that is within the aabb. if extra.goblinai.target==nil then extra is the passed parameter, which was self.entity (the goblin model), goblinai is the specific script attached to the goblin model and target is the variable (which was sloppily created on the fly, my bad). if extra~=entity then You are trying to only find entites with a player script attached. So you begin by making sure that the entity in this call is not the goblin who the aabb is around. if entity.player~=nil then extra.goblinai.target=entity.player end finally if the entity found is not the goblin and has a player script attached (entity.player~= nil) then the goblin's target is the new entity that is found. extra.goblinai.target=entity.player would not work because the entity that is passed in is not guaranteed to have a player script attached. Wow this was a long winded answer, hopefully it helps a little. I can gladly explain / clarify any specific sections of code. Quote Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 2, 2013 Author Share Posted March 2, 2013 A couple of Android queries: 1) Will it be possible to change the build target from the default to 4.x.x Jellybean for instance? 2) Will it be possible to incorporate the Google licensing api if required? 3) If needs be am I free to modify the android manifest? Thanks. I'm going to have to deffer these to Josh. Quote Link to comment Share on other sites More sharing options...
MCP Posted March 2, 2013 Share Posted March 2, 2013 No problems Chris. Thanks for your help so far. Quote "If our brains were simple enough for us to understand them, we'd be so simple that we couldn't." - Ian Stewart 1995. Link to comment Share on other sites More sharing options...
YouGroove Posted March 2, 2013 Share Posted March 2, 2013 Thanks a lot Chris The code is lot more clear , now to understand. yes extra was confusing. self.entity.world world means the word where is the entity goblin ? the level map ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
CopperCircle Posted March 3, 2013 Share Posted March 3, 2013 Hi, just tried to import a .obj but it does not show up in the assets, it copies the file into the project ok?. Importing .fbx seems to work fine. Quote Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 3, 2013 Author Share Posted March 3, 2013 Hi, just tried to import a .obj but it does not show up in the assets, it copies the file into the project ok?. Importing .fbx seems to work fine. Currently we only support the fbx file format. Here is a link to a free autodesk obj to fbx converter: http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=20481519 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 3, 2013 Share Posted March 3, 2013 Hi, how to set up an object to only detect a collision? I have tried the "trigger" option which works fine until I save it as a prefab and then use the prefab which results in a physical collision... Quote Link to comment Share on other sites More sharing options...
Guest Red Ocktober Posted March 3, 2013 Share Posted March 3, 2013 how does the LE3 editor handle lighting of imported LE2 .gmfs with multiple materials ? they look ok when in textured mode, but turn grey when lit... disregard... figured it out... whoever said that the new editor made some things easy wasn't kidding... maybe too easy... --Mike Quote Link to comment Share on other sites More sharing options...
Admin Posted March 3, 2013 Share Posted March 3, 2013 Hi, how to set up an object to only detect a collision? I have tried the "trigger" option which works fine until I save it as a prefab and then use the prefab which results in a physical collision... That doesn't sound like it's working right... Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 3, 2013 Share Posted March 3, 2013 Okay, Hope it's an easy fix! Quote Link to comment Share on other sites More sharing options...
shadmar Posted March 3, 2013 Share Posted March 3, 2013 Hi What is required from custom meshes to be able to use lightmap properly? I have a second uv channel and texture3 points to lightmap.tex, but I can't do it. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2013 Share Posted March 3, 2013 I tested even having one UV only, i thaught LE 3 would create a second UV but nope. Lightmapping only works on BSP. And if it worked on models, how would we do if we had normap map shader ? could lightmapping work with it ? It's really complicated i think. If you need shadows, you'll have to wait fro some next update , than not use BSP, but models with shaders and shadows, i thinks they will be the two main ways of LE 3 : BSP + lightmaps Models + shaders + shadows Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2013 Share Posted March 3, 2013 How to the more simply possible : It's for some shooting example basic tutorial on space ship that can shoot others : - Create a model or an array of models at runtime by Lua programming - make it non collision and invisible - switch to collision and visible - move it to a point (i think i knwo how to do) - on collision : detect what entity is hit - make the model invisible , non collision - keep the model to reuse it (like position on y = -1000) - and at least remove it from the scene and memory (like game finished and return to menu) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2013 Share Posted March 3, 2013 I have noather question : I have that code in App.lua : local camera = Camera:Create() camera:SetRotation(35,0,0) camera:Move(0,0,-30) It is possible to access to that camera from another script file attached to a character ? like simpleAI.lua ? the camera is already global, because nto declared with self.camera ? os i should be able to use it anywhere ? My calera is created in App.lua And this code on simpleAI.lua attached ot a character don't work : self.entity:GoToPoint(20,0,-15,1.4,1); camera:Move(self.entity:getPosition().x,0,-30) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted March 3, 2013 Share Posted March 3, 2013 Remove the "local" and the variable will be global, and can be accessed from anywhere: camera = Camera:Create() We always use local variables or table values to avoid any problems of scripts using the same variable names. Hi What is required from custom meshes to be able to use lightmap properly? I have a second uv channel and texture3 points to lightmap.tex, but I can't do it. You'll need to generate the lightmap data in another program until terrain is officially supported. The engine uses dynamic lighting for models and lightmaps for brushes, like the Source Engine does. I would just rely on dynamic lighting for now, personally. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 3, 2013 Share Posted March 3, 2013 When using the 3rdPersonCam script how do i set the target in the editor? Thanks Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2013 Share Posted March 3, 2013 It's in the code that you must detect goblins and set a target or directly set the target to some point in the space. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 3, 2013 Share Posted March 3, 2013 Where in the 3rdPersonFollow script does it set it to goblin? And why would the target be goblin when it would be the barbarian? Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted March 3, 2013 Share Posted March 3, 2013 I don't think this code is valid ? It don't contain any camera declaration ? IF you attach this script to your character it won't work caus it is script to attacha camera it seems. And camera are not an object you can pick up in the scene, so you can't bind it it seems. Perhaps i'm wrong ? Why not coding your own camera until some good camera template appears ? 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.