1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
* Global change.
Замена всех устаревших функции на аналогичные

* Global change.
Добавил локальные переменные там, где это было рентабельно.
This commit is contained in:
Ivan Gordeev
2021-07-26 09:18:18 +03:00
committed by GitHub
parent 4a2786967d
commit 373073e661
29 changed files with 121 additions and 123 deletions

View File

@@ -310,11 +310,11 @@ local function showAddons(ply)
else
v.message = Metrostroi.GetPhrase("N\\A")
end
if GetConVarNumber("metrostroi_addons_check_ignore") > 0 and (v.error or not v.message) then
if GetConVar("metrostroi_addons_check_ignore"):GetInt() > 0 and (v.error or not v.message) then
RunConsoleCommand("metrostroi_addons_check_ignore",0)
end
end
if GetConVarNumber("metrostroi_addons_check_ignore") > 0 and not ply or WaitAddons > 0 then return end
if GetConVar("metrostroi_addons_check_ignore"):GetInt() > 0 and not ply or WaitAddons > 0 then return end
if IsValid(MetrostroiWorkshopVGUI) then MetrostroiWorkshopVGUI:Close() end
local badCount = 0
@@ -332,7 +332,7 @@ local function showAddons(ply)
local scrollPanel = vgui.Create( "DScrollPanel", frame )
--scrollPanel:SetMinimumSize(nil,450)
for i,a in ipairs(RequiredAddons) do
if badCount ~= 0 and not showall and GetConVarNumber("metrostroi_addons_check_skip_error") > 0 and not a.error and a.message ~= "N\\A" or not a.error and a.reason then continue end
if badCount ~= 0 and not showall and GetConVar("metrostroi_addons_check_skip_error"):GetInt() > 0 and not a.error and a.message ~= "N\\A" or not a.error and a.reason then continue end
--local a = v[1]
local addon = vgui.Create("DPanel")

View File

@@ -1012,7 +1012,7 @@ ENT.Spawner = {
ent[v]:TriggerInput("Set",val and 1 or 0)
end
end,function(CB,VGUI)
VGUI.SwitchesR:SetDisabled(not CB:GetChecked())
VGUI.SwitchesR:SetEnabled(CB:GetChecked())
if not CB:GetChecked() then
VGUI.SwitchesR:SetValue(false)
end

View File

@@ -1047,7 +1047,7 @@ function ENT:Think()
end
end
if (GetConVarNumber("metrostroi_disablecamaccel") == 0) then
if (GetConVar("metrostroi_disablecamaccel"):GetInt() == 0) then
self.HeadAcceleration = (self:Animate("accel",((self:GetNW2Float("Accel",0)+1)/2),0,1, 4, 1)*30-15)
else
self.HeadAcceleration = 0
@@ -2262,8 +2262,8 @@ hook.Add("Think","metrostroi-cabin-panel",function()
end
-- Tooltips
local ttdelay = GetConVarNumber("metrostroi_tooltip_delay")
if GetConVarNumber("metrostroi_disablehovertext") == 0 and ttdelay and ttdelay >= 0 then
local ttdelay = GetConVar("metrostroi_tooltip_delay"):GetFloat()
if GetConVar("metrostroi_disablehovertext"):GetInt() == 0 and ttdelay and ttdelay >= 0 then
local button = findAimButton(ply,train)
--print(train.ClientProps[button.ID].button)
if button and
@@ -2291,7 +2291,7 @@ hook.Add("Think","metrostroi-cabin-panel",function()
toolTipText = toolTipText..newTT
toolTipPosition = Metrostroi.GetPhrase(newTTpos)
end]]
if GetConVarNumber("metrostroi_disablehovertextpos") == 0 and button.tooltipState and button.tooltip then
if GetConVar("metrostroi_disablehovertextpos"):GetInt() == 0 and button.tooltipState and button.tooltip then
toolTipText = toolTipText..button.tooltipState(train)
end
end
@@ -2525,7 +2525,7 @@ local ppMat = Material("pp/blurx")
hook.Add( "HUDPaint", "metrostroi-draw-crosshair-tooltip", function()
--if not drawCrosshair then return end
if IsValid(LocalPlayer()) then
local scrX,scrY = surface.ScreenWidth(),surface.ScreenHeight()
local scrX,scrY = ScrW(),ScrH()
if canDrawCrosshair then
surface.DrawCircle(scrX/2,scrY/2,4.1,drawCrosshair and Color(255,0,0) or Color(255,255,150))

View File

@@ -86,6 +86,10 @@ function ENT:PostEntityPaste(ply,ent,createdEntities)
end
--------------------------------------------------------------------------------
local C_MaxWagons = GetConVar("metrostroi_maxwagons")
local C_MaxTrains = GetConVar("metrostroi_maxtrains")
local C_MaxTrainsOnPly = GetConVar("metrostroi_maxtrains_onplayer")
function ENT:Initialize()
self.Joints = {}
self.JointPositions = {}
@@ -128,7 +132,7 @@ function ENT:Initialize()
-- Initialize highspeed interface
self:InitializeHighspeedLayout()
-- Add telemetry recording module if required
if GetConVarNumber("metrostroi_write_telemetry") == 1 then
if GetConVar("metrostroi_write_telemetry"):GetInt() == 1 then
self:LoadSystem("Telemetry")
end
self:LoadSystem("FailSim")
@@ -2001,15 +2005,15 @@ end
function ENT:SpawnFunction(ply, tr,className,rotate,func)
--MaxTrains limit
if self.ClassName ~= "gmod_subway_base" and not self.NoTrain then
local Limit1 = math.min(2,GetConVarNumber("metrostroi_maxwagons"))*GetConVarNumber("metrostroi_maxtrains_onplayer")-1
local Limit2 = math.max(0,GetConVarNumber("metrostroi_maxwagons")-2)*GetConVarNumber("metrostroi_maxtrains_onplayer")-1
local Limit1 = math.min(2,C_MaxWagons:GetInt())*C_MaxTrainsOnPly:GetInt()-1
local Limit2 = math.max(0,C_MaxWagons:GetInt()-2)*C_MaxTrainsOnPly:GetInt()-1
if Metrostroi.TrainCount() > GetConVarNumber("metrostroi_maxtrains")*GetConVarNumber("metrostroi_maxwagons")-1 then
if Metrostroi.TrainCount() > C_MaxTrains:GetInt()*C_MaxWagons:GetInt()-1 then
ply:LimitHit("train_limit")
--Metrostroi.LimitMessage(ply)
return
end
if Metrostroi.TrainCountOnPlayer(ply) > GetConVarNumber("metrostroi_maxwagons")*GetConVarNumber("metrostroi_maxtrains_onplayer")-1 then
if Metrostroi.TrainCountOnPlayer(ply) > C_MaxWagons:GetInt()*C_MaxTrainsOnPly:GetInt()-1 then
ply:LimitHit("train_limit")
--Metrostroi.LimitMessage(ply)
return

View File

@@ -229,7 +229,7 @@ function ENT:CreateBASSSound(name,callback,noblock,onerr)
if err ~= 41 then
MsgC(Color(255,0,0),Format("Sound:%s\n\tErrCode:%s, ErrName:%s\n",name,err,errName))
if onerr then callback(false) end
elseif GetConVarNumber("metrostroi_drawdebug") ~= 0 then
elseif GetConVar("metrostroi_drawdebug"):GetInt() ~= 0 then
MsgC(Color(255,255,0),Format("Sound:%s\n\tBASS_ERROR_UNKNOWN (it's normal),ErrCode:%s, ErrName:%s\n",name,err,errName))
self:CreateBASSSound(name,callback)
end
@@ -461,7 +461,7 @@ else
if err == 4 or err == 37 then self.StopSounds = true end
if err ~= 41 then
MsgC(Color(255,0,0),Format("Sound:%s\n\tErrCode:%s, ErrName:%s\n",name,err,errName))
elseif GetConVarNumber("metrostroi_drawdebug") ~= 0 then
elseif GetConVar("metrostroi_drawdebug"):GetInt() ~= 0 then
MsgC(Color(255,255,0),Format("Sound:%s\n\tBASS_ERROR_UNKNOWN (it's normal),ErrCode:%s, ErrName:%s\n",name,err,errName))
--self:PlayOnce(soundid,location,range,pitch,randoff)
end

View File

@@ -383,7 +383,7 @@ end
-- Make sure entity is not drawn
--------------------------------------------------------------------------------
function ENT:Draw()
if GetConVarNumber("metrostroi_drawsignaldebug") ~= 1 then return end
if GetConVar("metrostroi_drawsignaldebug"):GetInt() ~= 1 then return end
local platformStart = self:GetNW2Vector("PlatformStart",false)
local platformEnd = self:GetNW2Vector("PlatformEnd",false)

View File

@@ -140,7 +140,7 @@ function ENT:Initialize()
end
function ENT:OnRemove()
timer.Destroy("metrostroi_station_announce_"..self:EntIndex())
timer.Remove("metrostroi_station_announce_"..self:EntIndex())
end
--------------------------------------------------------------------------------

View File

@@ -20,7 +20,7 @@ function ENT:Use(ply)
RunConsoleCommand("metrostroi_voltage",Metrostroi.OldVoltage ~= 0 and Metrostroi.OldVoltage or 750)
Metrostroi.OldVoltage = 0
else
Metrostroi.OldVoltage = GetConVarNumber("metrostroi_voltage")
Metrostroi.OldVoltage = GetConVar("metrostroi_voltage"):GetInt()
RunConsoleCommand("metrostroi_voltage",0)
Metrostroi.Voltage = 0
Metrostroi.VoltageOffByPlayerUse = true

View File

@@ -1,7 +1,7 @@
include("shared.lua")
function ENT:Initialize()
self.CanDraw = GetConVarNumber("metrostroi_drawsignaldebug")>0
self.CanDraw = GetConVar("metrostroi_drawsignaldebug"):GetInt()>0
for k,v in pairs(self.ValidModels) do
if v==self:GetModel() then
self.CanDraw = true

View File

@@ -86,10 +86,10 @@ local function CreateList(name,text,tbl,OnSelect,stbl)
end
List.ID = table.insert(VGUI,function(val, disabled, reset)
if reset then
if List.Disable then List:SetDisabled(false) end
if List.Disable then List:SetEnabled(true) end
elseif val or disabled then
if val ~= nil then List:ChooseOptionID(val) end
List:SetDisabled(disabled)
List:SetEnabled(not disabled)
List.Disable = disabled
else
ListLabel:Remove()
@@ -138,12 +138,12 @@ local function CreateSlider(name,decimals,min,max,text,OnSelect,stbl)
end
Slider.ID = table.insert(VGUI,function(val, disabled, reset)
if reset then
if Slider.Disable then Slider:SetDisabled(false) Slider.Disable = nil end
if Slider.Disable then Slider:SetEnabled(true) Slider.Disable = nil end
return
end
if val or disabled then
if val ~= nil then Slider:SetValue(val) end
Slider:SetDisabled(disabled)
Slider:SetEnabled(not disabled)
Slider.Disable = disabled
return
end
@@ -183,12 +183,12 @@ local function CreateCheckBox(name,text,OnSelect,stbl)
end
CB.ID = table.insert(VGUI,function(val, disabled, reset)
if reset then
if CB.Disable then CB:SetDisabled(false) CB.Disable = nil end
if CB.Disable then CB:SetEnabled(true) CB.Disable = nil end
return
end
if val or disabled then
if val ~= nil then CB:SetValue(val) end
CB:SetDisabled(disabled)
CB:SetEnabled(not disabled)
CB.Disable = disabled
return
end
@@ -521,7 +521,7 @@ end
local function createFrame()
MaxWagons = GetGlobalInt("metrostroi_maxtrains")*GetGlobalInt("metrostroi_maxwagons")
MaxWagonsOnPlayer = GetGlobalInt("metrostroi_maxtrains_onplayer")*GetGlobalInt("metrostroi_maxwagons")
--if GetConVarString("gmod_toolmode") == "train_spawner" then RunConsoleCommand("gmod_toolmode", "weld") end
--if GetConVar("gmod_toolmode"):GetString() == "train_spawner" then RunConsoleCommand("gmod_toolmode", "weld") end
if IsValid(frame) then return end
Pos = 0
VGUI = {}
@@ -564,7 +564,7 @@ local function createFrame()
spawn.DoClick = function()
--[[
local Tool = GetConVarString("gmod_toolmode")
local Tool = GetConVar("gmod_toolmode"):GetString()
if Tool == "train_spawner" then Tool = "weld" end
RunConsoleCommand("train_spawner_oldT", Tool)
RunConsoleCommand("train_spawner_oldW", LocalPlayer():GetActiveWeapon():GetClass())

View File

@@ -9,9 +9,9 @@ CreateConVar("metrostroi_maxtrains",3,{FCVAR_ARCHIVE},"Maximum of allowed trains
CreateConVar("metrostroi_maxwagons",3,{FCVAR_ARCHIVE},"Maximum of allowed wagons in 1 train")
CreateConVar("metrostroi_maxtrains_onplayer",1,{FCVAR_ARCHIVE},"Maximum of allowed trains by player")
local function MaxWagonsChangeCallback()
SetGlobalInt("metrostroi_maxtrains",GetConVarNumber("metrostroi_maxtrains"))
SetGlobalInt("metrostroi_maxtrains_onplayer",GetConVarNumber("metrostroi_maxtrains_onplayer"))
SetGlobalInt("metrostroi_maxwagons",GetConVarNumber("metrostroi_maxwagons"))
SetGlobalInt("metrostroi_maxtrains",GetConVar("metrostroi_maxtrains"):GetInt())
SetGlobalInt("metrostroi_maxtrains_onplayer",GetConVar("metrostroi_maxtrains_onplayer"):GetInt())
SetGlobalInt("metrostroi_maxwagons",GetConVar("metrostroi_maxwagons"):GetInt())
timer.Simple(0,function()
net.Start("MetrostroiMaxWagons")
net.Broadcast()

View File

@@ -1,19 +1,7 @@
--Helper function for common use
local function AddBox(panel,cmd,str)
panel:AddControl("CheckBox",{Label=str, Command=cmd})
end
--Helper function for common use
local function AddTextBox(panel,cmd,str)
panel:AddControl("TextBox",{Label=str, Command=cmd})
end
local function AddSlider(panel,cmd,str,min,max,fl)
panel:AddControl("Slider",{Label=str, Command=cmd,min=min,max=max,type=fl and "float"})
end
-- Build admin panel
local function AdminPanel(panel)
if not LocalPlayer():IsAdmin() then return end
AddBox(panel,"metrostroi_train_requirethirdrail",Metrostroi.GetPhrase("Panel.RequireThirdRail"))
--panel:AddControl("CheckBox",{Label="Trains require 3rd rail", Command = "metrostroi_train_requirethirdrail"})
panel:CheckBox(Metrostroi.GetPhrase("Panel.RequireThirdRail"),"metrostroi_train_requirethirdrail")
end
-- Build regular client panel
local function ClientPanel(panel)
@@ -36,24 +24,23 @@ local function ClientPanel(panel)
if Metrostroi.HasPhrase("AuthorTextMetadmin") then
panel:ControlHelp(Metrostroi.GetPhrase("AuthorTextMetadmin"))
end
AddBox(panel,"metrostroi_drawcams",Metrostroi.GetPhrase("Panel.DrawCams"))
AddBox(panel,"metrostroi_disablehud",Metrostroi.GetPhrase("Panel.DisableHUD"))
AddBox(panel,"metrostroi_disablecamaccel",Metrostroi.GetPhrase("Panel.DisableCamAccel"))
AddBox(panel,"metrostroi_disablehovertext",Metrostroi.GetPhrase("Panel.DisableHoverText"))
AddBox(panel,"metrostroi_disablehovertextpos",Metrostroi.GetPhrase("Panel.DisableHoverTextP"))
AddBox(panel,"metrostroi_screenshotmode",Metrostroi.GetPhrase("Panel.ScreenshotMode"))
AddBox(panel,"metrostroi_shadows1",Metrostroi.GetPhrase("Panel.ShadowsHeadlight"))
AddBox(panel,"metrostroi_shadows3",Metrostroi.GetPhrase("Panel.RedLights"))
AddBox(panel,"metrostroi_shadows2",Metrostroi.GetPhrase("Panel.ShadowsOther"))
AddBox(panel,"metrostroi_shadows4",Metrostroi.GetPhrase("Panel.PanelLights"))
AddBox(panel,"metrostroi_sprites",Metrostroi.GetPhrase("Panel.PanelSprites"))
panel:CheckBox(Metrostroi.GetPhrase("Panel.DrawCams"),"metrostroi_drawcams")
panel:CheckBox(Metrostroi.GetPhrase("Panel.DisableHUD"),"metrostroi_disablehud")
panel:CheckBox(Metrostroi.GetPhrase("Panel.DisableCamAccel"),"metrostroi_disablecamaccel")
panel:CheckBox(Metrostroi.GetPhrase("Panel.DisableHoverText"),"metrostroi_disablehovertext")
panel:CheckBox(Metrostroi.GetPhrase("Panel.DisableHoverTextP"),"metrostroi_disablehovertextpos")
panel:CheckBox(Metrostroi.GetPhrase("Panel.ScreenshotMode"),"metrostroi_screenshotmode")
panel:CheckBox(Metrostroi.GetPhrase("Panel.ShadowsHeadlight"),"metrostroi_shadows1")
panel:CheckBox(Metrostroi.GetPhrase("Panel.RedLights"),"metrostroi_shadows3")
panel:CheckBox(Metrostroi.GetPhrase("Panel.ShadowsOther"),"metrostroi_shadows2")
panel:CheckBox(Metrostroi.GetPhrase("Panel.PanelLights"),"metrostroi_shadows4")
panel:CheckBox(Metrostroi.GetPhrase("Panel.PanelSprites"),"metrostroi_sprites")
local DRouteNumber = panel:TextEntry(Metrostroi.GetPhrase("Panel.RouteNumber"),"metrostroi_route_number")
AddBox(panel,"metrostroi_minimizedshow",Metrostroi.GetPhrase("Panel.MinimizedShow"))
AddSlider(panel,"metrostroi_cabfov",Metrostroi.GetPhrase("Panel.FOV"),65,100)
AddSlider(panel,"metrostroi_cabz",Metrostroi.GetPhrase("Panel.Z"),-10,10,true)
AddSlider(panel,"metrostroi_renderdistance",Metrostroi.GetPhrase("Panel.RenderDistance"),960,3072)
panel:CheckBox(Metrostroi.GetPhrase("Panel.MinimizedShow"),"metrostroi_minimizedshow")
panel:NumSlider(Metrostroi.GetPhrase("Panel.FOV"),"metrostroi_cabfov",65,100)
panel:NumSlider(Metrostroi.GetPhrase("Panel.Z"),"metrostroi_cabz",-10,10)
panel:NumSlider(Metrostroi.GetPhrase("Panel.RenderDistance"),"metrostroi_renderdistance",960,3072)
panel:Button(Metrostroi.GetPhrase("Panel.ReloadClient"),"metrostroi_reload_client",true)
function DRouteNumber:OnChange()
@@ -72,14 +59,12 @@ local function ClientAdvanced(panel)
panel:SetPadding(0)
panel:SetSpacing(0)
panel:Dock( FILL )
AddBox(panel,"metrostroi_drawdebug",Metrostroi.GetPhrase("Panel.DrawDebugInfo"))
AddBox(panel,"metrostroi_drawsignaldebug",Metrostroi.GetPhrase("Panel.DrawSignalDebugInfo"))
panel:CheckBox(Metrostroi.GetPhrase("Panel.DrawDebugInfo"),"metrostroi_drawdebug")
panel:CheckBox(Metrostroi.GetPhrase("Panel.DrawSignalDebugInfo"),"metrostroi_drawsignaldebug")
panel:Button(Metrostroi.GetPhrase("Panel.CheckAddons"),"metrostroi_addons_check")
panel:Button(Metrostroi.GetPhrase("Panel.ReloadLang"),"metrostroi_language_reload",true)
AddSlider(panel,"metrostroi_softdrawmultipier",Metrostroi.GetPhrase("Panel.SoftDraw"),25,400)
AddBox(panel,"metrostroi_language_softreload",Metrostroi.GetPhrase("Panel.SoftReloadLang"))
--panel:AddControl("combobox","metrostroi_language",{Label="Language", options = {"Русский","Английский"}})
--panel:AddControl("Checkbox",{Label="Draw debugging info", Command = "metrostroi_drawdebug"})
panel:NumSlider(Metrostroi.GetPhrase("Panel.SoftDraw"),"metrostroi_softdrawmultipier",25,400)
panel:CheckBox(Metrostroi.GetPhrase("Panel.SoftReloadLang"),"metrostroi_language_softreload")
end
hook.Add("PopulateToolMenu", "Metrostroi cpanel", function()

View File

@@ -405,7 +405,7 @@ end
local function OpenConfigWindow()
local Panel = vgui.Create("DFrame")
Panel:SetPos(surface.ScreenWidth()/5,surface.ScreenHeight()/3)
Panel:SetPos(ScrW()/5,ScrH()/3)
Panel:SetSize(250,250)
Panel:SetTitle("Metrostroi Debugger Config")
Panel:SetVisible(true)
@@ -414,13 +414,10 @@ local function OpenConfigWindow()
Panel:MakePopup()
List = vgui.Create("DPanelList",Panel)
List = vgui.Create("DScrollPanel",Panel)
List:SetPos(10,30)
List:SetSize(200,200)
List:SetSpacing(5)
List:EnableHorizontal(false)
List:EnableVerticalScrollbar(true)
for k,v in pairs(Debugger.DisplayGroups) do
local Box = vgui.Create("DCheckBoxLabel")
@@ -431,6 +428,8 @@ local function OpenConfigWindow()
Box:SetValue(0)
end -- TODO: Do this nicer somehow
Box:SizeToContents()
Box:Dock(TOP)
Box:DockMargin(0,2,0,2)
List:AddItem(Box)
Box.OnChange = function() EnableGroup(v,Box:GetChecked()) end
end
@@ -590,7 +589,7 @@ end
--Checks if we haven't gotten data from entid in a while
local function isTimedOut(id)
local timeout = GetConVarNumber("metrostroi_debugger_data_timeout")
local timeout = GetConVar("metrostroi_debugger_data_timeout"):GetFloat()
return timeout ~= nil and timeout > 0 and CurTime() - Debugger.EntDataTime[id] > timeout
end
@@ -618,7 +617,7 @@ hook.Add( "HUDPaint", "metrostroi-draw-system-debugger", function()
if Debugger.EntData ~= nil then
local localy = 15 --+ 65
if GetConVarNumber("developer") then
if GetConVar("developer"):GetInt() then
localy = 77
end

View File

@@ -9,7 +9,7 @@ end
Metrostroi.Languages = Metrostroi.Languages or {}
Metrostroi.ChoosedLang = GetConVarString("metrostroi_language")
Metrostroi.ChoosedLang = GetConVar("metrostroi_language"):GetString()
function Metrostroi.GetPhrase(phrase)
if Metrostroi.CurrentLanguageTable and not Metrostroi.CurrentLanguageTable[phrase] then
MsgC(Color(255,0,0),"No phrase:",Color(0,255,0),phrase,"\n")
@@ -28,17 +28,17 @@ end
if not file.Exists("metrostroi_data","DATA") then file.CreateDir("metrostroi_data") end
if not file.Exists("metrostroi_data/languages","DATA") then file.CreateDir("metrostroi_data/languages") end
local function debugmsg(...)
if GetConVarNumber("metrostroi_drawdebug") == 0 then return end
if GetConVar("metrostroi_drawdebug"):GetInt() == 0 then return end
MsgC(...)
MsgC("\n")
end
local function errmsg(...)
if GetConVarNumber("metrostroi_drawdebug") == 0 then return end
if GetConVar("metrostroi_drawdebug"):GetInt() == 0 then return end
MsgC(...)
ErrorNoHalt("\n")
end
local function errnhmsg(...)
if GetConVarNumber("metrostroi_drawdebug") == 0 then return end
if GetConVar("metrostroi_drawdebug"):GetInt() == 0 then return end
ErrorNoHalt(...)
end
function Metrostroi.LoadLanguage(lang,force)
@@ -139,7 +139,7 @@ function Metrostroi.LoadLanguage(lang,force)
debugmsg(Color(255,0,255),"Add language ",lang," phrase:\t",Color(0,255,0),id,Color(255,0,255),"=",Color(0,255,0),phrase)
end
end
if force or GetConVarNumber("metrostroi_language_softreload")~=1 then
if force or GetConVar("metrostroi_language_softreload"):GetInt()~=1 then
RunConsoleCommand("spawnmenu_reload")
hook.Run( "GameContentChanged" )
end
@@ -304,7 +304,7 @@ local function reloadLang()
Metrostroi.LoadLanguage(Metrostroi.ChoosedLang)
if not Metrostroi.CurrentLanguageTable then
Metrostroi.ChoosedLang = GetConVarString("gmod_language")
Metrostroi.ChoosedLang = GetConVar("gmod_language"):GetString()
if not Metrostroi.Languages[Metrostroi.ChoosedLang] then Metrostroi.ChoosedLang = "en" end
RunConsoleCommand("metrostroi_language",Metrostroi.ChoosedLang)
end

View File

@@ -95,7 +95,7 @@ local function OpenConfigWindow()
--Main frame
local Frame = vgui.Create("DFrame")
Frame:SetPos(surface.ScreenWidth()/5,surface.ScreenHeight()/3)
Frame:SetPos(ScrW()/5,ScrH()/3)
Frame:SetSize(250,400)
Frame:SetTitle("Metrostroi Track Recorder")
Frame:SetVisible(true)
@@ -117,7 +117,7 @@ local function OpenConfigWindow()
--Label for path recording panel
local PathL = AddLabel(PathPanel,"Path Recording")
PathL:Dock(TOP)
PathL:SetDark(true)
PathL:SetTextColor(Color(3,3,3))
--Start/stop buttons
local b1 = AddButton(PathPanel,"metrostroi_trackeditor_start","Start","Start recording a new path")
@@ -135,7 +135,7 @@ local function OpenConfigWindow()
--Label for save/load panel
local FileL = AddLabel(LoadPanel,"Save/load to file")
FileL:Dock(TOP)
FileL:SetDark(true)
FileL:SetTextColor(Color(3,3,3))
--Save/load buttons
local b1 = AddButton(LoadPanel,"metrostroi_trackeditor_load","Load","Load the map's track data file")

View File

@@ -23,7 +23,7 @@ end
local function EditCSEnts()
local CSFrame = vgui.Create("DFrame",Frame)
local _,y = Frame:GetSize()
CSFrame:SetPos(surface.ScreenWidth()/5+250,surface.ScreenHeight()/3-400/2+y/2)
CSFrame:SetPos(ScrW()/5+250,ScrH()/3-400/2+y/2)
CSFrame:SetSize(400,420)
CSFrame:SetTitle("CSEnts editor")
CSFrame:SetVisible(true)
@@ -292,7 +292,7 @@ end
local function EditPanel()
local PanelFrame = vgui.Create("DFrame",Frame)
local _,y = Frame:GetSize()
PanelFrame:SetPos(surface.ScreenWidth()/5+250,surface.ScreenHeight()/3-400/2+y/2)
PanelFrame:SetPos(ScrW()/5+250,ScrH()/3-400/2+y/2)
PanelFrame:SetSize(400,420)
PanelFrame:SetTitle("Panel editor")
PanelFrame:SetVisible(true)
@@ -364,7 +364,7 @@ end
local function EditCLPFB()
local CLPFBFrame = vgui.Create("DFrame",Frame)
local _,y = Frame:GetSize()
CLPFBFrame:SetPos(surface.ScreenWidth()/5+250,surface.ScreenHeight()/3-400/2+y/2)
CLPFBFrame:SetPos(ScrW()/5+250,ScrH()/3-400/2+y/2)
CLPFBFrame:SetSize(400,420)
CLPFBFrame:SetTitle("ClientPropForButton editor")
CLPFBFrame:SetVisible(true)
@@ -543,7 +543,7 @@ local function markEntity(self)
UtilsPanel:Dock(TOP)
local UtilsL = AddLabel(UtilsPanel,"Edit a:")
UtilsL:Dock(TOP)
UtilsL:SetDark(true)
UtilsL:SetTextColor(Color(3,3,3))
--Start/stop buttons
local b1 = AddButton(UtilsPanel,EditCSEnts,"CSEnts","Edits a panel in train"):Dock(TOP)
@@ -552,7 +552,7 @@ local function markEntity(self)
Frame:SetSize(250,210)
else
local Frame = vgui.Create("DFrame")
Frame:SetPos(surface.ScreenWidth()/5,surface.ScreenHeight()/3)
Frame:SetPos(ScrW()/5,ScrH()/3)
Frame:SetSize(250,85)
Frame:SetTitle("Warning")
Frame:SetVisible(true)
@@ -570,7 +570,7 @@ local function OpenConfigWindow()
--Main frame
if not IsValid(Frame) then
Frame = vgui.Create("DFrame")
Frame:SetPos(surface.ScreenWidth()/5,surface.ScreenHeight()/3)
Frame:SetPos(ScrW()/5,ScrH()/3)
Frame:SetSize(250,100)
Frame:SetTitle("Metrostroi train editor")
Frame:SetVisible(true)

View File

@@ -637,7 +637,7 @@ hook.Add("PostDrawOpaqueRenderables", "metrostroi-draw-stopmarker",function()
prevTime = RealTime()
-- Skip if disabled
if GetConVarNumber("metrostroi_stop_helper") ~= 1 then return end
if GetConVar("metrostroi_stop_helper"):GetInt() ~= 1 then return end
-- Get train
local train = LocalPlayer().InMetrostroiTrain

View File

@@ -69,7 +69,7 @@ end
local nextthink = 0
local function think()
if CurTime() < nextthink then return end
nextthink = CurTime() + GetConVarNumber("metrostroi_debugger_update_interval")
nextthink = CurTime() + GetConVar("metrostroi_debugger_update_interval"):GetFloat()
--Loop over clients and their ents and send the collected data
--Check for new entity variables

View File

@@ -550,7 +550,7 @@ function Metrostroi.ScanTrack(itype,node,func,x,dir,checked)
end
-- Show the scanned path
--[[if GetConVarNumber("metrostroi_drawdebug") == 1 then
--[[if GetConVar("metrostroi_drawdebug"):GetInt() == 1 then
local T = CurTime()
timer.Simple(0.05 + math.random()*0.05,function()
if node.next then

View File

@@ -95,9 +95,9 @@ function Metrostroi.HTTPRequest(request)
if status and (status ~= "timeout") then
local data = string.Explode("\r\n\r\n",http_data)
table.remove(data,1)
local content = string.Implode("\n\n",data)
local content = table.concat(data,"\n\n")
timer.Destroy("Metrostroi_HTTPRequest")
timer.Remove("Metrostroi_HTTPRequest")
onSuccess(content)
end
end)

View File

@@ -102,7 +102,8 @@ end
local function TeleEnd(args,ply)
if #args > 0 then
ply:SetPos(table.GetLastValue(Metrostroi.TrackEditor.Paths[tonumber(args[1])]))
local tbl = Metrostroi.TrackEditor.Paths[tonumber(args[1])]
ply:SetPos(tbl[#tbl])
end
end
@@ -118,7 +119,8 @@ end
local function TeleEntEnd(args,ply)
if #args > 0 and IsValid(Train) then
Train:SetPos(table.GetLastValue(Metrostroi.TrackEditor.Paths[tonumber(args[1])]))
local tbl = Metrostroi.TrackEditor.Paths[tonumber(args[1])]
Train:SetPos(ply:SetPos(tbl[#tbl]))
if Train.Base == "gmod_subway_base" then
Metrostroi.RerailTrain(Train)
@@ -207,7 +209,7 @@ local function Think()
end
-- Unused
local function ClientDraw()
if GetConVarNumber("metrostroi_drawsignaldebug") <= 0 then return end
if GetConVar("metrostroi_drawsignaldebug"):GetInt() <= 0 then return end
if #Metrostroi.TrackEditor.Paths == 0 then return end
local lastpos

View File

@@ -173,8 +173,8 @@ if Turbostroi and not TURBOSTROI then
cvars.AddChangeCallback("turbostroi_train_cores", function(cvar, old, value)
Turbostroi.SetSTAffinityMask(tonumber(value) or 254) -- 0 - disabled --NEWTURBOSTROI
end, "turbostroi")
Turbostroi.SetMTAffinityMask(GetConVarNumber("turbostroi_main_cores") or 1) -- CPU5 CPU4 on 6 core --NEWTURBOSTROI
Turbostroi.SetSTAffinityMask(GetConVarNumber("turbostroi_train_cores") or 254) -- 0 - disabled --NEWTURBOSTROI
Turbostroi.SetMTAffinityMask(GetConVar("turbostroi_main_cores"):GetInt() or 1) -- CPU5 CPU4 on 6 core --NEWTURBOSTROI
Turbostroi.SetSTAffinityMask(GetConVar("turbostroi_train_cores"):GetInt() or 254) -- 0 - disabled --NEWTURBOSTROI
Turbostroi.SetSimulationFPS(FPS)
hook.Add("Think", "Turbostroi_Think", function()
if not Turbostroi then return end

View File

@@ -533,12 +533,12 @@ hook.Add("Think", "Metrostroi_ElectricConsumptionThink", function()
--Metrostroi.Current = Metrostroi.Current + Iperson
-- Check if exceeded global maximum current
if Metrostroi.Current > GetConVarNumber("metrostroi_current_limit") then
if Metrostroi.Current > GetConVar("metrostroi_current_limit"):GetInt() then
Metrostroi.VoltageRestoreTimer = CurTime() + 7.0
print(Format("[!] Power feed protection tripped: current peaked at %.1f A",Metrostroi.Current))
end
local voltage = math.max(0,GetConVarNumber("metrostroi_voltage"))
local voltage = math.max(0,GetConVar("metrostroi_voltage"):GetInt())
-- Calculate new voltage
local Rfeed = 0.03 --25

View File

@@ -212,10 +212,10 @@ function TRAIN_SYSTEM:Think(dT)
self.Signal0 = ars:GetARS(0,Train) or ars:GetARS(2,Train)
self.Special = ars:Get325HzAproove0() and not ars:GetARS(2,Train)
self.NoFreq = ars:GetARS(1,Train) or not (self.Signal80 or self.Signal70 or self.Signal60 or self.Signal40 or self.Signal0)
if GetConVarNumber("metrostroi_ars_printnext") == Train:EntIndex() then RunConsoleCommand("say",ars.Name,tostring(arsback and arsback.Name),tostring(ars.NextSignalLink and ars.NextSignalLink.Name or "unknown"),tostring(pos.node1.path.id),tostring(Metrostroi.TrainDirections[Train])) end
if GetConVar("metrostroi_ars_printnext"):GetInt() == Train:EntIndex() then RunConsoleCommand("say",ars.Name,tostring(arsback and arsback.Name),tostring(ars.NextSignalLink and ars.NextSignalLink.Name or "unknown"),tostring(pos.node1.path.id),tostring(Metrostroi.TrainDirections[Train])) end
self.RealNoFreq = not (self.Signal80 or self.Signal70 or self.Signal60 or self.Signal40 or self.Signal0)
else
if GetConVarNumber("metrostroi_ars_printnext") == Train:EntIndex() then RunConsoleCommand("say","LOSE SIGNAL",tostring(pos and pos.node1.path.id or "unknown"),tostring(Metrostroi.TrainDirections[Train])) end
if GetConVar("metrostroi_ars_printnext"):GetInt() == Train:EntIndex() then RunConsoleCommand("say","LOSE SIGNAL",tostring(pos and pos.node1.path.id or "unknown"),tostring(Metrostroi.TrainDirections[Train])) end
if (self.CheckedNF and self.CheckedNF > 1) or (self.CheckedNF == 0 and self.NoFreq) or self.RealNoFreq then
self.Alert = nil
self.Signal80 = false

View File

@@ -135,7 +135,7 @@ function TRAIN_SYSTEM:Think(dT)
--if self.NoFreqTimer and CurTime()-self.NoFreqTimer > 2 then self.NoFreqTimer = false end
--self.NoFreq = (NoFreq and self.NoFreqTimer == false) and 1 or 0
self.NoFreq = NoFreq and 1 or 0
if GetConVarNumber("metrostroi_ars_printnext") == Train:GetWagonNumber() then RunConsoleCommand("say",ars.Name,tostring(arsback and arsback.Name),tostring(ars.NextSignalLink and ars.NextSignalLink.Name or "unknown"),tostring(pos.node1.path.id),tostring(Metrostroi.TrainDirections[Train])) end
if GetConVar("metrostroi_ars_printnext"):GetInt() == Train:GetWagonNumber() then RunConsoleCommand("say",ars.Name,tostring(arsback and arsback.Name),tostring(ars.NextSignalLink and ars.NextSignalLink.Name or "unknown"),tostring(pos.node1.path.id),tostring(Metrostroi.TrainDirections[Train])) end
elseif self.Enabled > 0 then
if self.NoFreqTimer == nil then self.NoFreqTimer = CurTime() end

View File

@@ -25,7 +25,7 @@ function ulx.wagoncount( calling_ply )
ulx.fancyLog("#s wagons have #s",v,(type(k) == "Player" and IsValid(k)) and k:GetName() or k)
end
end
ulx.fancyLog("Max trains: #s.\nMax wagons: #s.\nMax trains per player: #s", GetConVarNumber("metrostroi_maxtrains"), GetConVarNumber("metrostroi_maxwagons"), GetConVarNumber("metrostroi_maxtrains_onplayer"))
ulx.fancyLog("Max trains: #s.\nMax wagons: #s.\nMax trains per player: #s", GetConVar("metrostroi_maxtrains"):GetInt(), GetConVar("metrostroi_maxwagons"):GetInt(), GetConVar("metrostroi_maxtrains_onplayer"):GetInt())
end
local wagons = ulx.command( CATEGORY_NAME, "ulx trains", ulx.wagoncount, "!trains" )
wagons:defaultAccess( ULib.ACCESS_ALL )
@@ -384,7 +384,7 @@ end
function ulx.trainfuck(calling_ply, target_plys)
local affected_plys = {}
local gm = GetConVarNumber("sbox_godmode")
local gm = GetConVar("sbox_godmode"):GetInt()
if gm > 0 then RunConsoleCommand("sbox_godmode",0) end
for i=1, #target_plys do
local v = target_plys[ i ]

View File

@@ -564,7 +564,7 @@ function TOOL:BuildCPanelCustom()
if not CPanel then return end
--("signalling_signaldata",util.TableToJSON(tool.Signal))
--tool.Type = GetConVarNumber("signalling_type") or 1
tool.RouteType = GetConVarNumber("signalling_routetype") or 1
tool.RouteType = GetConVar("signalling_routetype"):GetInt() or 1
CPanel:ClearControls()
CPanel:SetPadding(0)
CPanel:SetSpacing(0)
@@ -1497,9 +1497,9 @@ end
TOOL.NotBuilt = true
function TOOL:Think()
if CLIENT and (self.NotBuilt or NeedUpdate) then
self.Signal = self.Signal or util.JSONToTable(string.Replace(GetConVarString("signalling_signaldata"),"'","\"")) or {}
self.Sign = self.Sign or util.JSONToTable(string.Replace(GetConVarString("signalling_signdata"),"'","\"")) or {}
self.Auto = self.Auto or util.JSONToTable(string.Replace(GetConVarString("signalling_autodata"),"'","\"")) or {}
self.Signal = self.Signal or util.JSONToTable(string.Replace(GetConVar("signalling_signaldata"):GetString(),"'","\"")) or {}
self.Sign = self.Sign or util.JSONToTable(string.Replace(GetConVar("signalling_signdata"):GetString(),"'","\"")) or {}
self.Auto = self.Auto or util.JSONToTable(string.Replace(GetConVar("signalling_autodata"):GetString(),"'","\"")) or {}
self:SendSettings()
self:BuildCPanelCustom()
self.NotBuilt = nil
@@ -1507,7 +1507,8 @@ function TOOL:Think()
end
end
function TOOL.BuildCPanel(panel)
panel:AddControl("Header", { Text = "#Tool.signalling.name", Description = "#Tool.signalling.desc" })
panel:SetName("#Tool.signalling.name")
panel:Help("#Tool.signalling.desc")
if not self then return end
self:BuildCPanelCustom()
end

View File

@@ -87,12 +87,16 @@ end
function TOOL.BuildCPanel(panel)
panel = panel or controlpanel.Get("switch")
panel:AddControl("Header", { Text = "#Tool.switch.name", Description = "#Tool.switch.desc" })
panel:AddControl("TextBox", { Label = "Name", Command = "switch_name" })
panel:AddControl("ComboBox", { Label = "Channel", Options = {None={switch_channel = 0},["1"] ={switch_channel = 1},["2"] ={switch_channel = 2}}})
panel:AddControl("Checkbox", { Label = "Locked", Command = "switch_locked" })
panel:AddControl("Checkbox", { Label = "Controllable", Command = "switch_controllable" })
panel:AddControl("Checkbox", { Label = "Invert", Command = "switch_invert" })
panel:SetName("#Tool.switch.name")
panel:Help("#Tool.switch.desc")
panel:TextEntry("Name","switch_name")
local CBChannel = panel:ComboBox( "Channel", "switch_channel" )
CBChannel:AddChoice("None",0)
CBChannel:AddChoice("1",1)
CBChannel:AddChoice("2",2)
panel:CheckBox("Locked","switch_locked")
panel:CheckBox("Controllable","switch_controllable")
panel:CheckBox("Invert","switch_invert")
end

View File

@@ -2,6 +2,8 @@
--local TOOL = player.GetBySteamID("STEAM_0:1:31566374"):GetTool("train_spawner")
TOOL.AddToMenu = false
local C_MaxWagons = GetConVar("metrostroi_maxwagons")
if CLIENT then
language.Add("Tool.train_spawner.name", "Train Spawner")
language.Add("Tool.train_spawner.desc", "Spawn a train")
@@ -162,7 +164,7 @@ function TOOL:Think()
e.GetDirtLevel = function() return 0.25 end
end
hook.Add("Think",self.GhostEntities[1],function()
if not IsValid(self.Owner:GetActiveWeapon()) or self.Owner:GetActiveWeapon():GetClass()~="gmod_tool" or GetConVarString("gmod_toolmode") ~= "train_spawner" then
if not IsValid(self.Owner:GetActiveWeapon()) or self.Owner:GetActiveWeapon():GetClass()~="gmod_tool" or GetConVar("gmod_toolmode"):GetString() ~= "train_spawner" then
self:OnRemove()
end
end)
@@ -440,12 +442,12 @@ function TOOL:LeftClick(trace)
end
if not self.AllowSpawn or not self.Train then return end
if SERVER then
if self.Settings.WagNum > GetConVarNumber("metrostroi_maxwagons") then
self.Settings.WagNum = GetConVarNumber("metrostroi_maxwagons")
if self.Settings.WagNum > C_MaxWagons:GetInt() then
self.Settings.WagNum = C_MaxWagons:GetInt()
end
if Metrostroi.TrainCountOnPlayer(self:GetOwner()) + self.Settings.WagNum > GetConVarNumber("metrostroi_maxtrains_onplayer")*GetConVarNumber("metrostroi_maxwagons")
or Metrostroi.TrainCount() + self.Settings.WagNum > GetConVarNumber("metrostroi_maxtrains")*GetConVarNumber("metrostroi_maxwagons") then
if Metrostroi.TrainCountOnPlayer(self:GetOwner()) + self.Settings.WagNum > GetConVar("metrostroi_maxtrains_onplayer"):GetInt()*C_MaxWagons:GetInt()
or Metrostroi.TrainCount() + self.Settings.WagNum > GetConVar("metrostroi_maxtrains"):GetInt()*C_MaxWagons:GetInt() then
self:GetOwner():LimitHit("train_limit")
return true
end
@@ -500,7 +502,8 @@ function TOOL:RightClick(trace)
end
function TOOL.BuildCPanel(panel)
panel:AddControl("Header", { Text = "#Tool.train_spawner.name", Description = "#Tool.train_spawner.desc" })
panel:SetName("#Tool.train_spawner.name")
panel:Help("#Tool.train_spawner.desc")
end
if SERVER then