IMIsle Modkit
Pages in this area

core

Small functions that belong to no namespace, and the Lua environment itself.

print

print(...)

Shared

Writes one log line with the resource name in front. The values are converted with tostring and joined with two spaces.

Side Goes to
Server %LOCALAPPDATA%\IsleModkit\server-plugin.log on the server PC
Client isle-modkit-mod.log next to the client mod DLL, and the F8 console when it is enabled
print("loaded", 3, true)

Log line: [myresource] loaded 3 true

modkit.log

modkit.log(...) modkit.log.info(...) modkit.log.warn(...) modkit.log.error(...)

Shared

modkit.log(...) and modkit.log.info(...) do the same as print. warn and error put WARN or ERROR in front of the text, so you can search the log for it. error only writes a line, it does not stop the script.

modkit.log.warn("no webhook configured")

Log line: [myresource] WARN no webhook configured

modkit.isAdmin

modkit.isAdmin(steamId)

Server

Parameter Type Description
steamId string Steam ID to check

Returns: true when the Steam ID is listed in sv_admins.

if modkit.isAdmin("76561198000000001") then print("is admin") end

Lua version and libraries

Both sides run Lua 5.4.7. Every resource has its own Lua state on each side.

Server scripts get the complete standard library, including io, os, package and debug. They run on your own machine with the rights of the game server process.

Client scripts run code from a server on the player's PC, so they get a reduced environment.

Available on the client Removed on the client
base functions (pairs, pcall, tostring, select, ...) load, loadfile, dofile
coroutine, table, string, math, utf8 io, package, require, debug
os.time, os.clock, os.date, os.difftime os.execute, os.exit, os.remove, os.rename, os.tmpname, os.getenv, os.setlocale

Client scripts come from the server a player joined, so they get no access to files or programs on the player's PC.

Coroutines work with timers and events on both sides. Timers and key handlers that are created inside a coroutine run on the main Lua state of the resource.