Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

Lua Help


MisterInvalid
 Share

Recommended Posts

Hi, I started trying to learn Lua today, and make my own (probably terrible) gamemode. I ran into a problem, and I'm not sure how to fix it. When I try to run my gamemode, I get the following error:

 

Couldn't include file 'shared.lua' (File not found) (@gamemodes/ghostwar/gamemode/cl_init.lua (line 1))

 

 

I do have shared.lua, and it is in the folder with my cl_init.lua and init.lua.

 

 

The contents of my cl_init.lua (If that could help)


include( 'shared.lua' )

function set_team()

local frame = vgui.Create( "DFrame" )
frame:SetPos( ScrW() / 2, ScrH() / 2 )
frame:SetSize( 200, 210 )
frame:SetTitle( "Change Team" )
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()

team_1 = vgui.Create( "DButton", frame )
team_1:SetPos( frame:GetTall() / 2, 5 )
team_1:SetSize( 50, 100 )
team_1:SetText( "Be The Ghost" )
team_1.DoClick = function()
RunConsoleCommand( "team_1" )
end

team_2 = vgui.Create( "DButton", frame )
team_2:SetPos( frame:GetTall() / 2, 105 )
team_2:SetSize( 50, 100 )
team_2:SetText( "Be A Victim" )
team_2.DoClick = function()
RunConsoleCommand( "team_2" )
end

end
concommand.Add( "team_menu", set_team )

 

My init.lua

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( 'shared.lua' )
ghosts = false
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerSpawn( ply )
ply:SetTeam( 2 )
end

function GM:PlayerLoadout( ply )

if ply:Team() == 1 then

ply:Give ( "weapon_crowbar" )
ply:SetGravity ( 0.50 )
ply:SetHealth ( 150 )
ply:SetWalkSpeed ( 150 )
ply:SetRunSpeed ( 200 )
end

elseif ply:Team() == 2 then

ply:Give ( "weapon_crossbow" )
ply:SetMaxHealth ( 50 )
ply:SetGravity ( 0.90 )
ply:SetWalkSpeed ( 100 )
ply:SetRunSpeed ( 125 )

end



end
function team_1( ply )

if ghosts == false then

ply:SetTeam( 1 )
ply:PrintMessage (HUD_PRINTTALK, "OH NO, " .. ply:name() .. "IS A GHOST!)
ghosts == true
end

elseif ghosts == true then

umsg.Start ( "The Ghosts team is full", ply )
umsg.End
ply:SetTeam( 2 )
end

end

function fPlayerDisconnect( ply )
if ply:team() == 1

ghosts == false
PrintMessage( HUD_PRINTTALK, ply:GetName() .. " has left the server." )
end
else if ply:team() == 2

PrintMessage( HUD_PRINTTALK, ply:GetName() .. " has left the server." )

end

hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect )

 

And my shared.lua

GM.Name = "Ghostwar"
GM.Author = "MisterInvalid"
GM.Email = ""
GM.Website = ""
team.SetUp( 1, "Ghost", Color( 0, 0, 0, 0 ) )
team.SetUp( 2, "Victims", Color( 50, 50, 50, 255 ) )

 

I know the code probably won't work, but it's my first time :P

Edited by MisterInvalid
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share