• Render library not working for STool
    2 replies, posted
Hi First of all, I'm new to Lua coding so bear with me. I'm trying to make a simple mod that draws the direction vectors for any entity you click on with an sTool. Everyting is ok until I get to the actual rendering; it renders nothing. Here's the Draw function I hooked to PostDrawOpaqueRenderables [lua] if(CLIENT) then hook.Add("PostDrawOpaqueRenderables","VectorRender", function() if (table.Count(PropsWithRender)==0) then return end for i, ent in pairs(PropsWithRender) do render.DrawBox( ent:GetPos(), ent:GetAngles(), Vector( -32, -32, -32), Vector( 32, 32, 32 ) , Color( 0, 255, 0, 255 ), false) end end) end [/lua] That box is not the final render, just trying to draw something. I bet it's just a scope problem, but I'm lost. Thanks in advance :)
Put print("test")s in the code and see which parts are executed and which are not.
Thanks for the response. Well, for your information, the array PropsWithRender and its index are defined filewise but shared. If I add the hook if(CLIENT), like the original, it calls the function but reads Propswithrender as empty. That's why it isnt rendering. If I go if(SERVER), the array is properly read but well, render library is clientside. I'll try defining the array elsewhere. EDIT1: Well it turns out it works if I create a multiplayer game. Half the code isn't working for single player, no idea why. EDIT2: Ok, I could render my vectors succesfully. Still can't make it work on singleplayer and still has some bugs, but thats another subject. Thanks!
Sorry, you need to Log In to post a reply to this thread.