diff options
Diffstat (limited to 'gamemode/structuresystem')
| -rw-r--r-- | gamemode/structuresystem/common_smelt.lua | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/gamemode/structuresystem/common_smelt.lua b/gamemode/structuresystem/common_smelt.lua index bb34331..43637e1 100644 --- a/gamemode/structuresystem/common_smelt.lua +++ b/gamemode/structuresystem/common_smelt.lua @@ -6,7 +6,6 @@ function genericMakeFurnace(tbl) local oldusefunc = tbl.onUse local overrideuse = function(self, ply) if SERVER or ply != LocalPlayer() then return end - print("I am the local player!") local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( ScrW() / 1.3, ScrH() / 1.4 ) @@ -24,7 +23,7 @@ function genericMakeFurnace(tbl) testbut.DoClick = function(button) net.Start("makerecipe") net.WriteString(tbl.Name) - if(tbl.uniquedata) then net.WriteUInt(self:EntIndex(), GMS.NETINT_BITCOUNT) end + if tbl.uniquedata then net.WriteUInt(self:EntIndex(), GMS.NETINT_BITCOUNT) end net.WriteUInt(k, GMS.NETINT_BITCOUNT) net.SendToServer() end @@ -38,34 +37,36 @@ end net.Receive( "makerecipe", function(ln,ply) local tblname = net.ReadString() local tbl = GMS.Structures[tblname] - print("Table is:") - PrintTable(tbl) - print("Recipes table is:") - PrintTable(tbl.Recipes) assert(tbl != nil,"Maybe someone's trying to hack lol") if tbl.uniquedata then local entnum = net.ReadUInt(GMS.NETINT_BITCOUNT) tbl = GMS.UniqueStructures[entnum] end local recipenum = net.ReadUInt(GMS.NETINT_BITCOUNT) - print("Useing recipes:") - PrintTable(tbl.Recipes) - print("And recipenum:") - PrintTable(tbl.Recipes[recipenum]) assert(tbl.Recipes != nil and tbl.Recipes[recipenum] != nil, "Invalid recpie!") - print("Attempting to craft recpie:") - PrintTable(tbl.Recipes[recipenum]) local recipe = tbl.Recipes[recipenum] local numrequired = 1 for k, v in pairs( recipe.Req ) do numrequired = numrequired + v - print("numrequired is now:" .. numrequired) end local time = math.pow(numrequired,tbl.timemult) - ((numrequired * tbl.timemult) * math.pow(ply:GetSkill("Smelting"),tbl.skillease)) time = time * numrequired / 5 - --time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * tbl.skillease, 2 ) ) - print("I think smelting this should take " .. time .. " seconds") + for k,v in pairs(recipe.Req) do + if ply:GetResource(k) < v then + ply:SendMessage("You don't have enough!", 3, Color(255, 255, 255, 255)) + return + end + end + --We have enough resources! make it! + startProcessGeneric(ply,"Crafting " .. recipe.Name, time, function(player) + for k,v in pairs(recipe.Results) do + player:IncResource(k,v) + end + for k,v in pairs(recipe.Req) do + ply:DecResource(k,v) + end + end) end) |
