Alienhead Posted January 14 Share Posted January 14 Placing this code in my main.lua ( before my main loop ) works fine. But if I move the code to my component's Start:Method() nothing shows up. I'm positive its something Im doing wrong.. but Im puzzled as to what it could be. I need a nudge ! function randomFloat(lower, greater) return lower + math.random() * (greater - lower); end misc.lua: ( just a require-module with a bunch of home brew routines in it. ) local amt = 10 crows = {} for t=1, amt do crows[t] = CreateBox(world) crows[t]:SetPosition(randomFloat(-2,0, 2.0), 2.0, randomFloat(-2.0, 2.0) ) end Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
SpiderPig Posted January 14 Share Posted January 14 2 minutes ago, Alienhead said: -2,0 My first obvious observation. Might just be a typo in the post Quote Link to comment Share on other sites More sharing options...
Alienhead Posted January 14 Author Share Posted January 14 Ahhh i didn't see that typo.. and I was sure hoping that was it.. but correcting it still yields nothing. Thanks though. Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
SpiderPig Posted January 14 Share Posted January 14 Have you checked to make sure start() is actually being called? Maybe a print or notify in there just to be sure that's not the issue? Quote Link to comment Share on other sites More sharing options...
Alienhead Posted January 14 Author Share Posted January 14 Yup it's getting called, placing this code in the Start() method hides the transparent box. ( as it should ) self.entity:SetHidden(true) 1 Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Solution SpiderPig Posted January 14 Solution Share Posted January 14 I can't see anything else wrong with your code but I'm no lua expert so I'm just rattling off things that might help now... world not null? 2 Quote Link to comment Share on other sites More sharing options...
Alienhead Posted January 14 Author Share Posted January 14 Heh, you just nailed it.. local world = CreateWorld() in the main.lua. I've been messing with LE and lua for to long to let that one slip by hehe, but then again we never had to call the world in LE when creating AN OBJECT. ::>?) TY ! 1 Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
SpiderPig Posted January 14 Share Posted January 14 Yes I've been called out with that one too. Glad it's fixed! 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted January 14 Share Posted January 14 If this code is in a component, you probably want to get the world like this: local world = self.enttty:GetWorld() Maybe you need to pass that to a function, but that is a little better than relying on a global variable. 1 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...
Alienhead Posted January 14 Author Share Posted January 14 These are the positions my World:Pick is giving me.. everyone of them are off by some weird amount. I've got to quit for a few days, I'm to frustrated to get anything accomplished. for t=1, self.Amount do local piv = CreatePivot(world) ; piv:SetHidden(true) local c = crow:Instantiate(world) ; c:SetPickMode(PICK_NONE) local pick_info = nil while pick_info == nil do c:SetPosition(self.entity:GetPosition()) c:Move(randomFloat( -(self.aabb.size.x/2),(self.aabb.size.x/2)) , self.aabb.size.y/2, randomFloat(-(self.aabb.size.z/2),(self.aabb.size.z/2))) piv:SetPosition(c:GetPosition()) piv:Translate(0,-50,0) pick_info = world:Pick(c:GetPosition(true), piv:GetPosition(true), .25, true) if pick_info ~= nil then piv:SetPosition(pick_info.position) c:SetPosition(pick_info.position) end end table.insert( self.crows, { piv = piv, mesh = c, }) end Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Josh Posted January 14 Share Posted January 14 I can try it out if you would like. 1 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...
Alienhead Posted January 14 Author Share Posted January 14 Sure Josh, I'll send it up. Quote I'm only happy when I'm coding, I'm only coding when I'm happy. 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.