Slimwaffle Posted October 6, 2018 Share Posted October 6, 2018 Hey guys. I need help on this one. I am trying to create a script for storage containers in my game. So far I can walk up to the container, Press Use and it launches a GUI. But for some reason I can't get the button to work. I can click on the button. But it doesn't process button events. To print the command to the system. I will paste my code below. test1 = 0 function Storage() local Storage={} local scale = 1 --GUI gui = GUI:Create(context) gui:SetScale(scale) local widget Storage.gui=gui Storage.context = context gui:GetBase():SetScript("Scripts/GUI/Panel.lua") Storage.but1 = Widget:Button("Testing",10,20,80,30,gui:GetBase()) gui:Hide() function Storage:Update() self:ProcessEvent(Event(Event.WidgetAction)) while EventQueue:Peek() do local event = EventQueue:Wait() if self:ProcessEvent(event)==false then return false end end return true end function Storage:ProcessEvent(event) if event.id == Event.WidgetSelect then elseif event.id == Event.WidgetAction then if event.source == self.but1 then System:Print("Button Working") end end return true end return Storage end function Script:Start() Storage() end function Script:Use() test1 = 1 gui:Show() Time:Pause() mlook = 1 context:GetWindow():ShowMouse() end Quote Link to comment Share on other sites More sharing options...
Einlander Posted October 9, 2018 Share Posted October 9, 2018 On 10/6/2018 at 12:26 AM, slimwaffle said: if event.source == self.but1 then replace that line with this if event.source == Storage.but1 then Your Storage variable was created as a global variable. It is not local to the script that created it. Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted October 9, 2018 Author Share Posted October 9, 2018 17 minutes ago, Einlander said: replace that line with this if event.source == Storage.but1 then Your Storage variable was created as a global variable. It is not local to the script that created it. I did this but the button still isn't printing to the system. 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.