• Print

Author Topic: I lost my touch can you fix this?  (Read 4326 times)

0 Members and 1 Guest are viewing this topic.

Offline gnode

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
  • programmer
    • STEAM
I lost my touch can you fix this?
« on: May 04, 2016, 08:12:39 pm »
Code: Lua
  1. function TEAM_MENU()
  2.         local TEAM_MENU = vgui.Create("DFrame", TEAM_MENU)
  3.         TEAM_MENU:SetSize(888, 474)
  4.         TEAM_MENU:SetTitle("ThePod")
  5.         TEAM_MENU:Center()
  6.         TEAM_MENU:SetVisible(true)
  7.         TEAM_MENU:SetDraggable(true)
  8.         TEAM_MENU:ShowCloseButton(true)
  9.         TEAM_MENU:SetSizable(true)
  10.         TEAM_MENU:SetBackgroundBlur(true)
  11.         TEAM_MENU:MakePopup()
  12.         TEAM_MENU.Paint = function()
  13.                 draw.RoundedBox(8, 0, 0, TEAM_MENU:GetWide(), TEAM_MENU:GetTall(), Color(61, 52, 52, 255))
  14.         end
  15.        
  16.         local TEAM_HUMANS = vgui.Create("DPanel", TEAM_MENU)
  17.         TEAM_HUMANS:SetPos(25, 50)
  18.         TEAM_HUMANS:SetSize(250, 250)
  19.         TEAM_HUMANS:SetText("Humans")
  20.         TEAM_HUMANS.DoClick = function()
  21.                 RunConsoleCommand("TEAM_HUMANS")
  22.         end
  23.         TEAM_HUMANS.Paint = function()
  24.                 draw.RoundedBox(8, 0, 0, TEAM_HUMANS:GetWide(), TEAM_HUMANS:GetTall(), Color(0, 0, 0, 150))
  25.         end
  26.        
  27.         local TEAM_ALIENS = vgui.Create("DPanel", TEAM_MENU)
  28.         TEAM_ALIENS:SetPos(280, 50)
  29.         TEAM_ALIENS:SetSize(250, 250)
  30.         TEAM_ALIENS:SetText("Humans")
  31.         TEAM_ALIENS.DoClick = function()
  32.                 RunConsoleCommand("TEAM_ALIENS")
  33.         end
  34.         TEAM_ALIENS.Paint = function()
  35.                 draw.RoundedBox(8, 0, 0, TEAM_ALIENS:GetWide(), TEAM_ALIENS:GetTall(), Color(0, 0, 0, 150))
  36.         end
  37.        
  38.         local TEAM_SPEC = vgui.Create("DPanel", TEAM_MENU)
  39.         TEAM_SPEC:SetPos(535, 50)
  40.         TEAM_SPEC:SetSize(250, 250)
  41.         TEAM_SPEC:SetText("Humans")
  42.         TEAM_SPEC.DoClick = function()
  43.                 RunConsoleCommand("TEAM_SPEC")
  44.         end
  45.         TEAM_SPEC.Paint = function()
  46.                 draw.RoundedBox(8, 0, 0, TEAM_SPEC:GetWide(), TEAM_SPEC:GetTall(), Color(0, 0, 0, 150))
  47.         end
  48. end
  49. concommand.Add("TEAM_MENU", TEAM_MENU)

Offline gnode

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
  • programmer
    • STEAM
Re: I lost my touch can you fix this?
« Reply #1 on: May 04, 2016, 08:17:23 pm »
Sorry for my crappy coding I have been messing around with c++ and c# too much

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: I lost my touch can you fix this?
« Reply #2 on: May 05, 2016, 11:11:21 am »
Can't fix it if you don't tell us what's wrong.

None of us here are servants. We'll help, but most of us aren't just gonna write code for you (unless it's really simple). What have you tried already? What errors are you getting, if any? What behavior are you expecting, and what behavior are you getting?
bw81@ulysses-forums ~ % whoami
Homepage

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: I lost my touch can you fix this?
« Reply #3 on: May 09, 2016, 06:08:46 pm »
I think I might have found your issue.
Code: Lua
  1. function TEAM_MENU()
  2.         local TEAM_MENU = vgui.Create("DFrame", TEAM_MENU)

I noticed here you're making the DFrame reference to itself, so it's trying to attach it to itself before it's even being made.

By my understanding it would instead be
Code: Lua
  1. function TEAM_MENU()
  2.         local TEAM_MENU = vgui.Create("Dframe")
...And then the rest of your stuff.


Can't fix it if you don't tell us what's wrong.

None of us here are servants. We'll help, but most of us aren't just gonna write code for you (unless it's really simple). What have you tried already? What errors are you getting, if any? What behavior are you expecting, and what behavior are you getting?
This is still true. The only reason I helped here (really) is that I found the error quickly :P



(Also, I could be wrong here. I, myself, will admit that I'm not amazing at Lua, but to my knowledge I think that would be the problem.)

Used https://wiki.garrysmod.com/page/Category:DFrame as a reference.
« Last Edit: May 09, 2016, 06:12:28 pm by Masterbinkie »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: I lost my touch can you fix this?
« Reply #4 on: May 09, 2016, 08:48:07 pm »
I think I might have found your issue.
I noticed here you're making the DFrame reference to itself, so it's trying to attach it to itself before it's even being made.

By my understanding it would instead be
Code: Lua
  1. function TEAM_MENU()
  2.         local TEAM_MENU = vgui.Create("Dframe")
...And then the rest of your stuff.

This looks about right. It wouldn't make sense to make a DFrame a child of itself.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

  • Print