Skip to content
Пупсич edited this page Jun 13, 2026 · 1 revision

Initialization

local utils = require("YAPZLib/Utils")

Functions

utils.debugLog(_log) -- prints log only if debug is enabled

[sting] _log

returns nil


utils.checkArgs(...) -- checks incoming argumets | 1.Argument 2.Type/Class 3.NilCheck

-- usage example

local function(self, vehicle, x, y, vehicleName, skin)
    local types = utils.checkArgs(
        self, "ISReplaceVehicle", true, -- supports metatable types defined in table.Type
        vehicle, "BaseVehicle", true, -- supports Java-classes
        x, "number", false, -- value can be nil, so there is no need to check it
        y, "number", false, -- same
        vehicleName, "string | list", true, -- supports several classes
        skin, "integer", false - only integer numbers
    )
    if not types then return end
    
    if types[5] == string then -- vehicleName type
        ...
    end
end

-- or just

if not utils.checkArgs(
    vehicle, "BaseVehicle", true,
    x, "number", false,
    y, "number", false
) then return end

returns [boolean] false or table types

Usable Lua-types:

  • "nil" - used to skip type/class check
  • "function"
  • "string"
  • "boolean"
  • "integer"
  • "number" - all numbers, float and integer
  • "list" - table [i] = value
  • "map" - table [key] = value
  • "table" - any table

utils.formatCamelCase(str) -- converts strings like "okakOkak" to "okak Okak"

[sting] str

returns [sting] formattedString


utils.tableIsEmpty(tab)

[table] tab

returns [boolean] true or false


utils.copyTable(tab)

[table] tab

returns [table] copy


utils.clearTable(tab)

[table] tab

returns nil


utils.getGlobalObject(name) -- returns objects from global environment

[string] name

returns _G[field_1][...][field_n][finalObject] if name type of "field_1.[...].field_n.finalObject" or _G[name]


utils.invertAngle(angle)

[number] angle

returns [number] invertedAngle


utils.getSquaresInRadius(posx, posy, z, radius)

[integer] posx

[integer] posy

[integer] z

[integer] radius

returns [table] squares


utils.delay(func, ticks, ...) -- delays function on certain amout of ticks | ... - arguments of delayed function

-- usage example

utils.delay(function(var1, var2)
    ...
end, 3, var1, var2) -- 3 ticks delay

-- or

local f = function()
    ...
end

utils.delay(f, 1)

[function] func

[integer] ticks

returns nil


utils.cellIsModded(cellX, cellY) -- check if cell is loaded by map mod

[integer] cellX

[integer] cellX

returns [boolean] true or false


utils.cellIsModded(x, y) -- returns cell coordinates from usual

[number] x

[number] y

returns [integer] cellX, [integer] cellY


utils.clearContainer(container)

[ItemContainer] container

returns nil


utils.refillContainer(obj, roomName, containerType, procName, junk)

[IsoObject] obj

[string] roomName

[string] containerType

[string] procName

[boolean] junk

returns nil

Clone this wiki locally