ParaToxic Posted May 29, 2014 Share Posted May 29, 2014 Hey guys after a long break I want to create a new little game and learn a bit about scripting in lua. I want to create a 2D HUD entitie with a script that for example draws "Press the F key to..." if I collide with a Collider. But I realized that I cant use the AddHook function inside of an object. How can I use drawing functions like DrawText in the objects script ?? Thanks Quote Link to comment Share on other sites More sharing options...
josk Posted May 29, 2014 Share Posted May 29, 2014 In your object script there should be a PostRender function function Script:PostRender(context) App.context:SetBlendMode(Blend.Alpha) App.context:SetColor(0,1,0,1.0) App.context:DrawText("Value: "..self.val, 100, 100) App.context:SetBlendMode(Blend.Solid) end Quote Elite Cobra Squad Link to comment Share on other sites More sharing options...
Rick Posted May 29, 2014 Share Posted May 29, 2014 @josk I think you can just use the passed in variable 'context'. self.context and context would be different variables where if the context variable doesn't work then it's a bug. Quote Link to comment Share on other sites More sharing options...
josk Posted May 29, 2014 Share Posted May 29, 2014 So you can, learn something new every day. Thanks. Quote Elite Cobra Squad Link to comment Share on other sites More sharing options...
Admin Posted May 29, 2014 Share Posted May 29, 2014 In your object script there should be a PostRender function function Script:PostRender(context) App.context:SetBlendMode(Blend.Alpha) App.context:SetColor(0,1,0,1.0) App.context:DrawText("Value: "..self.val, 100, 100) App.context:SetBlendMode(Blend.Solid) end Keep in mind that App.context might not exist, if the script is running in a C++ program. So it's best to just use the function argument context. 1 Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted May 29, 2014 Author Share Posted May 29, 2014 Oh sorry I didn't mention that I use Leadwerks Engine 2...:/ 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.