• Print

Author Topic: Noob Lua Question  (Read 4858 times)

0 Members and 1 Guest are viewing this topic.

Offline Doomed

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Noob Lua Question
« on: October 13, 2013, 10:36:33 am »
So I'm quiet new with lua, but there's 1 thing i'm currently having problems with: I can't get the spawn menu to be enabled. I've derived it from sandbox, so there's no problem there. I also added this to init.lua:(might be wrong though)

Code: [Select]
function GM:SpawnMenuEnabled()
return true;
end

Any ideas?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Noob Lua Question
« Reply #1 on: October 13, 2013, 11:06:17 am »
http://wiki.garrysmod.com/page/SANDBOX/SpawnMenuEnabled
Tried SANDBOX:SpawnMenuEnabled ?
(MrPresident is probably one of our most experienced gamemode coders here...I'm sure he'll have more questions to assist you if my suggestion isn't correct.
I've no idea if GM in a Sandbox derived gamemode actually becomes 'sandbox')
« Last Edit: October 13, 2013, 11:08:12 am by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Noob Lua Question
« Reply #2 on: October 13, 2013, 01:30:39 pm »
If you are deriving from Sandbox you shouldn't even have to run that function.

The spawn menu should be enabled by default unless you specifically disabled it.

As for the SANDBOX replacing GAMEMODE (or GM), I've never seen this other than just now on the wiki. Also I couldn't find anything in the gamemode's source code to support this either.

Even in the cl_spawnmenu.lua right from the Sandbox gamemode it's

Code: Lua
  1. function GM:SpawnMenuEnabled()
  2.         return true    
  3. end
  4.  

Try removing that function entirely from your code. If the spawnmenu still isn't working, let me know.
« Last Edit: October 13, 2013, 01:32:17 pm by MrPresident »

Offline Doomed

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Noob Lua Question
« Reply #3 on: October 16, 2013, 01:50:50 pm »
Back, sorry if this may be a semi-bump, but I finally fixed it! :D Turns out  I manually had to write
Code: [Select]
DeriveGamemode( "sandbox" ) in shared.lua. Putting
Code: [Select]
"base" "sandbox" in gamemode.txt didn't do anything.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Noob Lua Question
« Reply #4 on: October 16, 2013, 05:18:34 pm »
I could have told you that. :P

Yeah, make sure you're deriving your gamemode properly and you should be fine.

  • Print