Skip to content

Commit

Permalink
omit FONT:Exists as it does not work anymore (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
jule14 authored Mar 4, 2024
1 parent 5db9b29 commit fd48276
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ which should be the same between all instances of a game are not reloaded unnecc

`FONT:Exists(name)`

Used to check if a font has already been created. Do not use `surface.CreateFont` without first checking if the font has already been created as it is expensive!
Has stopped working following an update to GMod, don't use!

~~Used to check if a font has already been created. Do not use `surface.CreateFont` without first checking if the font has already been created as it is expensive!~~

#### Images

Expand Down
4 changes: 2 additions & 2 deletions lua/arcade_cabinet_games/2048.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ for i = 1, 11 do
}
end

if not FONT:Exists("2048_title") then
--if not FONT:Exists("2048_title") then
surface.CreateFont("2048_title", {
size = 80,
weight = 800,
Expand All @@ -202,7 +202,7 @@ if not FONT:Exists("2048_title") then
weight = 800,
font = "Roboto"
})
end
--end

local GAME = {}

Expand Down
8 changes: 4 additions & 4 deletions lua/arcade_cabinet_games/blitz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local gameOverAt = 0
local gameState = 0


if not FONT:Exists("CustomFont0022") then
--if not FONT:Exists("CustomFont0022") then
surface.CreateFont("CustomFont0022",
{ font = "Consolas",
extended = false,
Expand All @@ -54,9 +54,9 @@ if not FONT:Exists("CustomFont0022") then
additive = false,
outline = false
})
end
--end

if not FONT:Exists("CustomFont0023") then
--if not FONT:Exists("CustomFont0023") then
surface.CreateFont("CustomFont0023",
{ font = "Consolas",
extended = false,
Expand All @@ -73,7 +73,7 @@ if not FONT:Exists("CustomFont0023") then
additive = false,
outline = false
})
end
--end

--<variables>
local state = 9
Expand Down
26 changes: 13 additions & 13 deletions lua/arcade_cabinet_games/snake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
-- https://github.com/ukgamer/gmod-arcademachines
-- Made by Jule

if not FONT:Exists( "Snake32" ) then
surface.CreateFont( "Snake32", {
--if not FONT:Exists("Snake32") then
surface.CreateFont("Snake32", {
font = "Trebuchet MS",
size = 32,
weight = 500,
antialias = 1,
additive = 1
} )
end
})
--end

if not FONT:Exists( "SnakeTitle" ) then
surface.CreateFont( "SnakeTitle", {
--if not FONT:Exists("SnakeTitle") then
surface.CreateFont("SnakeTitle", {
font = "Trebuchet MS",
size = 70,
italic = true,
weight = 500,
antialias = 1,
additive = 1
} )
end
})
--end

local function PlayLoaded( loaded )
if IsValid( SOUND.Sounds[loaded].sound ) then
SOUND.Sounds[loaded].sound:SetTime( 0 )
local function PlayLoaded(loaded)
if IsValid(SOUND.Sounds[loaded].sound) then
SOUND.Sounds[loaded].sound:SetTime(0)
SOUND.Sounds[loaded].sound:Play()
end
end

local function StopLoaded( loaded )
if IsValid( SOUND.Sounds[loaded].sound ) then
local function StopLoaded(loaded)
if IsValid(SOUND.Sounds[loaded].sound) then
SOUND.Sounds[loaded].sound:Pause()
end
end
Expand Down
3 changes: 2 additions & 1 deletion lua/arcade_cabinet_lib/font.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local FONT = {}

function FONT:Exists(name)
return pcall(function() surface.SetFont(name) end)
return false
-- return pcall(function() surface.SetFont(name) end)
end

return FONT

0 comments on commit fd48276

Please sign in to comment.