This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UNIT = setmetatable({}, { | |
__index = { | |
KILOMETRE = 1; | |
METER = 2; | |
CENTIMETRE = 3; | |
MILE = 3; | |
INCH = 4; | |
FOOT = 5; | |
}; | |
__metatable = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# New version/preview: https://i.imgur.com/xsq3MJ7.png | |
# Old version/preview: https://i.imgur.com/2F23MlA.png | |
if (first()) | |
{ | |
function number percentOfValueInRange(Min, Max, Value) | |
{ | |
return ((Min - Value) / (Min - Max)) * 100 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Simple Starfall chip code viewer/hacker (addon: https://github.com/thegrb93/StarfallEx). | |
-- | |
local sf = SF | |
if (not istable(sf)) then | |
return | |
end | |
local allInstances = sf.allInstances | |
if (not istable(allInstances)) then | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array getPlayersNameSubstr(Length) | |
{ | |
local Result = array() | |
local Players = players() | |
for (Index = 1, Players:count()) | |
{ | |
local Player = Players[Index, entity] | |
Result:pushString(Player:name():sub(1, Length)) | |
} | |
return Result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local NAN = 0.0 / 0.0 | |
local NINF = -math.huge | |
local PINF = math.huge | |
--- Returns true if given value is a finite number; otherwise false or nil if value is not of type string nor number. | |
function math.finite(value) | |
if type(value) == "string" then | |
value = tonumber(value) | |
if value == nil then return nil end | |
elseif type(value) ~= "number" then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Localization of used libraries/functions, as an access to local (upvalues) is faster than global. | |
local file = file | |
local file_Delete, file_Find = file.Delete, file.Find | |
local file_DeleteDir -- Separate declaration from definition (since it is a recursive function). | |
--- A function to recursively remove/delete files and sub-directories. | |
--- gate_folder_name: Name of the folder for the Editor mode (e.g. expression2). | |
--- selected_folder_path: Directory (relative to gate_folder_name) to be deleted/removed. | |
file_DeleteDir = function(gate_folder_name, selected_folder_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Whatever I have tried... It just simply did not increment Dollhouse achievement, it seems it is "protected" in some awkward way. | |
-- See: https://imgur.com/a/mT7aA | |
--local DollhouseID = 25 | |
--[[hook.Add("Think", "Dollhouse achievement unlocker", function() | |
if achievements.GetCount(DollhouseID) < achievements.GetGoal(DollhouseID) then | |
achievements.SpawnedRagdoll() | |
print(achievements.GetName(DollhouseID), achievements.GetCount(DollhouseID) .. " / " .. achievements.GetGoal(DollhouseID)) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local s = [[Hello\u003F World\u0021]] | |
------------------------------------------------------------------------------- | |
local string = string | |
local char, format, gmatch, gsub, sub = string.char, string.format, string.gmatch, string.gsub, string.sub | |
local tonumber = tonumber | |
local UESCAPE_PATTERN = "\\u([0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])" | |
-- Converts a fully uescaped string back to normal. | |
function string:from_uescape() | |
local out = "" | |
for i = 1, #self, 6 do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Made/Published to clear up misinformation, for you to possibly learn something new from it. - CaptainPRICE | |
-- Tell me in the comments (below) if you have spot bug(s), or if you have any suggestions or improvements as I would like to hear them! | |
-- See my comment here: https://github.com/wiremod/wire/pull/1217#issuecomment-246211364 | |
local game = game | |
local IS_DEDICATED, IS_SINGLEPLAYER, MAX_NUM_PLAYERS = game.IsDedicated(), game.SinglePlayer(), game.MaxPlayers() | |
print(CLIENT and "CLIENT" or (SERVER and "SERVER" or "MENU"), IS_SINGLEPLAYER and "SP" or "MP", IS_DEDICATED and "DEDICATED" or "LISTEN", "MAX=" .. MAX_NUM_PLAYERS, "v" .. VERSION, BRANCH) | |
if not debug then return print("debug library is missing") end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local math = math | |
local math_floor = math.floor | |
local error, setmetatable, rawget, tostring, type = error, setmetatable, rawget, tostring, type | |
int = {} | |
do | |
local INT32, INT32_NAME, INT32_SIZE, INT32_DEFAULT, INT32_MAX, INT32_MIN = 3, "int32", 32, 0, 2147483648, -2147483648 | |
local int32 = { | |
__metatable = false, |
OlderNewer