Jump to content

drawtext.lua issue


onaid
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...