1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
This commit is contained in:
g_brzhezinskiy
2021-01-02 12:51:45 +03:00
commit 1d05caf866
613 changed files with 337020 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
include("shared.lua")
function ENT:Draw()
self:DrawModel()
--self:SetNW2Float("Total",Metrostroi.TotalkWh)
--self:SetNW2Float("Rate",Metrostroi.TotalRateWatts)
local pos = self:LocalToWorld(Vector(4.6,-5.5,14))
local ang = self:LocalToWorldAngles(Angle(0,90,90))
cam.Start3D2D(pos, ang, 1/16)
surface.SetDrawColor(0, 0, 0, 255)
surface.DrawRect(6, 32+64*0, 192-24, 32)
surface.DrawRect(6, 32+64*1, 192-24, 32)
surface.DrawRect(6, 32+64*2, 192-24, 32)
surface.DrawRect(6, 32+64*3, 192-24, 32)
surface.DrawRect(6, 32+64*4, 192-24, 32)
draw.DrawText(Format("%07.0f",self:GetTotal()*1000),"MetrostroiSubway_IGLA",6+4,32+64*0,Color(255,255,255,255))
--draw.DrawText(",","MetrostroiSubway_IGLA",20+4+26,32+64*0,Color(255,255,255,255))
draw.DrawText(".","MetrostroiSubway_IGLA",20+4+64+4,32+64*0+2,Color(255,255,255,255))
draw.DrawText("E (watts-hour)","MetrostroiSubway_VerySmallText3",16,6+64*0,Color(0,0,0,255))
draw.DrawText(Format("%07.1f",self:GetRate()*1e-3),"MetrostroiSubway_IGLA",6+4,32+64*1,Color(255,255,255,255))
draw.DrawText("P (kW)","MetrostroiSubway_VerySmallText3",16,8+64*1,Color(0,0,0,255))
draw.DrawText(Format("%7.2f",Metrostroi.GetEnergyCost(self:GetTotal())),"MetrostroiSubway_IGLA",6+4,32+64*2,Color(255,255,255,255))
draw.DrawText("Cost ($)","MetrostroiSubway_VerySmallText3",16,8+64*2,Color(0,0,0,255))
draw.DrawText(Format("%7.1f",self:GetV()),"MetrostroiSubway_IGLA",6+4,32+64*3,Color(255,255,255,255))
draw.DrawText("Voltage (V)","MetrostroiSubway_VerySmallText3",16,8+64*3,Color(0,0,0,255))
draw.DrawText(Format("%7.1f",self:GetA()),"MetrostroiSubway_IGLA",6+4,32+64*4,Color(255,255,255,255))
draw.DrawText("Current (A)","MetrostroiSubway_VerySmallText3",16,8+64*4,Color(0,0,0,255))
--Metrostroi.DrawClockDigit(56+170,48,2.0,0)
--[[local T0 = self:GetNW2Float("T0",os.time())+1396011937
local T1 = self:GetNW2Float("T1",CurTime())
local dT = (os.time()-T0 + (CurTime() % 1.0)) - (CurTime()-T1)
local digits = { 1,2,3,4,5,6 }
local os_time = os.time()-dT
local d = os.date("!*t",os_time)
digits[1] = math.floor(d.hour / 10)
digits[2] = math.floor(d.hour % 10)
digits[3] = math.floor(d.min / 10)
digits[4] = math.floor(d.min % 10)
digits[5] = math.floor(d.sec / 10)
digits[6] = math.floor(d.sec % 10)
for i,v in ipairs(digits) do
local j = i-1
local x = 56+100*(i-1)+50*math.floor((i-1)/2)
local y = 48
Metrostroi.DrawClockDigit(x,y,1.7,v)
end
Metrostroi.DrawClockDigit(56+170,48,1.7,".")]]--
cam.End3D2D()
end

View File

@@ -0,0 +1,60 @@
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
local OldVoltage
function ENT:Initialize()
self:SetModel("models/z-o-m-b-i-e/metro_2033/electro/m33_electro_box_12_4.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
if not Metrostroi.OldVoltage then
Metrostroi.OldVoltage = 0
end
end
function ENT:Use(ply)
--if not ply:IsAdmin() then return end
if Metrostroi.Voltage == 0 then
RunConsoleCommand("metrostroi_voltage",Metrostroi.OldVoltage ~= 0 and Metrostroi.OldVoltage or 750)
Metrostroi.OldVoltage = 0
else
Metrostroi.OldVoltage = GetConVarNumber("metrostroi_voltage")
RunConsoleCommand("metrostroi_voltage",0)
Metrostroi.Voltage = 0
Metrostroi.VoltageOffByPlayerUse = true
end
self:EmitSound("buttons/lever8.wav",100,100)
end
function ENT:Think()
self:SetTotal(Metrostroi.TotalkWh)
self:SetRate(Metrostroi.TotalRateWatts)
self:SetV(Metrostroi.Voltage)
self:SetA(Metrostroi.Current)
if Metrostroi.Voltage >= 10 then
Metrostroi.VoltageOffByPlayerUse = nil
end
if Metrostroi.Voltage < 10 and not Metrostroi.VoltageOffByPlayerUse then
self.SoundTimer = self.SoundTimer or CurTime()
if (CurTime() - self.SoundTimer) > 1.0 then
self:EmitSound("ambient/alarms/klaxon1.wav", 100, 100)
self.SoundTimer = CurTime()
end
end
self:NextThink(CurTime())
return true
end
function ENT:OnRemove()
if Metrostroi.Voltage == 0 then
RunConsoleCommand("metrostroi_voltage",Metrostroi.OldVoltage ~= 0 and Metrostroi.OldVoltage or 750)
end
end

View File

@@ -0,0 +1,13 @@
ENT.Type = "anim"
ENT.Category = "Metrostroi (utility)"
ENT.Spawnable = true
ENT.AdminSpawnable = false
function ENT:SetupDataTables()
self:NetworkVar("Float", 0, "Total" )
self:NetworkVar("Float", 1, "Rate" )
self:NetworkVar("Float", 2, "V")
self:NetworkVar("Float", 3, "A" )
end