Well I've been tyring to make a simple overlayed message that appears on initial spawn, then after 15 seconds will go away
All of the HUD has been completed successfully and worked fine, but when I've tried to link it all together in an autorun file I keep getting the error:
[code]Chunk has too many syntax levels[/code]
Originally I thought it to be that lua was trying to run too much in one block, so I moved my HUD code out of the if client statement, and just had a check ran to make sure it was only client being ran when the HUD was made
Here is my code so far, in the directory, "autorun/PlayerLoadMenu.lua" - and the current error is:
[code][lua\autorun\playerloadmenu.lua:22] chunk has too many syntax levels[/code]
[lua]
local MenuOpen = false
local Info = {"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11"}
if SERVER then
AddCSLuaFile( "autorun/PlayerLoadMenu.lua" )
hook.Add( "PlayerInitialSpawn", "InitialSpawn_JoinScreen", function( ply )
timer.Simple( "3", function() ply:ConCommand("+JoinScreen"); end )
timer.Simple( "15", function() ply:ConCommand("-JoinScreen"); end )
end )
end
if CLIENT then
include( 'autorun/PlayerLoadMenu.lua' )
local GmodLogo = surface.GetTextureID( "console/gmod_logo" )
local Title = "Welcome To '"..GetHostName().."'"
surface.SetFont( "HUDNumber5" )
local TitleSize = surface.GetTextSize( Title )
end
concommand.Add( "+JoinScreen", function() MenuOpen = true; end )
concommand.Add( "-JoinScreen", function() MenuOpen = false; end )
if not CLIENT then return end
function JoinScreen()
if (MenuOpen == true) then
surface.SetDrawColor( 230, 230, 230, 255 )
surface.DrawRect( 0, 0, ScrW(), ScrH() )
draw.WordBox( 4, (ScrW()*0.5)-(TitleSize*0.5), ScrH()*0.1, Title, "HUDNumber5", Color(25,87.5,125,255), Color(255,255,255,255) )
draw.RoundedBox( 4, ScrW()*0.1, ScrH()*0.25, ScrW()*0.8, ScrH()*0.65, Color(50,175,255,255) )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetTexture( GmodLogo )
surface.DrawTexturedRectRotated( ScrW()*0.8, ScrH()*0.75, ScrW()*0.15, ScrH()*0.2, -22.5 )
draw.SimpleText( Info[1], "HUDNumber", ScrW()*0.15, ScrH()*0.32, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[2], "Trebuchet22", ScrW()*0.15, ScrH()*0.35, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[3], "Trebuchet22", ScrW()*0.15, ScrH()*0.375, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[4], "Trebuchet22", ScrW()*0.15, ScrH()*0.4, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[5], "Trebuchet18", ScrW()*0.175, ScrH()*0.425, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[6], "HUDNumber", ScrW()*0.15, ScrH()*0.52, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[7], "Trebuchet22", ScrW()*0.15, ScrH()*0.55, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[8], "Trebuchet22", ScrW()*0.15, ScrH()*0.575, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[9], "Trebuchet24", ScrW()*0.15, ScrH()*0.72, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[10], "Trebuchet24", ScrW()*0.15, ScrH()*0.77, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[11], "Trebuchet24", ScrW()*0.15, ScrH()*0.82, Color(255,255,255,255), 0, 1 )
end
end
hook.Add( "HUDPaint", "JoinScreen", JoinScreen )
[/lua]
timer.Simple takes a number as the first argument, not a string. Lines 22 and 23.
Oh wow, that was stupid of me xD
Thanks for pointing that out, I'll try the code without it in a minute
Sorry for the late bump response, I tried it out without the quotation marks but still got:
[code][lua\autorun\playerloadmenu.lua:26] chunk has too many syntax levels[/code]
Could it be my Info table chunk being too large?
That code is from autorun/PlayerLoadMenu.lua, right? You're including the file inside itself at line 28.
[lua]include( 'autorun/PlayerLoadMenu.lua' )[/lua]
Oh shiz, I have so many nooby mistakes in this code,might aswell rewrite it at some point :P
I'll try that later thanks and post back
To start, thanks for the help both of you for my stupid noobie errors that it turned out this script was full of
Removing the include fixed the syntax error thanks, but also the overlay had not been loading when I ran the console command because of, yep, more noobie errors :)
But I got it fixed, the errors being:
- The MenuOpen variable was shared, not client only
- The console commands were also shared so changing the variable for server and the single client
- And also the HUDPaint just being moved back into the main if (CLIENT) chunk for neatness
Anyone that wants it, the fixed, fully working (In singleplayer :P) code here:
[lua]local Info = {"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11"}
if (SERVER) then
AddCSLuaFile( "autorun/PlayerLoadMenu.lua" )
hook.Add( "PlayerInitialSpawn", "InitialSpawn_JoinScreen", function( ply )
ply:ConCommand("+JoinScreen")
timer.Simple( 15, function() ply:ConCommand("-JoinScreen"); end )
end )
end
if (CLIENT) then
local GmodLogo = surface.GetTextureID( "console/gmod_logo" )
local Title = "Welcome To '"..GetHostName().."'"
surface.SetFont( "HUDNumber5" )
local TitleSize = surface.GetTextSize( Title )
local MenuOpen = false
concommand.Add( "+JoinScreen", function() MenuOpen = true; end )
concommand.Add( "-JoinScreen", function() MenuOpen = false; end )
function JoinScreen()
if (MenuOpen == true) then
surface.SetDrawColor( 230, 230, 230, 255 )
surface.DrawRect( 0, 0, ScrW(), ScrH() )
draw.WordBox( 4, (ScrW()*0.5)-(TitleSize*0.5), ScrH()*0.1, Title, "HUDNumber5", Color(25,87.5,125,255), Color(255,255,255,255) )
draw.RoundedBox( 4, ScrW()*0.1, ScrH()*0.25, ScrW()*0.8, ScrH()*0.65, Color(50,175,255,255) )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetTexture( GmodLogo )
surface.DrawTexturedRectRotated( ScrW()*0.8, ScrH()*0.75, ScrW()*0.15, ScrH()*0.2, -22.5 )
draw.SimpleText( Info[1], "HUDNumber", ScrW()*0.15, ScrH()*0.32, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[2], "Trebuchet22", ScrW()*0.15, ScrH()*0.35, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[3], "Trebuchet22", ScrW()*0.15, ScrH()*0.375, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[4], "Trebuchet22", ScrW()*0.15, ScrH()*0.4, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[5], "Trebuchet18", ScrW()*0.175, ScrH()*0.425, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[6], "HUDNumber", ScrW()*0.15, ScrH()*0.52, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[7], "Trebuchet22", ScrW()*0.15, ScrH()*0.55, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[8], "Trebuchet22", ScrW()*0.15, ScrH()*0.575, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[9], "Trebuchet24", ScrW()*0.15, ScrH()*0.72, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[10], "Trebuchet24", ScrW()*0.15, ScrH()*0.77, Color(255,255,255,255), 0, 1 )
draw.SimpleText( Info[11], "Trebuchet24", ScrW()*0.15, ScrH()*0.82, Color(255,255,255,255), 0, 1 )
end
end
hook.Add( "HUDPaint", "JoinScreen", JoinScreen )
end[/lua]
if (MenuOpen == true) then
Is the same as
if (MenuOpen) then
Just a sidenote.
[QUOTE=Freze;29338469]if (MenuOpen == true) then
Is the same as
if (MenuOpen) then
Just a sidenote.[/QUOTE]
Thanks, but I like it that way so then if I ever forget what I've done, I simply look and see "Ah, if the variable is true which is changed by the concommand then the menu opens..."
But thanks anyway :)
:)
wow this is fucking gay as hell.
[QUOTE=whatafuckingfag;29341371]wow this is fucking gay as hell.[/QUOTE]
Erm, lolwat :P
Sorry, you need to Log In to post a reply to this thread.