summaryrefslogtreecommitdiff
path: root/gamemode
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-04-30 20:15:02 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-04-30 20:15:02 -0400
commitadcec79b09baa5b6804795077caae8ad7e6c0394 (patch)
tree005db3dde02b7082fa8c6611d2911da9c1b6e88b /gamemode
parent603b64b1a93b36f04d25018ec3f53b16dcd84019 (diff)
downloadgmstranded-adcec79b09baa5b6804795077caae8ad7e6c0394.tar.gz
gmstranded-adcec79b09baa5b6804795077caae8ad7e6c0394.tar.bz2
gmstranded-adcec79b09baa5b6804795077caae8ad7e6c0394.zip
Added mineing resources
Diffstat (limited to 'gamemode')
-rw-r--r--gamemode/cl_init.lua1
-rw-r--r--gamemode/configure_me.lua5
-rw-r--r--gamemode/init.lua6
-rw-r--r--gamemode/itemsystem/items/admantineore.lua10
-rw-r--r--gamemode/itemsystem/items/copperore.lua10
-rw-r--r--gamemode/itemsystem/items/goldore.lua10
-rw-r--r--gamemode/itemsystem/items/ironore.lua10
-rw-r--r--gamemode/itemsystem/items/mithirilore.lua10
-rw-r--r--gamemode/itemsystem/items/platinumore.lua10
-rw-r--r--gamemode/itemsystem/items/silverore.lua10
-rw-r--r--gamemode/itemsystem/items/steelore.lua10
-rw-r--r--gamemode/itemsystem/items/stone.lua10
-rw-r--r--gamemode/itemsystem/items/strangestone.lua10
-rw-r--r--gamemode/itemsystem/items/techore.lua10
-rw-r--r--gamemode/processes.lua20
-rw-r--r--gamemode/server/player_functions.lua14
-rw-r--r--gamemode/shared.lua6
-rw-r--r--gamemode/shared/developer_cheats.lua56
18 files changed, 203 insertions, 15 deletions
diff --git a/gamemode/cl_init.lua b/gamemode/cl_init.lua
index 776f894..6d496ac 100644
--- a/gamemode/cl_init.lua
+++ b/gamemode/cl_init.lua
@@ -3,6 +3,7 @@ include( "utility.lua")
includeFolder("craftablesystem",true)
includeFolder("itemsystem",true)
includeFolder("client",true)
+includeFolder("shared",true)
include( "shared.lua" )
diff --git a/gamemode/configure_me.lua b/gamemode/configure_me.lua
index 70d0f4b..6e26eb9 100644
--- a/gamemode/configure_me.lua
+++ b/gamemode/configure_me.lua
@@ -26,3 +26,8 @@ GMS.LootableNPCs = {
"npc_pigeon",
"npc_zombie"
}
+
+//SteamID's of any developers, this list should be empty on production servers!
+GMS.Developers = {
+ "STEAM_0:0:0" //the single-player steamid
+}
diff --git a/gamemode/init.lua b/gamemode/init.lua
index a4c480a..5b1fa5a 100644
--- a/gamemode/init.lua
+++ b/gamemode/init.lua
@@ -4,10 +4,12 @@ include( "init_static.lua")
AddCSLuaFolder("client",false)
AddCSLuaFolder("craftablesystem",true)
AddCSLuaFolder("itemsystem",true)
+AddCSLuaFolder("shared",true)
includeFolder("server",false)
includeFolder("craftablesystem",true)
includeFolder("itemsystem",true)
+includeFolder("shared",true)
AddCSLuaFile( "configure_me.lua" )
@@ -131,7 +133,7 @@ end
-- Cancel process
concommand.Add( "gms_cancelprocess", function( ply, cmd, args )
ply:CancelProcess()
-
+
end )
@@ -937,6 +939,7 @@ concommand.Add( "gms_makefire", GM.MakeCampfire )
---------------------------------------------------------------------------------------------------- */
function GM:PlayerInitialSpawn( ply )
+ print("--------Inital spawn called!---------")
ply:SetTeam( 1 )
ply.Skills = {}
@@ -996,6 +999,7 @@ function GM:PlayerInitialSpawn( ply )
ply.FeatureUnlocks = tbl["unlocks"]
ply.MaxResources = ( ply.Skills["Survival"] * 5 ) + 25
+ print("Setting MaxResources to " .. ply.MaxResources)
ply:SendMessage( "Loaded character successfully.", 3, Color( 255, 255, 255, 255 ) )
ply:SendMessage( "Last visited on " .. tbl.date .. ", enjoy your stay.", 10, Color( 255, 255, 255, 255 ) )
diff --git a/gamemode/itemsystem/items/admantineore.lua b/gamemode/itemsystem/items/admantineore.lua
new file mode 100644
index 0000000..2b1ac16
--- /dev/null
+++ b/gamemode/itemsystem/items/admantineore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Adamantine Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/copperore.lua b/gamemode/itemsystem/items/copperore.lua
new file mode 100644
index 0000000..c7e1fea
--- /dev/null
+++ b/gamemode/itemsystem/items/copperore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Copper Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/goldore.lua b/gamemode/itemsystem/items/goldore.lua
new file mode 100644
index 0000000..a5b1a53
--- /dev/null
+++ b/gamemode/itemsystem/items/goldore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Gold Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/ironore.lua b/gamemode/itemsystem/items/ironore.lua
new file mode 100644
index 0000000..b94d9eb
--- /dev/null
+++ b/gamemode/itemsystem/items/ironore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Iron Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/mithirilore.lua b/gamemode/itemsystem/items/mithirilore.lua
new file mode 100644
index 0000000..da3dea8
--- /dev/null
+++ b/gamemode/itemsystem/items/mithirilore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Mithril Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/platinumore.lua b/gamemode/itemsystem/items/platinumore.lua
new file mode 100644
index 0000000..b94d9eb
--- /dev/null
+++ b/gamemode/itemsystem/items/platinumore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Iron Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/silverore.lua b/gamemode/itemsystem/items/silverore.lua
new file mode 100644
index 0000000..b94d9eb
--- /dev/null
+++ b/gamemode/itemsystem/items/silverore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Iron Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/steelore.lua b/gamemode/itemsystem/items/steelore.lua
new file mode 100644
index 0000000..c245ade
--- /dev/null
+++ b/gamemode/itemsystem/items/steelore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Steel Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/stone.lua b/gamemode/itemsystem/items/stone.lua
new file mode 100644
index 0000000..d288d27
--- /dev/null
+++ b/gamemode/itemsystem/items/stone.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Stone"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/strangestone.lua b/gamemode/itemsystem/items/strangestone.lua
new file mode 100644
index 0000000..9d684ce
--- /dev/null
+++ b/gamemode/itemsystem/items/strangestone.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Strange Stone"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/techore.lua b/gamemode/itemsystem/items/techore.lua
new file mode 100644
index 0000000..cc494e6
--- /dev/null
+++ b/gamemode/itemsystem/items/techore.lua
@@ -0,0 +1,10 @@
+ITEM = {}
+
+ITEM.Name = "Tech Ore"
+ITEM.Description = "Something you can craft with!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+genericMakeDroppable(ITEM)
+
+GMS.RegisterResource(ITEM)
diff --git a/gamemode/processes.lua b/gamemode/processes.lua
index 333f404..45e544d 100644
--- a/gamemode/processes.lua
+++ b/gamemode/processes.lua
@@ -615,34 +615,34 @@ function PROCESS:OnStop()
self.Owner:IncResource( "Stone", num3 )
self.Owner:SendMessage( "Stone ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 2 ) then
- self.Owner:IncResource( "Copper_Ore", num3 )
+ self.Owner:IncResource( "Copper Ore", num3 )
self.Owner:SendMessage( "Copper Ore ( "..num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 3 ) then
- self.Owner:IncResource( "Iron_Ore", num3 )
+ self.Owner:IncResource( "Iron Ore", num3 )
self.Owner:SendMessage( "Iron Ore ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 4 ) then
- self.Owner:IncResource( "Tech_Ore", num3 )
+ self.Owner:IncResource( "Tech Ore", num3 )
self.Owner:SendMessage( "Tech Ore ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 5 ) then
- self.Owner:IncResource( "Silver_Ore", num3 )
+ self.Owner:IncResource( "Silver Ore", num3 )
self.Owner:SendMessage( "Silver Ore ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 6 ) then
- self.Owner:IncResource( "Gold_Ore", num3 )
+ self.Owner:IncResource( "Gold Ore", num3 )
self.Owner:SendMessage( "Gold Ore ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 7 ) then
- self.Owner:IncResource( "Steel_Ore", num3 )
+ self.Owner:IncResource( "Steel Ore", num3 )
self.Owner:SendMessage( "Steel Ore ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 8 ) then
- self.Owner:IncResource( "Platinum_Ore", num3 )
+ self.Owner:IncResource( "Platinum Ore", num3 )
self.Owner:SendMessage( "Platinum Ore ( " .. num3 .. "x )", 3, Color( 10, 200, 10, 255 ) )
elseif ( num2 == 85 ) then
- self.Owner:IncResource( "Strange_Stone", num3 )
+ self.Owner:IncResource( "Strange Stone", num3 )
self.Owner:SendMessage( "Strange Stone ( " .. num3 .. "x ) ", 3, Color( 0, 247, 255, 255) )
elseif ( num2 == 9 ) then
- self.Owner:IncResource( "Mithril_Ore", num3 )
+ self.Owner:IncResource( "Mithril Ore", num3 )
self.Owner:SendMessage( "Mithril Ore ( " .. num3 .. "x ) ", 3, Color(10, 200, 10, 255) )
elseif ( num2 == 10) then
- self.Owner:IncResource( "Adamantine_Ore", num3 )
+ self.Owner:IncResource( "Adamantine Ore", num3 )
self.Owner:SendMessage( "Adamantine Ore( " .. num3 .. "x ) ", 3, Color(255,0, 111, 255) )
end
diff --git a/gamemode/server/player_functions.lua b/gamemode/server/player_functions.lua
index b8afc32..09de491 100644
--- a/gamemode/server/player_functions.lua
+++ b/gamemode/server/player_functions.lua
@@ -150,9 +150,9 @@ function PlayerMeta:SetResource( resource, int )
PrintTable(resource)
print(int)
- if ( !self.Resources[resource] ) then self.Resources[resource] = 0 end
+ --if ( !self.Resources[resource] ) then self.Resources[resource] = 0 end
- self.Resources[resource] = int
+ --self.Resources[resource] = int
if(net.Start("gms_SetResource",false)) then
net.WriteString(resource.Name)
@@ -186,6 +186,10 @@ function PlayerMeta:IncResource( resource, int )
if ( !self.Resources[resource] ) then self.Resources[resource] = 0 end
local all = self:GetAllResources()
local max = self.MaxResources
+ print("When adding resources, max resource is:")
+ print(max)
+ print("All is:")
+ print(all)
if ( all + int > max ) then
self.Resources[resource] = self.Resources[resource] + ( max - all )
@@ -196,6 +200,8 @@ function PlayerMeta:IncResource( resource, int )
end
self:SetResource(resource, self:GetResource( resource ))
+ print("Now all is:")
+ print(self:GetAllResources())
end
function PlayerMeta:DecResource( resource, int )
@@ -215,12 +221,14 @@ function PlayerMeta:DecResource( resource, int )
end
function PlayerMeta:GetAllResources()
+ print("Totaling data in:")
+ PrintTable(self.Resources)
local num = 0
for k, v in pairs( self.Resources ) do
num = num + v
end
-
+ print("Total was " .. num)
return num
end
diff --git a/gamemode/shared.lua b/gamemode/shared.lua
index 2cc0234..5588e1f 100644
--- a/gamemode/shared.lua
+++ b/gamemode/shared.lua
@@ -93,7 +93,11 @@ end
local PlayerMeta = FindMetaTable( "Player" )
function PlayerMeta:IsDeveloper()
- if ( self:SteamID() == "STEAM_0:0:18313012" ) then return true end
+ for k,v in pairs(GMS.Developers) do
+ if(self:SteamID() == v) then
+ return true
+ end
+ end
return false
end
diff --git a/gamemode/shared/developer_cheats.lua b/gamemode/shared/developer_cheats.lua
new file mode 100644
index 0000000..e8c4fbb
--- /dev/null
+++ b/gamemode/shared/developer_cheats.lua
@@ -0,0 +1,56 @@
+--This file contains things to help developers debug while working on the code. All this stuff relies on the Developers table in configre_me.lua
+
+local pmeta = FindMetaTable( "Player" )
+
+function pmeta:IsDeveloper()
+ for k,v in pairs(GMS.Developers) do
+ if(self:SteamID() == v) then
+ return true
+ end
+ end
+ return false
+end
+
+-----------------Print inventory---------------------
+local printServerResources = function(ply,cmd,args)
+ if(CLIENT or (!ply:IsDeveloper())) then return end
+ PrintTable(ply.Resources)
+end
+
+local printServerResourcesAuto = function(cmd,args) end
+
+concommand.Add("gms_sv_printSvRes",printServerResources,printServerResourcesAuto,"Prints the server representation of your resources")
+
+local printClientResources = function(ply,cmd,args)
+ if(SERVER or (!ply:IsDeveloper())) then return end
+ PrintTable(Resources)
+end
+
+local printClientResourcesAuto = function(cmd,args) end
+
+concommand.Add("gms_sv_printClRes",printClientResources,printClientResourcesAuto,"Prints the client representation of your resources")
+
+------------------Give weapons----------------------
+local giveWeapon = function(ply,cmd,args)
+ if(!ply:IsDeveloper()) then return end
+ if(weapons.Get(args[1]) == nil) then
+ print("Could not find weapon:" .. args[1])
+ return
+ end
+ ply:Give(args[1])
+end
+
+local giveWeaponAuto = function(cmd,args)
+ local possibles = {}
+ local needle = string.Trim(args)
+ print("\"" .. needle .. "\"")
+ for k,v in pairs(weapons.GetList()) do
+ local fplace = string.find(v.ClassName,needle)
+ if(fplace != nil) then
+ table.insert(possibles,cmd .. " " .. v.ClassName)
+ end
+ end
+ return possibles
+end
+
+concommand.Add("gms_sv_givewep",giveWeapon,giveWeaponAuto)