randomdude Posted September 4, 2017 Share Posted September 4, 2017 How do I make popup messages? like the player gets into a trigger and than a messages shows up with some text. Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 5, 2017 Author Share Posted September 5, 2017 function Script:Start() self.enabled=false end function Script:Enable()--in if self.enabled==false then self.enabled=true --self:CallOutputs("Enable") local gui = GUI:Create(context) local base = gui:GetBase() base:SetScript("Scripts/GUI/Panel.lua") x=100 y=50 local sep=30 widget = Widget:TextArea(x,y,500,100,base) widget:SetText("This function creates a textarea widget.\n\nA textarea is read-only widget that can display multiple lines of text.") y=y+sep end end function Script:Disable()--in if self.enabled then self.enabled=false --self:CallOutputs("Disable") end end Okay cool, thats fuctional. but how do get only the window with text and the game as background? And how do I get it stopped after a specific time? Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted September 5, 2017 Share Posted September 5, 2017 I personally use my own UI system, so I am not much into the Leadwerks built in UI system, but I can help you with the stopping after a specific time. As far as I understand it you want the message just be displayed for a specific of time don't you? For this simple add a timer, which disables the widget like this: Script.timer = 0 Script.widgetLifeTime = 30 function Script:UpdateWorld() if self.enabled then self.timer = self.timer + Time:GetSpeed() if self.timer >= self.widgetLifeTime then self.timer = 0 self:Disable() end end end But your disable function won't work. I guess you have to release the widget somewhere, but at them moment I dont know how this exactly works with the leadwerks UI, maybe check the Reference for that. I don't get what you mean with: 8 hours ago, randomdude said: but how do get only the window with text and the game as background? Quote Link to comment Share on other sites More sharing options...
Genebris Posted September 5, 2017 Share Posted September 5, 2017 Script.message Script.time = -1000 function Script:PostRender(context) if Time:GetCurrent() > self.time + 10 then return end context:DrawText(self.message, x,y) end function Script:SetMessage(text) self.message = text self.time = Time:GetCurrent() end Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 5, 2017 Author Share Posted September 5, 2017 Okay Thanks. These Timers aren´t working somehow, I tried a lot of variations. Dont know what is wrong. Its either ignored or nothing happens. But this DrawText function is what I need. This here is working correct but the app is stopping. function Script:Start() self.enabled=false end function Script:Enable()--in if self.enabled==false then self.enabled=true --self:CallOutputs("Enable") local text = "Hello!asdasdasdasdasdasdasdasdasd" local font = context:GetFont() local x = window:GetWidth()/2 local y = window:GetHeight()/2 x = x - font:GetTextWidth(text)/2 y = y - font:GetHeight()/2 context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1) context:DrawText(text,x,y) context:Sync() Time:Delay(1000) end end function Script:Disable()--in if self.enabled then self.enabled=false --self:CallOutputs("Disable") end end I tried instead of Time:Delay this timer function but its not working. Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 5, 2017 Author Share Posted September 5, 2017 For people who want to use this, just make two triggers, one enables and one disables. function Script:Start() self.enabled=false end function Script:Enable()--in if self.enabled==false then self.enabled=true end end function Script:PostRender(context) if self.enabled==true then local text = "Hello!" local font = context:GetFont() local x = window:GetWidth()/2 local y = window:GetHeight()/2 x = x - font:GetTextWidth(text)/2 y = y - font:GetHeight()/2 context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1) context:DrawText(text,x,y) end end function Script:Disable()--in if self.enabled then self.enabled=false --self:CallOutputs("Disable") end end Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted September 6, 2017 Share Posted September 6, 2017 Haven't you tried my timer code? There is no built in timer function or something like that. Try that out: Script.timer = 0 Script.widgetLifeTime = 30 function Script:UpdateWorld() if self.enabled then --This is the timer: self.timer = self.timer + Time:GetSpeed() if self.timer >= self.widgetLifeTime then self.timer = 0 self:Disable() end end end You need any function which updates every frame and put that timer code in there. Do NOT put this lines of code into a function which just gets called once. You can for example put this inside the post render function. The "Time:Delay" function freezes your code for a specific amount of time I guess. Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 6, 2017 Author Share Posted September 6, 2017 No it´s not working. https://www.twitch.tv/videos/172707074 It´s not only not working it causes graphic errors. I stick to my trigger version. Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted September 10, 2017 Share Posted September 10, 2017 Hmm weird, maybe the textbox is getting enabled somewhere else, because thats what it looks like. Try to print something inside your postrender function where the textbox is getting rendered, to see if its getting called. 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.