AggrorJorn Posted December 26, 2009 Share Posted December 26, 2009 I have copied the firepit code to my own firepit. The code is besides some default value exactly the same. However when you run the code you get the message : Table index is nill. Also the class.lua is opened with the line selected: classtable[modelreference]=class. The object appears to be working normally but I wonder what the error message means. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 26, 2009 Share Posted December 26, 2009 This indicates the modelreference value equals nil. 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...
Rick Posted December 26, 2009 Share Posted December 26, 2009 You'll have to show your code and then we may be able to see what's happening. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 26, 2009 Author Share Posted December 26, 2009 The firepit code: require("scripts/class") local class=CreateClass(...) class.sound=LoadSound('abstract::campfire_01_15.wav') function class:CreateObject(model) local object=self.super:CreateObject(model) object.model.aabb.x0=-5 object.model.aabb.x1=5 object.model.aabb.y0=-5 object.model.aabb.y1=5 object.model.aabb.z0=-5 object.model.aabb.z1=5 --Create light object.light=CreatePointLight(4,model) object.light:SetColorf(1,0.6,0.25,1,1) object.light:SetPositionf(0,0.8,0,0) object.light:SetShadowOffset(0,0.91,0) object.light:SetShadowmapSize(1024) --Create emitters if world_transparency~=nil then if world_main~=nil then SetWorld(world_transparency) object.heathaze=CreateEmitter(10,4500,Vec3(0,1,0),0,object.model) object.heathaze:SetPositionf(-136,52,-662,0) object.material_heathaze=LoadMaterial('abstract::heathaze.mat',0) object.heathaze:Paint(object.material_heathaze,0) object.heathaze:SetRadius(0.25,0.25) object.heathaze:SetWaver(1) object.heathaze:SetOrder(1,0) object.heathaze:SetVelocity(Vec3(0,0.375,0),Vec3(0,0.05,0)) object.heathaze:SetRotationSpeed(0.05) object.heathaze:SetArea(Vec3(0.2,0.0,0.2)) object.heathaze:SetPositionf(0,0.50,0,0) object.fire=CreateEmitter(25,750,Vec3(0,1,0),0,object.model) object.fire:SetPositionf(0,0.25,0,0) object.fire:Paint(LoadMaterial('abstract::fire.mat'),0) object.fire:SetRadius(0.4,0.1) object.fire:SetColorf(0.2,0.2,0.2,1,1) object.fire:SetWaver(1) object.fire:SetVelocity(Vec3(0,1.5,0),Vec3(0,0.05,0)) object.fire:SetRotationSpeed(0.01) object.fire:SetArea(Vec3(0.2,0.1,0.2)) object.sparks=CreateEmitter(5,800,Vec3(0,1,0),0,object.model) object.sparks:Paint(LoadMaterial('abstract::fire.mat'),0) object.sparks:SetRadius(0.01,0.01) object.sparks:SetColorf(1,0.6,0.25,1,1) object.sparks:SetVelocity(Vec3(0,1.5,0),Vec3(0.05,0.5,0.05)) object.sparks:SetRotationSpeed(0.1) object.sparks:SetArea(Vec3(0.4,0.0,0.4)) object.sparks:SetWaver(5) object.sparks:SetPositionf(0,0.25,0,0) SetWorld(world_main) end end --Emit fire sound if class.sound~=nil then object.model:EmitSound(class.sound,10,1,1) end --Declare initial values object.fluctuation=100.0 object.smoothedfluctuation=5.0 function object:SetKey(key,value) if key=="color" then elseif key=="intensity" then else return self.super:SetKey(key,value) end return 1 end --Force the bounding box to be bigger function object:UpdateMatrix() object.model.aabb.x0=object.model.mat.tx-5 object.model.aabb.x1=object.model.mat.tx+5 object.model.aabb.y0=object.model.mat.ty-5 object.model.aabb.y1=object.model.mat.ty+5 object.model.aabb.z0=object.model.mat.tz-5 object.model.aabb.z1=object.model.mat.tz+5 object.model.aabb:Update() end function object:GetKey(key,value) if key=="color" then elseif key=="intensity" then else return self.super:GetKey(key,value) end return value end function object:Render() self.fluctuation=self.fluctuation+math.random(-100,100)/1000.0*AppSpeed() self.fluctuation=math.min(2.2,self.fluctuation) self.fluctuation=math.max(0.2,self.fluctuation) self.smoothedfluctuation=Curve(self.fluctuation,self.smoothedfluctuation,5.0/AppSpeed()) self.light:SetColorf(1.0*self.smoothedfluctuation,0.6*self.smoothedfluctuation,0.25*self.smoothedfluctuation,1,0) end end Quote Link to comment Share on other sites More sharing options...
Rick Posted December 26, 2009 Share Posted December 26, 2009 When do you get this error? Do you get it when you save the script and only 1 time after every save of the script? Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 26, 2009 Share Posted December 26, 2009 my guess is he is hitting the 'run script' button... which since this isn't a 'game script', he shouldn't be trying to RUN it... 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...
AggrorJorn Posted December 26, 2009 Author Share Posted December 26, 2009 it doesn't appear when saving. It happens when I press run. I normally press run to update the file so that every instance in the scene gets the new code. I could use the save button and nothing is wrong. I just wonderd what happens with the code when I run the script (F5). It does this every time I run it. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 26, 2009 Share Posted December 26, 2009 it doesn't appear when saving. It happens when I press run. I normally press run to update the file so that every instance in the scene gets the new code. I could use the save button and nothing is wrong. I just wonderd what happens with the code when I run the script (F5). It does this every time I run it. that worked for multi-state... it doesn't appear to work for single state... if anything it causes problems. 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...
Josh Posted December 27, 2009 Share Posted December 27, 2009 If you just save the script every instance in the scene will be freed (with the old script) and reloaded (with the new script). You should not run a class script. 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...
Rick Posted December 27, 2009 Share Posted December 27, 2009 Oh he is running just this one script and not running the game mode. Yeah, running one object script by itself isn't how you go about it. Quote 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.