mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
127
gamemodes/ixhl2rp/plugins/wn7farming/items/base/sh_seeds.lua
Normal file
127
gamemodes/ixhl2rp/plugins/wn7farming/items/base/sh_seeds.lua
Normal file
@@ -0,0 +1,127 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Seeds Base"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.useSound = {"player/footsteps/dirt1.wav", "player/footsteps/dirt2.wav", "player/footsteps/dirt3.wav", "player/footsteps/dirt4.wav"}
|
||||
ITEM.PlantModel = "models/props/de_inferno/claypot03_damage_01.mdl"
|
||||
ITEM.GrowTime = {14400, 14600}
|
||||
ITEM.Harvest = "fruit_apple"
|
||||
ITEM.baseHarvest = {5, 15}
|
||||
ITEM.outlineColor = Color(0, 255, 0, 100)
|
||||
ITEM.vortOnly = false
|
||||
ITEM.returnSeed = true
|
||||
ITEM.functions.plant = {
|
||||
name = "Plant",
|
||||
icon = "icon16/brick_add.png",
|
||||
OnRun = function(item)
|
||||
local client = item.player
|
||||
local trace = client:GetEyeTraceNoCursor()
|
||||
|
||||
if trace.HitPos:DistToSqr(client:GetShootPos()) > 192 * 192 then
|
||||
client:Notify("You can't plant it that far away!")
|
||||
return false
|
||||
end
|
||||
|
||||
if trace.Entity:GetModel() != "models/wn7new/advcrates/n7_planter_dirt.mdl" then
|
||||
client:Notify("This can only be planted in suitable soil.")
|
||||
return false
|
||||
end
|
||||
|
||||
if !(client:GetCharacter():GetFaction() == FACTION_VORT) && item.vortOnly then
|
||||
client:Notify("You have no idea how to work with these strange seeds.")
|
||||
return false
|
||||
end
|
||||
|
||||
local check = true
|
||||
|
||||
for _, v in pairs(ents.FindInSphere(trace.HitPos, 20)) do
|
||||
if v:GetClass() == "cw_plant" then
|
||||
check = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not check then
|
||||
client:Notify("You can't plant this close to another plant!")
|
||||
return false
|
||||
end
|
||||
|
||||
local seed = ents.Create("cw_plant")
|
||||
local growtimeItem = math.random(item.GrowTime[1], item.GrowTime[2])
|
||||
local baseHarvest = math.random(item.baseHarvest[1], item.baseHarvest[2])
|
||||
local character = client:GetCharacter()
|
||||
local cookingSkill = character:GetSkillLevel("cooking")
|
||||
local growtime = growtimeItem - (cookingSkill * 100)
|
||||
|
||||
character:DoAction("plant_seed")
|
||||
|
||||
seed:SetPos(trace.HitPos + trace.HitNormal + trace.Entity:GetUp() * -3)
|
||||
seed.Harvest = item.Harvest
|
||||
seed.baseHarvest = baseHarvest
|
||||
seed.GrowthPercent = 0
|
||||
seed.GrowTime = growtime
|
||||
seed.InitialGrowTime = growtime
|
||||
seed.BaseHarvest = baseHarvest
|
||||
seed.Fertilizer = 0
|
||||
seed.Hydration = math.random(1, 10)
|
||||
seed.usedSeed = item.uniqueID
|
||||
seed.returnSeed = item.returnSeed
|
||||
seed.vortOnly = item.vortOnly
|
||||
seed:Spawn()
|
||||
|
||||
seed:SetModel(item.PlantModel)
|
||||
client:Notify("You have successfully planted the seeds")
|
||||
|
||||
local startPos = seed:GetPos() + Vector(0, 0, 10)
|
||||
local endPos = startPos + Vector(0, 0, 32768)
|
||||
local skyCheckTrace = util.TraceLine({
|
||||
start = startPos,
|
||||
endpos = endPos,
|
||||
mask = MASK_SOLID_BRUSHONLY
|
||||
})
|
||||
|
||||
seed.HasSun = skyCheckTrace.HitSky
|
||||
|
||||
for _, ent in pairs(ents.FindInSphere(seed:GetPos(), 1500)) do
|
||||
if IsValid(ent) and ent:GetClass() == "wn_sunlamp" and ent:GetNetVar("enabled") then
|
||||
seed.HasSun = true
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if not seed.HasSun then
|
||||
client:Notify("The plant won't survive for long as it's not in an open area with sunlight.")
|
||||
return true
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
if (IsValid(item.entity)) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
local data = tooltip:AddRow("data")
|
||||
data:SetBackgroundColor(derma.GetColor("Error", tooltip))
|
||||
data:SetText("You can plant these seeds in a special garden.")
|
||||
data:SizeToContents()
|
||||
end
|
||||
|
||||
|
||||
-- Called when a player drops the item.
|
||||
function ITEM:OnDrop(player, position) end
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Apple Seeds"
|
||||
ITEM.description = "A tiny box with some apple seeds inside of it."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/apple_tree.mdl"
|
||||
ITEM.GrowTime = {14000, 14400}
|
||||
ITEM.baseHarvest = {2, 3}
|
||||
ITEM.Harvest = "fruit_apple"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Banana Seeds"
|
||||
ITEM.description = "A box with some banana seeds inside."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/apple_tree.mdl"
|
||||
ITEM.GrowTime = {14000, 14400}
|
||||
ITEM.baseHarvest = {3, 6}
|
||||
ITEM.Harvest = "fruit_banana"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Berries Seeds"
|
||||
ITEM.description = "A tiny box with some berries seeds inside of it."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/props_foliage/bush2.mdl"
|
||||
ITEM.GrowTime = {14280, 14628}
|
||||
ITEM.baseHarvest = {3, 6}
|
||||
ITEM.Harvest = "fruit_berries"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Orange seeds"
|
||||
ITEM.description = "Some orange orange seeds, inside of a box."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/apple_tree.mdl"
|
||||
ITEM.GrowTime = {14568, 14975}
|
||||
ITEM.baseHarvest = {4, 6}
|
||||
ITEM.Harvest = "fruit_orange"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Pear Seeds"
|
||||
ITEM.description = "A tiny box with some pear seeds inside of it."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/apple_tree.mdl"
|
||||
ITEM.GrowTime = {14833, 15277}
|
||||
ITEM.baseHarvest = {4, 6}
|
||||
ITEM.Harvest = "fruit_pear"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Pineapple Seeds"
|
||||
ITEM.description = "A tiny box with some pineapple seeds inside of it."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/apple_tree.mdl"
|
||||
ITEM.GrowTime = {15118, 15591}
|
||||
ITEM.baseHarvest = {4, 5}
|
||||
ITEM.Harvest = "fruit_pineapple"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Potato Seeds"
|
||||
ITEM.description = "A tiny box with some potato seeds inside of it."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/potato_plant.mdl"
|
||||
ITEM.GrowTime = {15413, 15915}
|
||||
ITEM.baseHarvest = {4, 6}
|
||||
ITEM.Harvest = "veg_potato"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Tomato Seeds"
|
||||
ITEM.description = "A box with some tomato seeds inside. They're not red."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/corn_plant.mdl"
|
||||
ITEM.GrowTime = {15718, 16250}
|
||||
ITEM.baseHarvest = {4, 6}
|
||||
ITEM.Harvest = "veg_tomato"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Watermelon Seeds"
|
||||
ITEM.description = "A tiny box with some watermelon seeds inside of it."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/noble/limelight/broccoli_plant.mdl"
|
||||
ITEM.GrowTime = {18034, 19996}
|
||||
ITEM.baseHarvest = {2, 3}
|
||||
ITEM.Harvest = "fruit_watermelon"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Xen Berries Seeds"
|
||||
ITEM.description = "A fluroescent box with some weird seeds inside..."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/jq/hlvr/props/xenpack/xen_vort_plant.mdl"
|
||||
ITEM.GrowTime = {14280, 14628}
|
||||
ITEM.baseHarvest = {4, 6}
|
||||
ITEM.Harvest = "ing_xenberries"
|
||||
ITEM.vortOnly = true
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Xen Herbs Seeds"
|
||||
ITEM.description = "A fluroescent box with some weird seeds inside..."
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
ITEM.PlantModel = "models/jq/hlvr/props/xenpack/xen_blob_corner_small_blob001_stack.mdl"
|
||||
ITEM.GrowTime = {14280, 14628}
|
||||
ITEM.baseHarvest = {4, 6}
|
||||
ITEM.Harvest = "ing_xen_herb"
|
||||
ITEM.vortOnly = true
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Advanced Fertilizer"
|
||||
ITEM.description = "A small sack filled with small lumps of fertilizer, saltpetre and all the gardening goodies that you need to make a succesful and bountiful harvest. This one has been masterfully crafted to feed all of the plant's needs."
|
||||
ITEM.model = "models/props_junk/garbage_milkcarton001a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
local data = tooltip:AddRow("data")
|
||||
data:SetBackgroundColor(derma.GetColor("Error", tooltip))
|
||||
data:SetText("You can use this item to increase the fertility & hydration of a plant")
|
||||
data:SizeToContents()
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.Water = {
|
||||
name = "Fertilize",
|
||||
icon = "icon16/brick.png",
|
||||
OnRun = function(item)
|
||||
local player = item.player
|
||||
local trace = player:GetEyeTraceNoCursor()
|
||||
|
||||
if (trace.HitPos:Distance(player:GetShootPos()) <= 192) then
|
||||
if (trace.Entity:GetClass() == "cw_plant") then
|
||||
trace.Entity:SetNWInt("Fertilizer", 100)
|
||||
trace.Entity.Fertilizer = 100
|
||||
trace.Entity.Hydration = 100
|
||||
|
||||
player:ChatNotify("You spread some fertilizer around the plant... the plant is happy!")
|
||||
return true
|
||||
else
|
||||
player:Notify("You are not looking at a valid plant.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
48
gamemodes/ixhl2rp/plugins/wn7farming/items/sh_fertilizer.lua
Normal file
48
gamemodes/ixhl2rp/plugins/wn7farming/items/sh_fertilizer.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Fertilizer"
|
||||
ITEM.description = "A small sack filled with small lumps of fertilizer, saltpetre and all the gardening goodies that you need to make a succesful and bountiful harvest."
|
||||
ITEM.model = "models/props_junk/garbage_milkcarton001a.mdl"
|
||||
ITEM.category = "Farming"
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
local data = tooltip:AddRow("data")
|
||||
data:SetBackgroundColor(derma.GetColor("Error", tooltip))
|
||||
data:SetText("You can use this item to increase the fertility level of a plant")
|
||||
data:SizeToContents()
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.Water = {
|
||||
name = "Fertilize",
|
||||
icon = "icon16/brick.png",
|
||||
OnRun = function(item)
|
||||
local player = item.player
|
||||
local trace = player:GetEyeTraceNoCursor()
|
||||
|
||||
if (trace.HitPos:Distance(player:GetShootPos()) <= 192) then
|
||||
if (trace.Entity:GetClass() == "cw_plant") then
|
||||
trace.Entity.Fertilizer = math.min(trace.Entity.Fertilizer + 25, 100)
|
||||
trace.Entity:SetNWInt("Fertilizer", math.min(trace.Entity:GetNWInt("Fertilizer", 0) + 25, 100))
|
||||
|
||||
|
||||
player:ChatNotify("You spread some fertilizer around the plant...")
|
||||
return true
|
||||
|
||||
else
|
||||
player:Notify("You are not looking at a valid plant.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
117
gamemodes/ixhl2rp/plugins/wn7farming/items/sh_water_bucket.lua
Normal file
117
gamemodes/ixhl2rp/plugins/wn7farming/items/sh_water_bucket.lua
Normal file
@@ -0,0 +1,117 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Watering Can"
|
||||
ITEM.description = "A metal gas can repurposed as a watering can that can be filled with water, specially to water down Plants."
|
||||
ITEM.model = "models/props_junk/metalgascan.mdl"
|
||||
ITEM.category = "Farming"
|
||||
|
||||
if (CLIENT) then
|
||||
local color_green = Color(0, 255, 0, 255)
|
||||
local color_red = Color(255, 50, 50, 255)
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
local data = tooltip:AddRow("data")
|
||||
data:SetBackgroundColor(derma.GetColor("Error", tooltip))
|
||||
data:SetText("You can use this bucket directly on plants to water them and increase their Hydration levels\nYou can fill it at bodies of water or Water Caches.")
|
||||
data:SizeToContents()
|
||||
|
||||
local water = tooltip:AddRow("water")
|
||||
water:SetBackgroundColor(derma.GetColor("Error", tooltip))
|
||||
water:SetText("Water: " ..self:GetData("water", 0).. "%")
|
||||
water:SizeToContents()
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.Water = {
|
||||
name = "Water Plant",
|
||||
icon = "icon16/drink.png",
|
||||
OnRun = function(item)
|
||||
local player = item.player
|
||||
local trace = player:GetEyeTraceNoCursor()
|
||||
|
||||
if item:GetData("water") > 0 then
|
||||
if (trace.HitPos:Distance(player:GetShootPos()) <= 192) then
|
||||
if (trace.Entity:GetClass() == "cw_plant") then
|
||||
|
||||
local hydration = trace.Entity.Hydration
|
||||
trace.Entity.Hydration = math.min(hydration + 25, 100)
|
||||
|
||||
local newValue = item:GetData("water", 0) - 25
|
||||
item:SetData("water", newValue)
|
||||
player:EmitSound("ambient/water/water_spray1.wav")
|
||||
player:ChatNotify("You water the plant with the contents of the bucket!")
|
||||
else
|
||||
player:Notify("You are not looking at a valid plant.")
|
||||
end
|
||||
end
|
||||
else
|
||||
player:Notify("There's not enough water on the bucket!")
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.fill = {
|
||||
name = "Fill with Water",
|
||||
tip = "applyTip",
|
||||
icon = "icon16/arrow_in.png",
|
||||
OnRun = function(item)
|
||||
if (SERVER) then
|
||||
local client = item.player
|
||||
local targetEnt = client:GetEyeTraceNoCursor().Entity
|
||||
|
||||
if item:IsWaterDeepEnough(client) then
|
||||
if item:GetData("water") != 100 then
|
||||
local newValue = item:GetData("water", 0) + 25
|
||||
client:ChatNotify("You've refilled to "..newValue.."%")
|
||||
|
||||
item:SetData("water", newValue)
|
||||
client:EmitSound("ambient/water/water_spray1.wav")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if targetEnt:GetClass() == "ix_watercache" or (targetEnt:GetClass() == "ix_cleanwatercache" and targetEnt:GetNetVar("broken", false)) then
|
||||
if item:GetData("water") != 100 then
|
||||
local newValue = item:GetData("water", 0) + 25
|
||||
client:ChatNotify("You've refilled the Watering Can to "..newValue.."%")
|
||||
|
||||
item:SetData("water", newValue)
|
||||
client:EmitSound("ambient/water/water_spray1.wav")
|
||||
else
|
||||
client:ChatNotify("The Watering Can is full!")
|
||||
end
|
||||
else
|
||||
client:ChatNotify("You are not looking at a valid Water Source!")
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:IsWaterDeepEnough(client)
|
||||
local pos = client:GetPos() + Vector(0, 0, 15)
|
||||
local trace = {}
|
||||
trace.start = pos
|
||||
trace.endpos = pos + Vector(0, 0, 1)
|
||||
trace.mask = bit.bor( MASK_WATER )
|
||||
local tr = util.TraceLine(trace)
|
||||
|
||||
return tr.Hit
|
||||
end
|
||||
|
||||
function ITEM:OnInstanced(index, x, y, item)
|
||||
self:SetData("water", 0)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user