Skip to content

Commit

Permalink
Code cleanup, respecting native Lua syntax more
Browse files Browse the repository at this point in the history
  • Loading branch information
Grocel committed May 14, 2023
1 parent 8eb3c20 commit fcbd0f5
Show file tree
Hide file tree
Showing 16 changed files with 682 additions and 682 deletions.
8 changes: 4 additions & 4 deletions lua/entities/base_streamradio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ else
function ENT:OnEntityCopyTableFinish(data)
local done = {}

// Filter out all variables/members with an storable values
// to avoid any abnormal, invalid or unexpectedly shared entity stats on duping (especially for Garry-Dupe)
-- Filter out all variables/members with an storable values
-- to avoid any abnormal, invalid or unexpectedly shared entity stats on duping (especially for Garry-Dupe)
local function recursive_filter(tab, newtable)
if done[tab] then return tab end
done[tab] = true
Expand Down Expand Up @@ -700,8 +700,8 @@ else
self:OnSetupCopyData(data)
end

// Filter out all variables/members with an underscore in the beginning
// to avoid any abnormal, invalid or unexpectedly shared entity stats on duping (especially for Garry-Dupe)
-- Filter out all variables/members with an underscore in the beginning
-- to avoid any abnormal, invalid or unexpectedly shared entity stats on duping (especially for Garry-Dupe)
for k, v in pairs(data) do
if isstring(k) and #k > 0 and k[1] == "_" then
data[k] = nil
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/sent_streamradio/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function ENT:WiremodThink( )
self:TriggerWireOutput("Playing", self.StreamObj:IsPlaying())
self:TriggerWireOutput("Loading", self.StreamObj:IsLoading() or self.StreamObj:IsBuffering() or self.StreamObj:IsSeeking())

self:TriggerWireOutput("Tag", {}) // todo
self:TriggerWireOutput("Tag", {}) -- todo
self:TriggerWireOutput("Codec", self._codec)
self:TriggerWireOutput("Spectrum", self._spectrum)
self:TriggerWireOutput("Sound Level", self.StreamObj:GetAverageLevel())
Expand Down
8 changes: 4 additions & 4 deletions lua/streamradio_core/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
DisableAdvancedOutputs boolean true True disables the Advanced Wire Outputs.
*/

// ======================================================================
// === Don't edit anything below, unless you know what you are doing. ===
// === Really, you don't need to. Report it to me if you find a bug. ===
// ======================================================================
-- ======================================================================
-- === Don't edit anything below, unless you know what you are doing. ===
-- === Really, you don't need to. Report it to me if you find a bug. ===
-- ======================================================================

local ValidTypes = {
StreamName = "string",
Expand Down
4 changes: 2 additions & 2 deletions lua/streamradio_core/classes/ui/radio/gui_errorbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function CLASS:SetPlaylistError(url)

local text

if url != "" then
if url ~= "" then
text = string.format("Error: Could not open playlist:\n%s\n\nMake sure the file is valid and not Empty\n\nClick help for more details.", url)
else
text = "Error: Could not open playlist!\n\nMake sure the file is valid and not Empty\n\nClick help for more details."
Expand All @@ -99,7 +99,7 @@ function CLASS:SetErrorCode(err, url)
local errordesc = StreamRadioLib.DecodeErrorCode(err)
local text

if url != "" then
if url ~= "" then
text = string.format("Error: %i\n\nCould not play stream:\n%s\n\n%s\n\nClick help for more details.", err, url, errordesc)
else
text = string.format("Error: %i\n\nCould not play stream!\n\n%s\n\nClick help for more details.", err, errordesc)
Expand Down
2 changes: 1 addition & 1 deletion lua/streamradio_core/classes/ui/radio/gui_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function CLASS:SetStream(stream)
if not self.State then return end
if not IsValid(self.Errorbox) then return end

//self.State.Error = 0
-- self.State.Error = 0
end)

self.StreamOBJ:SetEvent("OnConnect", self:GetID(), function()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ local function RenderSpectrumBar(index, level, bars, soundlevel, x, y, w, h, col
local BarX = math.Round(x + (index - 1) * barwide)
local NextBarX = math.Round(x + index * barwide)

// close the bar gaps
-- close the bar gaps
barwide = NextBarX - BarX

local BarY = h + y
Expand Down
6 changes: 3 additions & 3 deletions lua/streamradio_core/client/cl_lib.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--////////////////////////////////////
-- Stream Radio Lip
--////////////////////////////////////
-- ////////////////////////////////////
-- Stream Radio Lip
-- ////////////////////////////////////
local IsValid = IsValid
local tonumber = tonumber
local tostring = tostring
Expand Down
1,294 changes: 647 additions & 647 deletions lua/streamradio_core/client/cl_presets.lua

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lua/streamradio_core/client/cl_vgui_editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -453,36 +453,36 @@ local function FileMenu(self, item, path, name, filetype, parentpath)

--Copy/Paste (Todo)
--[[
if (filetype ~= StreamRadioLib.TYPE_FOLDER and !newfile) then
if (filetype ~= StreamRadioLib.TYPE_FOLDER and not newfile) then
MenuItem = Menu:AddOption("Copy", function()
if ( !IsValid( self ) ) then return end
if ( not IsValid( self ) ) then return end
if ( self:IsLoading() ) then return end
self.Clipboard = path
end)
MenuItem:SetImage("icon16/page_paste.png")
MenuItem = Menu:AddOption("Paste", function()
if ( !IsValid( self ) ) then return end
if ( not IsValid( self ) ) then return end
if ( self:IsLoading() ) then return end
StreamRadioLib.Editor.Copy( self.Clipboard, path )
end)
MenuItem:SetImage("icon16/page_paste.png")
if ( !self.Clipboard or self.Clipboard == "" ) then
if ( not self.Clipboard or self.Clipboard == "" ) then
MenuItem:SetTextColor( Disabled_Gray ) -- custom disabling
MenuItem.DoClick = function() end
end
MenuItem = Menu:AddOption("Cut", function()
if ( !IsValid( self ) ) then return end
if ( not IsValid( self ) ) then return end
if ( self:IsLoading() ) then return end
StreamRadioLib.Editor.Rename( self.Clipboard, path )
self.Clipboard = nil
end)
MenuItem:SetImage("icon16/page_paste.png")
if ( !self.Clipboard or self.Clipboard == "" ) then
if ( not self.Clipboard or self.Clipboard == "" ) then
MenuItem:SetTextColor( Disabled_Gray ) -- custom disabling
MenuItem.DoClick = function() end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/streamradio_core/interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ local function AddCommonFunctions(interface)

nerr.interface = self

if this != self then
if this ~= self then
nerr.subinterface = this
end

Expand Down
6 changes: 3 additions & 3 deletions lua/streamradio_core/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ local StreamRadioLib = StreamRadioLib
local _, NetURL = StreamRadioLib.LoadSH('streamradio_core/neturl.lua')
StreamRadioLib.NetURL = NetURL

// Placeholder for Blocked URLs with non-Keyboard chars
-- Placeholder for Blocked URLs with non-Keyboard chars
StreamRadioLib.BlockedURLCode = string.char(124, 245, 142, 188, 5, 6, 2, 1, 2, 54, 12, 7, 5) .. "___blocked_url"

StreamRadioLib.EDITOR_ERROR_OK = 0
Expand Down Expand Up @@ -245,8 +245,8 @@ function StreamRadioLib.Hash( str )
local rstr = string.reverse(str)
local rsalt = string.reverse(salt)

// There is no other 'hash' than CRC in GMod,
// so inflate it a bit to avoid collisions.
-- There is no other 'hash' than CRC in GMod,
-- so inflate it a bit to avoid collisions.

hash[1] = CRCfloat32(salt)
hash[2] = CRCfloat32("wdwer" .. rstr .. "jakwd")
Expand Down
4 changes: 2 additions & 2 deletions lua/streamradio_core/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ function LIB.AddDTNetworkVar(ent, datatype, name, ...)
assert(name ~= "", "argument #2 is an invalid name!")


//local exists = DTNetworkVarExists(ent, name)
-- local exists = DTNetworkVarExists(ent, name)

//if DTNetworkVarExists(ent, name) then return true end
-- if DTNetworkVarExists(ent, name) then return true end
if not CanAddDTNetworkVar(ent, datatype, name) then return false end

ent.StreamRadioDT = ent.StreamRadioDT or {}
Expand Down
2 changes: 1 addition & 1 deletion lua/streamradio_core/shoutcast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ function LIB.GenreExists(hierarchy)
end

local g_format_blacklist = {
//["audio/mpeg"] = true,
-- ["audio/mpeg"] = true,
}

function LIB.IsValidFormat(format)
Expand Down
4 changes: 2 additions & 2 deletions lua/weapons/gmod_tool/stools/streamradio_gui_color_global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ function TOOL:AddModeList( panel )
local color = data[varname]
if not color then continue end

//local checked = activecheckbox:GetChecked()
//line:SetSortValue(line._activeindex, checked and 1 or 0)
-- local checked = activecheckbox:GetChecked()
-- line:SetSortValue(line._activeindex, checked and 1 or 0)

local oldcolor = colortile:GetColor()
if color == oldcolor then continue end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ function TOOL:AddModeList( panel )
local color = data[varname]
if not color then continue end

//local checked = activecheckbox:GetChecked()
//line:SetSortValue(line._activeindex, checked and 1 or 0)
-- local checked = activecheckbox:GetChecked()
-- line:SetSortValue(line._activeindex, checked and 1 or 0)

local oldcolor = colortile:GetColor()
if color == oldcolor then continue end
Expand Down
4 changes: 2 additions & 2 deletions materials/3dstreamradio/_data/version.vmt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
417
1678219460
418
1684107996

0 comments on commit fcbd0f5

Please sign in to comment.