• help with lua in derma
    3 replies, posted
I need help adding a derma menu and a few functions to it. [url]http://www.garrysmod.org/downloads/?a=view&id=99724[/url] This is a plant that grows and once at the last stage, can be harvested to get a entity. I want to change it a little bit, at the last stage when you click on it, i want it to open a little derma UI with 2 buttons. One who harvest it(the original function that already is there) And a second button that sells it and give you X amount cash. once one of the buttons are clicked, the window disappear and you get one of those two things and the plant does the original function which is going back to the first stage before seed is added. This is for darkRP. This is how i want it to look, i think the code have to be changed a little bit. I want the derma window to popup in the middle of the screen local DButton5 local DButton4 local DFrame3 DButton5 = vgui.Create('DButton') DButton5:SetSize(100, 25) DButton5:SetPos(0, 50) DButton5:SetText('Sell') DButton5.DoClick = function() end DButton4 = vgui.Create('DButton') DButton4:SetSize(100, 25) DButton4:SetPos(0, 25) DButton4:SetText('Harvest') DButton4.DoClick = function() end DFrame3 = vgui.Create('DFrame') DFrame3:SetSize(100, 79) DFrame3:SetPos(0, 0) DFrame3:SetTitle('Options') DFrame3:SetSizable(true) DFrame3:SetDeleteOnClose(false) DFrame3:MakePopup()
To center the DFrame, use this [lua] local wide = 100 local tall = 79 DFrame3:SetSize(wide, tall) DFrame3:SetPos( (ScrW() - wide) * 0.5, (ScrH() - tall) * 0.5 ) [/lua]
[QUOTE=_nonSENSE;23124135]To center the DFrame, use this [lua] local wide = 100 local tall = 79 DFrame3:SetSize(wide, tall) DFrame3:SetPos( (ScrW() - wide) * 0.5, (ScrH() - tall) * 0.5 ) [/lua][/QUOTE] or you could use [b][url=http://wiki.garrysmod.com/?title=Panel.Center]Panel.Center [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=|King Flawless|;23124160]or you could use [B][URL="http://wiki.garrysmod.com/?title=Panel.Center"]Panel.Center [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B][/QUOTE] Thank you, I learn each and every day :smile:
Sorry, you need to Log In to post a reply to this thread.