From d3612d8431de4eaa813d6571c368a0ce0679662c Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Fri, 6 May 2016 20:32:19 -0400 Subject: A little more refactoring in the itemsystem --- gamemode/itemsystem/common_plantable.lua | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'gamemode') diff --git a/gamemode/itemsystem/common_plantable.lua b/gamemode/itemsystem/common_plantable.lua index 2728b9a..9c86491 100644 --- a/gamemode/itemsystem/common_plantable.lua +++ b/gamemode/itemsystem/common_plantable.lua @@ -14,18 +14,9 @@ local function plant(player, resourcename) net.SendToServer() end if(SERVER) then - print("Planting " .. resourcename) local tbl = GMS.Resources[resourcename] - print("Plant table:") - PrintTable(tbl) - if(tbl.GrowTime == nil) then - print(tbl.Name .. " .GrowTime is nil, this might be a bug!") - return - end - if(tbl.OnGrow == nil) then - print(tbl.Name .. " .OnGrow is nil, this might be a bug!") - return - end + assert(tbl.GrowTime != nil,tbl.Name .. " .GrowTime is nil!") + assert(isfunction(tbl.OnGrow),tbl.Name .. " .OnGrow is not a table") local tr = player:GetEyeTrace() local pent = ents.Create("gms_generic_plantable") @@ -83,7 +74,7 @@ function GAMEMODE.MakeGenericPlantChild( ply, pos, mdl, parent ) return ent end -function GAMEMODE.MakeGenericPlant( ply, pos, mdl, isTree ) +function GAMEMODE.MakeGenericPlant( ply, pos, mdl, isWorld ) local ent = ents.Create( "prop_dynamic" ) ent:SetAngles( Angle( 0, math.random( 0, 360 ), 0 ) ) ent:SetSolid( SOLID_VPHYSICS ) @@ -96,7 +87,7 @@ function GAMEMODE.MakeGenericPlant( ply, pos, mdl, isTree ) ent:Fadein() ent:RiseFromGround( 1, 50 ) - if ( !isTree && IsValid( ply ) ) then + if ( !isWorld && IsValid( ply ) ) then ent:SetNWEntity( "plantowner", ply ) SPropProtection.PlayerMakePropOwner( ply, ent ) else -- cgit v1.2.3-70-g09d2