when coding for a new game mode (was following a tutorial on the basics, made my own stuff with that knowledge) and i was working on GUI. then this happened
[ERROR] gamemodes/spooky ghosts/gamemode/cl_init.lua:73: unexpected symbol near '='
1. unknown - gamemodes/spooky ghosts/gamemode/cl_init.lua:0
Couldn't Load Init Script: 'spooky ghosts/gamemode/cl_init.lua'
I thought the second error was a effect of the first so i tried to fix the first and disasters ensured
all i know is that the code doesn't work and i need massive help. I'm new to lua coding and basically coding in general. please help!
(what i was trying to do was have the GUI change based on what team you where on)
[QUOTE]AddCSLuaFile( "cl_init.lua" )
include( 'shared.lua' )
Toobles ()
Toobles[1] = "Ghost Hunters"
Toobles[2] = "Spooky Seekers"
Toobles[3] = "Spooky Ghosts"
for i=1, 3 do
Msg("You are now on the "..Toobles[i].."Team \n")
end
function HUDHide( myhud )
for k, v in pairs{"CHudHealth","CHudBattery", "CHudAmmo","CHudSecondaryAmmo"} do
if myhud == v then return false end
end
end
hook.Add("HUDShouldDraw", "HUDHide", HUDHide)
function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()
local HP = LocalPlayer():Health()
surface.CreateFont("MyFont", 30, 250,false, false,"ScoreboardText")
surface.SetTextColor(255,255,255, 255)
surface.SetTextPos(80, ScrH()- 205)
surface.SetFont( "MyFont" )
surface.DrawText( HP )
end
function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()
local Ammo = LocalPlayer():GetAmmoCount()
surface.CreateFont("MyFont", 30, 250,false, false,"ScoreboardText")
surface.SetTextColor(255,255,255, 255)
surface.SetTextPos(80, ScrH()- 105)
surface.SetFont( "MyFont" )
surface.DrawText( Ammo )
end
function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()
surface.CreateFont("MyFont", 30, 250,false, false,"ScoreboardText")
surface.SetTextColor(255,255,255, 255)
surface.SetTextPos(150, ScrH()- 250)
surface.SetFont( "MyFont" )
surface.DrawText( ply:Team() )
end
function BarHUD1()
local ply = LocalPlayer()
local HP = ply:Health()
local Ammo = ply:GetAmmoCount()
draw.RoundedBox( 8, 80, ScrH()- 200, 200, 30, Color(40,40,40,180))
draw.RoundedBox( 8, 80, ScrH()- 200, math.Clamp( HP, 0, 200 )*2, 40, Color(255,0,0,255))
end
function BarHUD2()
local ply = LocalPlayer()
local Ammo = ply:GetAmmoCount()
draw.RoundedBox( 8, 80, ScrH()- 100, 200, 30, Color(40,40,40,180))
draw.RoundedBox( 8, 80, ScrH()- 100, math.Clamp( Ammo, 0, 200 )*2, 40, Color(0,0,255,255))
end
function BgHUD()
local ply = LocalPlayer()
local plyT = LocalPlayer():Team()
local TColorRed = 0
local TColorGreen = 0
local TColorBlue = 0
if plyT == 1 then TColorRed = 255 and TColorGreen = 0 and TColorBlue = 0 [B]<------------------------------------------------------------------------- This is line 73[/B]
elseif plyT == 2 then TColorRed = 51 and TColorGreen = 102 and TColorBlue = 255
elseif plyT == 3 then TColorRed = 255 and TColorGreen = 255 and TColorBlue = 255
elseif plyT == 4 then TColorRed = 122 and TColorGreen = 122 and TColorBlue = 122
end
draw.RoundedBox( 8, 50, ScrH()- 250, 300, 200, Color(40,40,40,180))
draw.RoundedBox( 14, 150, ScrH()- 250, 200 , 20, Color(TColorRed,TColorGreen,TColorBlue)
end
end[/QUOTE]
Use [ code] tags. Also whitespace, you need to put l lots of whitespace in that code. [code]if plyT == 1 then TColorRed = 255 and TColorGreen = 0 and TColorBlue = 0[/code]
There is no need for the ands there, but with whitespace it should also look like.
[code]
if plyT == 1 then
TColorRed = 255
TColorGreen = 0
TColorBlue = 0
else.....
[/code]
-snip-
actually, there's a lot more wrong with that code than just line 73.
It almost seems as though you're trying to use a ternary without using a ternary... It would also help if you tabbed your code.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/logic/ternary_operations.lua.html[/url]
Or, if you're trying to set all 3 vars in a line. But this is done using commas, not "and"s.
[code]// Define them...
local TColorRed, TColorGreen, TColorBlue = 0, 0, 0;
if ( plyT == 1 ) then
TColorRed, TColorGreen, TColorBlue = 255, 0, 0; -- Or just set 1 since we defined all as 0.
end[/code]
[QUOTE=mcd1992;46040134]Use [ code] tags. Also whitespace, you need to put l lots of whitespace in that code. [code]if plyT == 1 then TColorRed = 255 and TColorGreen = 0 and TColorBlue = 0[/code]
There is no need for the ands there[/quote]
He could define them on new lines; but you're right, the ands do not serve a purpose because he's trying to define multiple vars on one line which is done using commas.
[QUOTE=Mors Quaedam;46040136]Please use [noparse][code][/code][/noparse] tags next time.
-snipped-[/QUOTE]
He's trying to set the variables, not test them. There are also 2 "then"s in that, and 1 = for red.
Thanks for helping me fix this disaster. im brand new and didnt know where to start.
[QUOTE=Acecool;46040139]It almost seems as though you're trying to use a ternary without using a ternary... It would also help if you tabbed your code.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/logic/ternary_operations.lua.html[/url]
Or, if you're trying to set all 3 vars in a line. But this is done using commas, not "and"s.
[code]// Define them...
local TColorRed, TColorGreen, TColorBlue = 0, 0, 0;
if ( plyT == 1 ) then
TColorRed, TColorGreen, TColorBlue = 255, 0, 0; -- Or just set 1 since we defined all as 0.
end[/code]
He could define them on new lines; but you're right, the ands do not serve a purpose because he's trying to define multiple vars on one line which is done using commas.
He's trying to set the variables, not test them. There are also 2 "then"s in that, and 1 = for red.[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.