onaid Posted July 9, 2016 Share Posted July 9, 2016 hi all , am having some trouble with the drawtext.lua . I have attached a trial project where there are two collision triggers and two drawtext pivots also two delay triggers. what i want to achieve is when player walks into first trigger the first text is displayed, then off. when player walks into second trigger , second text is displayed, then delay trigger turns it off. each draw text, and collision has a delay trigger to turn off text and disable collision trigger. pretty straight forward stuff right ? well what is happening is both drawtext pivots are showing up ? like each time the drawtext.lua is called its displaying both text at same time ? so even if i only collide with first trigger it is also showing second drawtext ? https://drive.google.com/open?id=0BxWM6ILP8Pf9b2ZwcGtnT3hxT2c https://drive.google.com/open?id=0BxWM6ILP8Pf9VUxBTm0xaWhfWEE Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted July 9, 2016 Share Posted July 9, 2016 The problem is with your Draw Script. Your default is on. So it shows even before you get to the Trigger. You also had the TextConfirm variable set as a global variable. So as soon as it was set for the first text it was also set for the second. The following should work. Script.Text = "Enter Text Here"--String Script.X = 0 --Int "X Position" Script.Y = 0 --Int "Y Position" Script.FontSize = 32 --Int "Font Size" Script.Text_On = false --bool "Default off" --Script.TextConfirm = false function Script:Start() --TextConfirm = self.Text_On self.context = Context:GetCurrent() self.window = self.context:GetWindow() local font = Font:Load("Fonts/Arial.ttf",self.FontSize) self.context:SetFont(font) end function Script:PostRender(context) if (self.Text_On == true) then self.context:SetBlendMode(Blend.Alpha) self.context:SetColor(1,1,1) self.context:DrawText(self.Text, self.X,self.Y) self.context:SetBlendMode(Blend.Solid) end end function Script:TextOn()--in self.Text_On = true end function Script:TextOff()--in self.Text_On = false end Quote Link to comment Share on other sites More sharing options...
onaid Posted July 18, 2016 Author Share Posted July 18, 2016 Thanks very much thirsty panther ! your above script has done the trick cheers mate 1 Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted July 18, 2016 Share Posted July 18, 2016 Happy to help. 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.