mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
118 lines
3.4 KiB
Lua
118 lines
3.4 KiB
Lua
--[[
|
||
| 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 = "Sulama Kabı"
|
||
ITEM.description = "Metal bir kutu, özellikle Bitkileri sulamak için suyla doldurulabilen bir sulama kabı olarak yeniden kullanılabilir."
|
||
ITEM.model = "models/props_junk/metalgascan.mdl"
|
||
ITEM.category = "Çiftçilik"
|
||
|
||
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 = "Bitkiyi Sula",
|
||
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 = "Suyla Doldur",
|
||
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
|
||
|