Lua scripts
A mod script is written in Lua 5.4. It listens to game events and answers with data. For a talk, the answer is a line to say. A script can also read the pockets, the town and its villagers, and queue commands for letters, items, lines and questions.
For a first script, start with the scripter path.
Setting a script up #
In mod.json, name the file and list every event it listens to:
"scripts": {
"main": "main.lua",
"events": ["villager_talked", "day_started"]
}mainmust end in lower case.luaand be in the ZIP. It can sit in a folder, as inscripts/main.lua.- A mod has one script. There is no
require, so keep your code in that one file. eventslists events, each once. Callingon()for an event that is not listed is an error.- A script works in a Just you mod and in a World mod.
- A script that only offers functions to other mods still lists one event in
events. List one and register no handler. See a library mod.
Reference: main.lua, with every limit and error code.
When your code runs #
- When the game starts, each mod's script runs from top to bottom once. This is where you call
on()and set up your tables. - After that, only your handlers run, when their event happens.
- Your variables keep their values for the whole session. They start fresh at the next restart. Use
storefor anything that must last.
The API #
| Call | What it does |
|---|---|
on(event, fn) | Runs fn each time event happens. Call it only while the script first runs, never from inside a handler. Up to 16 handlers per event. |
log(...) | Writes a line to the Mod log and the browser console as [Mods] your-id: .... Values are joined with spaces. A line is cut at 299 bytes. |
message(key) | Returns the line with that key from your messages file, or nil. With a colon, as in "other.mod:key", it reads another mod's line. |
game.time() | Returns the game's date and time as a table { year, month, day, hour, minute, weekday }. weekday is 0 for Sunday to 6 for Saturday. |
store.get(key) | Returns a saved value, or nil. |
store.set(key, value) | Saves a string, number or boolean. nil deletes the key. See the store. |
game.day_number() | Returns the game clock's day as one whole number, counted in days since 2000-01-01. |
store.town() | Returns an opaque text that names the town the store belongs to now, or nil before a town loads. When it changes, read again what you keep in locals. |
store.player.get, store.player.set | The store of the player who is playing. There is one per mod, per town, per player. See the store. |
store.client.get, store.client.set | The per-browser store. There is one per mod, whatever town is loaded. See the store. |
game.pockets() | Returns the held items only, in slot order, as { { slot, item, mod_item }, ... }. slot is 1 to 15. Empty pockets give {}. |
game.bells() | Returns the Bells in the wallet, or nil when no town is loaded. |
game.town() | Returns { name, id, year, month, day, hour, minute, weekday, season }, or nil when no town is loaded. season is spring, summer, fall or winter. |
game.villagers() | Returns { { id, name, species, personality }, ... }. personality is normal, peppy, lazy, jock, cranky or snooty. Every villager is on the villagers list. |
game.player() | Returns { name, id, x, y, z, angle, acre, scene, tool, state }, or nil when no town is loaded. id stays the same for that resident in that town. The rest says where the player stands and what they are doing. See the player. |
game.weather() | Returns the weather where the player is, { kind, intensity }, or nil when no town is loaded. See the weather and where the player is. |
game.place() | Returns where the player is, { scene, name, island, acre, acre_x, acre_z, unit_x, unit_z }, or nil when no town is loaded. See the weather and where the player is. |
game.calendar_today() | Returns the ids of your own calendar days that fall on the town's date today, in file order. It returns {} when there are none. See calendar days. |
game.input() | Returns the player's buttons held now and the main stick: { a, b, ..., c_right, stick_x, stick_y }. See the player's buttons. |
settings.get(name) | Returns a setting's value. That is the player's value, or the default. See settings. |
remote.add, remote.call, remote.has | Offer functions to other mods and call theirs. See dependencies. |
remote.version | Whether a mod named in depends or optional_depends is there, and at what version. See optional dependencies. |
rng(), rng(n), rng(m, n) | Return a random number. rng() gives a fraction from 0 up to 1. rng(n) gives a whole number from 1 to n. rng(m, n) gives one from m to n. See random numbers. |
timer.after(minutes, name, data) | Sets a timer that fires once, as a timer_fired event, that many game minutes from now. It returns the timer's id. See timers. |
timer.cancel(id) | Cancels a waiting timer. It returns true when there was one. |
cmd.* | Queues a command. See Commands. |
Events #
Every handler gets exactly one table, e. A field with nothing to say is nil, never an empty
string or 0. Ids are always numbers in Lua. JSON files write them as strings such as "0x2800". cmd.* takes a number, "0x2800" or your mod's own "author.mod:thing".
| Event | e | Return | When |
|---|---|---|---|
villager_talked | { villager } | nil, a talk table { place, line, topics, ask }, or a list of talk tables. | The player starts an ordinary talk with a villager.See the places. |
day_started | { year, month, day, weekday } | Nothing | A new day begins in the game. |
item_picked_up | { item, mod_item } | Nothing | The player got an item. |
scene_entered | { scene, name } | Nothing | A scene starts, such as the town, a house or a shop. |
data_migrated | { from, to } | Nothing | Fires once per town, when mod.json "data_version" differs from the version the town's data was written at.See moving your data forward. |
hour_changed | { year, month, day, hour } | Nothing | The game's clock reached a new hour. |
item_bought | { item, mod_item, price, shop, ordered } | Nothing | The player bought a good for Bells at any counter in the game.See the shops. |
item_sold | { item, mod_item, count, bells, shop } | Nothing | The player sold for Bells.See the shops. |
fish_caught | { item, pocketed } | Nothing | A fish was landed. |
bug_caught | { item, pocketed } | Nothing | A bug was netted. |
letter_read | { sender, item, mod_item, first_time, letter } | Nothing | The player chose Read on a letter. |
villager_moved_in | { villager } | Nothing | A villager with no house was given one. |
visitor_arrived | { kind } | Nothing | A friend is riding into this player's own town. |
command_finished | { id, command, ok, via, code, message } | Nothing | A command this mod queued was applied or refused. |
question_answered | { id, choice, text } | Nothing | The player answered this mod's ask, or closed it. |
timer_fired | { id, name, data } | Nothing | A timer this mod set with timer.after is due.See timers. |
villager_answered | { villager, choice, text } | nil, a line, or a reply table { line, ask }. | The player answered the question this mod's conversation asked (villager_talked returned place = "conversation" with an ask).See a conversation that asks. |
button_pressed | { button } | Nothing | A button on the player's controller was pressed.See the player's buttons. |
button_released | { button } | Nothing | A button on the player's controller was let go.See the player's buttons. |
player_acted | { action, item, reaction } | Nothing | The player started one of the actions below.See the player. |
Notes on the fields:
villageris the same table wherever a villager appears, in events and in each entry ofgame.villagers(). It is{ id, name, species, personality }.idis a number that stays the same for that villager.speciesandpersonalityarenilwhen the game cannot tell.- In
scene_entered,sceneis the scene number.nameis its name from the scenes list, like"player_house". It isnilfor a scene with no published name. - In
letter_read,itemis the present. It isnilwhen there is none. - In
letter_read,letternames the letter when a mod's letters file sent it. It is the full id, like"your.mod:welcome". To act when the player reads your invitation, teste.letter == "your.mod:welcome". It isnilfor the game's letters, a player's letters and a letter sent withcmd.send_letter{ text }. The game finds the letter by its words, so two letters with the same body and sign-off are not told apart. mod_itemis the full id of a mod item, like"your.mod:ghost-lantern", when the piece is one.itemis then the furniture it stands on. Foritem_sold, it describes the first piece sold.mod_itemisnilfor a plain good. It is alsonilfor a visitor shopping in a friend's town, whose piece is plain furniture.item_picked_upcarriesmod_itemwhen you pick a mod item up off the floor of your own house. That is the only place a mod item stands. A mod item dropped outdoors is plain furniture, so it comes back plain.letter_readcarriesmod_itemwhen the letter's present is a mod item, such as one you attached to a letter yourself.fish_caughtandbug_caughthave nomod_item. A fish or a bug is never a mod item.fish_caughthas no size or length, because the game keeps none for a caught fish. Each kind of fish has one shadow size, soitemtells you that.- In
item_picked_up, write item numbers in hex to match the game's lists, withstring.format("0x%04X", e.item). item_picked_updoes not fire for anything bought. It also does not fire when the pockets are full, because the item is not yours yet.- A fish or a bug that goes into the pockets fires
item_picked_upand thenfish_caughtorbug_caught. A script that counts in both handlers counts that catch twice. Count catches infish_caughtandbug_caught, wherepocketedsays whether it was kept. Or skip fish and bugs initem_picked_up.
Notes on villager_talked:
- Use it for a line that depends on something, such as the time, the date, the store or an item in the pockets. The script kit has a villager notice an apple you carry. Small talk needs no script: put it in a talk pool, by villager or personality, season, time of day, weather and calendar day.
- Every line names its place: a plain string returned alone is refused and logged. A talk table names its
place:before,hello,topic,afterorconversation, and itslineis a string or a list of up to 8 pages. Return a list of talk tables for several places at once. See any place from a script. - A
conversationcan end inask = { text, choices }. The pick goes to yourvillager_answeredhandler, which returns what the villager says next. See a conversation that asks. - A place a script did not take can still get a calendar day or talk pool line, so one talk can have both.
- It is never called for a special talk. Special talks carry the game's own story, so no mod hears them. They are a first meeting, a villager moving out, an errand, delivery or contest in progress with that villager, a complaint, a pitfall or a bee chase, an islander, Kamakura and summer camp.
- The villager's next ordinary talk calls
villager_talkedas usual. A line you keep for "the next time we talk", such as a thank-you, comes then. - The game asks every mod in the order of the Mods tab list, from the top. The first line returned for a place takes it; a later one for that place is written to the Mod log. A conversation takes the whole talk, and the mods below it are not asked.
- A page is 1 to 400 bytes, with no zero byte. Returning
""ornilmeans no line. A table that is not right is written to the Mod log and nothing of it is said.
Notes on item_bought and item_sold. shop says where:
shop | Where |
|---|---|
"nook" | Nook's in every size, and Nookington's in The City |
"flower" | The flower shop |
"redd" | Crazy Redd |
"saharah" | Saharah's carpet, swapped for one of yours plus Bells |
"joan" | Turnips |
"fireworks" | The fireworks show's stall |
"shrine" | The New Year fortune slip |
"gyroid" | What another player put up at their gyroid |
"villager" | A villager's trade |
- Only Nook's and villagers buy from you. To keep to Nook's, test
e.shop == "nook". orderedistruefor a Nook's catalog order. It is paid now and mailed tomorrow, so it is not in the pockets yet.- A service is not a good and sends no
item_bought. Services are a new look at the Pampered Paw (thehaircutservice), Katrina's fortune, a dream and an Able Sisters design.
Notes on timing:
day_starteddoes not run again when the game restarts later on a day the town already saw. The save holds the day it last began.- If the game was not saved since that day began, the save still holds the day before. The next start then runs
day_startedagain. To count days, store the last date you saw instead of counting calls. - No event runs in the title screen demo.
The player #
game.player() reads the player as they are right now, so it is cheap to call from any event or timer:
x,y,z: where they stand. A ground tile is 40 across and an acre is 640.xgrows to the east andzto the south, down the screen. Inside a building they are the room's own.angle: which way they face, 0 to 359 degrees. 0 faces south, toward the camera, 90 east, 180 north and 270 west.acre:{ x, z }in the town, as the map counts acres.xis the column, 1 to 5 from west to east.zis the row, 1 (the train station's row, A on the map) to 6 (the beach row, F). It isnilin any scene but the town.scene: the scene's name from the scenes list, like"town".tool:"axe","net","rod","shovel"or"umbrella"in their hand, golden ones too.nilfor an empty hand or anything else.state: one word:"standing","walking","running","sitting","lying"(on a bed),"wading"or"busy"."wading"is the game's word for walking into the next acre while the screen scrolls: the town has no water a player can wade into."busy"is everything else: a tool swing, picking something up, a talk, a door, a cutscene. Treat a word you do not know as"busy": the list may grow.
Everything after id is nil while the scene is still being built, such as in day_started as the game starts. On a visit it is the visitor, standing in the host's town.
local p = game.player()
if p and p.scene == "town" and p.acre then
log("in acre", p.acre.x, p.acre.z, "facing", p.angle, "holding", p.tool or "nothing", "and", p.state)
endplayer_acted fires when the player starts an action. e.action is one of axe_swung (at a tree or at nothing), axe_hit_rock, axe_broke, net_swung, rod_cast, shovel_dug, hole_filled, tree_shaken, sat_down, stood_up, lay_down, stung, fell_in_pitfall, tripped, shocked, door_entered or reacted. It arrived in API 1.1.
- Walking, running and standing are never events. Read
game.player().statefor those. itemis the tool's item number for an axe, net, rod or shovel action. An axe's number changes as it wears. It isnilfor every other action.reactionnames the reaction forreacted: one played from the reactions bar or bycmd.react.- It is the start, not the result:
axe_swungfires for every swing, whether the tree falls or not. - Only the player playing this game sends it. A friend on a visit or another player in The City does not.
- It fires on a visit and in The City too, where it changes nothing.
- A word you do not know may come in a later update: ignore it.
cmd.react(name) plays a reaction on the player's own character. See the commands. The player is busy with the action that just
started, so react a moment later, from a timer:
-- Count the trees shaken today, per resident, and cheer on the tenth.
on("player_acted", function(e)
if e.action ~= "tree_shaken" then return end
local n = (store.player.get("trees") or 0) + 1
store.player.set("trees", n)
-- The player is busy shaking the tree right now, so cheer a minute later.
if n == 10 then timer.after(1, "cheer") end
end)
on("timer_fired", function(e)
if e.name == "cheer" then cmd.react("hooray") end
end)Small examples #
Say something different on Sunday mornings:
on("villager_talked", function(e)
local t = game.time()
if t.weekday == 0 and t.hour < 12 then
return { place = "before", line = "A lazy Sunday morning, " .. e.villager.name .. " says. Isn't it lovely?" }
end
return nil
end)Count every item you pick up, across sessions:
on("item_picked_up", function(e)
local n = (store.get("picked") or 0) + 1
store.set("picked", n)
if n % 100 == 0 then
log("you have picked up", n, "things")
end
end)The cookbook has whole mods to read.
The store #
storeis one per mod per town, with 8 KB per town.store.clientis one per browser.- The main part of your script runs before a town loads, so read and save from events. See Per-town data.
- A town has up to 4 residents, and they share
store.store.playeris one per mod, per town, per player. Keep there anything one resident earns alone, such as a quest or today's gift. It takes the same keys and values and lives inside the same 8 KB. - When a resident is deleted, the game deletes what your mod saved for them in
store.player. A new resident in that save slot starts with nothing. - Every
store.set,store.player.setandstore.client.setwrites your mod's file in the save folder before it returns. - The browser keeps the save folder at the game's next save sync. That is a game save. For the cloud, mod data uploads at most every 2 minutes. A tab closed before that sync loses the last sets.
- A key is a string of up to 64 bytes. It cannot start with a control character.
- A value is a string of up to 1024 bytes, a number,
trueorfalse. Whole numbers come back whole. - A
store.setthat breaks a limit changes nothing and raises an error. The error stops your script unless you catch it:
local ok, err = pcall(store.set, "notes", long_text)
if not ok then
log("could not save notes:", err)
endTimers #
A script cannot wait. It asks to be called later: timer.after(minutes, name, data) sets a timer, and the game
sends your mod a timer_fired event when it is due.
-- mod.json: "events": ["villager_talked", "timer_fired"],
-- "permissions": ["show_line"]
-- The mark is in the town's store, not store.player: the timer can fire
-- while another resident plays, and it must be cleared then too.
on("villager_talked", function(e)
if store.get("kettle") then return nil end
local id, why, code = timer.after(30, "kettle", e.villager.name)
if not id then
log("no timer:", why, code)
return nil
end
store.set("kettle", id)
return { place = "before", line = "I put the kettle on. Come back in half an hour!" }
end)
on("timer_fired", function(e)
-- e = { id, name, data }: the timer is already gone
if e.name == "kettle" then
store.set("kettle", nil)
cmd.show_line("The kettle at " .. e.data .. "'s place must be boiling by now.")
end
end)- List
timer_firedinscripts.eventsand add its handler. Without a handler,timer.afteris refused. minutesis a whole number of game minutes, 1 to 10,080. That is up to 7 game days.namesays what the timer is for. It is 1 to 40 bytes of letters, digits,_,-and.. One handler gets all your timers, so teste.name.datais optional. It is text of up to 240 bytes, a number,trueorfalse. It comes back ase.data. Empty text comes back asnil.timer.afterreturns the timer's id. An id is never used twice in a town. When it is refused, it returnsnil, a message and a code.timer.cancel(id)cancels a waiting timer and returnstrue. It returnsfalsefor a timer that already fired.
The clock:
- Time is counted on the game's clock, the one
game.time()reads. A timer keeps counting while the game is paused or closed. - A timer fires at the end of a frame's update, in whatever scene the player is in. One that came due while the game was closed fires soon after the town loads.
- A timer never fires at the title screen or at player select. Nothing of a mod runs there: no event, no timer and no command. It all carries on when play starts.
- The smallest step is one game minute. A timer never fires early.
- If the player sets the game's clock forward, every timer that is now due fires. If they set it back, a timer waits again, but never longer than 10,080 minutes from the new time.
Where a timer is kept:
- A waiting timer is kept in your mod's town store. It survives a save and a reload, and it travels with the town in a cloud save or an export.
- It counts toward the store's 8 KB, with its name and data. A timer that does not fit is refused.
- A mod may have 16 timers waiting in one town.
- The main part of your script runs before a town loads. Set timers from events.
- On a visit and in The City, the store lives in memory, and so do timers set there. They are gone when the player leaves.
- A scene change does not touch a timer.
Limits when a timer fires:
timer_firedis an event like any other. Its handlers share the usual budget of 200,000 instructions.- Commands queued from it count against the caps per event and per day, as from any event.
- At most one timer per mod fires in a frame. When several are due, the rest fire in the next frames, earliest first.
- The timer is gone before your handler runs. To repeat, set the next one inside the handler.
| Code | Try again | When |
|---|---|---|
timer-args | never | Wrong arguments, such as the minutes, the name or the data. Also when the script has no timer_fired handler. |
timer-limit | later | The mod already has timers.per_mod timers waiting in this town. |
timer-no-town | later | No town is loaded yet. The script's main chunk runs before the save loads. |
timer-no-clock | later | The game clock is not set. It reads a date before the year 2000, so there is no minute to count from. |
timer-store-full | later | The timer does not fit in this mod's town store (store.bytes), or the store could not be written. |
The player's buttons #
A script can read the controls the player plays with. A keyboard key, a controller button and the on-screen touch pad all reach the game as the same controller, with the player's own key settings applied, so one handler covers all three. The Button Tricks example gives each D-pad button a trick of its own.
-- mod.json: "events": ["button_pressed"], "permissions": ["show_line"]
on("button_pressed", function(e)
-- Z while L is held: a combination the game itself does not use
local input = game.input() -- nil while the text editor is open
if e.button == "z" and input and input.l then
cmd.show_line("Hotkey!")
end
end)- The buttons are
a,b,x,y,z,l,r,start,dpad_up,dpad_down,dpad_left,dpad_right,c_up,c_down,c_leftandc_right. The C stick is the fourc_buttons. - The two events and
game.input()arrived in API 1.1. A playac-mod older than 1.1.0 does not know them. button_pressedandbutton_releasedhand you{ button }. They come once a frame, releases first, each in the order above.- A button already held when play starts, or held through a change of scene or the text editor, is not a press.
game.input()gives every button astruewhile held, and the main stick asstick_x(right) andstick_y(up), each from -1 to 1. The keyboard's movement keys tilt it fully.- The game still gets every press. A button your handler listens to does what it always does too, so pick a combination the player does not use for anything else.
- Your script never sees which key was typed. Nothing reaches it while the game's text editor is open, such as writing a letter or a name, whether by keyboard or by controller.
game.input()answersnilthen.
The weather and where the player is #
Two questions a script can ask at any time, from any event. Asking changes nothing, so they need no permission.
-- mod.json: "events": ["scene_entered"], "permissions": ["show_line"]
on("scene_entered", function(e)
if e.name ~= "town" then return end
local w, p = game.weather(), game.place()
if not w or not p or not p.acre then return end
if w.kind == "rain" and w.intensity == "heavy" then
cmd.show_line("Pouring at " .. p.acre .. ". Good day for fish.")
end
end)game.weather().kindisclear,rainorsnow, the same words shops and talk pools use. Cherry blossom petals and falling leaves count asclear.intensityislight,normalorheavyfor rain and snow, andnonewhen it is clear.- Indoors,
game.weather()is the weather outside. On the island it is the island's, which can differ from the town's. game.place()givessceneandnameasscene_entereddoes, andisland,trueon the island or in a cottage there.- Outdoors it adds the acre.
acreis the town map's own label, from"A-1"to"F-5", or"island-1"and"island-2"on the island.acre_xis the column andacre_zthe row, 1 for A.unit_xandunit_zare the square inside the acre, 0 to 15 from the north-west corner. Indoors these arenil. game.place()names a place the way the town map does, to one square. For the exact position, usegame.player(). Both are only ever the player's own: a mod never sees where another player is.- On a visit, both describe the town being visited, the one
game.town()names.
Random numbers #
rng()counts how many numbers your mod has drawn in this town on this game day. Each call gives the next one, so calls in a day differ.- The count is saved with the town. A reload carries on from it, so reloading cannot reroll. A new game day starts new numbers.
- On a visit, in The City and before a town loads, the count is kept in memory only.
math.randomandmath.randomseedare not available. Calling one stops the script with an error that says to userng().
What Lua you get #
- You get Lua 5.4 with the
string,table,math,utf8andcoroutinelibraries. - You get the basic functions, such as
pairs,ipairs,tostring,tonumber,type,select,pcall,errorandsetmetatable. - These are not there:
io,os,debug,package,require,load,loadfile,dofile,collectgarbage,printandstring.dump. Uselogin place ofprint. __gcmetamethods are refused. A table with a__lenmetamethod cannot be passed totable.insert,remove,sortorconcat.- For random numbers, use
rng.
Limits and what happens past them #
| Limit | Value |
|---|---|
| Work per event | 200,000 Lua instructions for all your mod's handlers of that event together. Library work counts too. That covers string patterns, table sorts and joins, string.pack and unpack at 1 instruction per 4 format bytes, and memory you allocate. |
| Time per event | A backstop: one event run past 125 ms stops the script. 3 runs in a row over 8 ms stop it too. Both are stretched on a slow device. See what stops a script. |
| Time at start | A backstop: the main part of the script, when the game starts, gets 250 ms. |
| Memory | 4 MB per mod, 16 MB for all mods together |
| Handlers | 16 per event per mod |
log() | 20 lines per event and 500 per session. Past that, lines are dropped with a note. |
| Script file | 512 KB |
A script that raises an error, runs out of memory or runs past its time is stopped for the rest of the
session. Your mod's other content, such as textures and a shop, keeps working. The Mods tab shows Script stopped: and the reason, for example yourname.my-script/main.lua:12: attempt to index a nil value. The same line goes to the console. pcall catches ordinary errors, but never a stop for running too long.
What stops a script, and what does not #
- The instruction count is the rule. A run that goes past 200,000 instructions is stopped with
script took too long (over 200000 instructions). The count is the same on every device. An endless loop and a huge allocation are stopped this way, on a fast computer and on a slow phone alike. - Wall-clock time is only a backstop. Some work happens inside one instruction, such as a garbage collection. The count cannot see that time, so a run past 125 ms is stopped too, with
script took too long (over ... ms). A script that stays inside its count does not get near it. - Slow runs. A run over 8 ms is a strike. 3 strikes in a row stop the script with
script kept the game waiting. One fast run clears the strikes, so one pause of a busy device is not enough. - A slow or busy device. The game measures how long its own work takes each frame, without the mods' time. When its frames are slower than usual, the wall-clock limits above are stretched by the same factor, up to 8 times. So a phone, or a computer busy with other programs, does not stop a mod that a fast computer runs. The message shows the stretched number.
- The frame share never stops a mod. All mods together get 4 ms of Lua a frame. Past that, events wait for the next frame, in order, and a talk is answered by the villager's own line. On a slow device events wait more often, but they still run.
What a script cannot do #
- It cannot change anything in the game directly. A handler only returns data and queues commands. The game applies them at the end of a frame's update, within the mod's permissions and caps. Moving villagers or reshaping the town is not a command.
- It cannot run every frame. There is no per-frame event, and there will not be one. A timer waits at least one game minute.
- It cannot take anything from the player on its own.
cmd.take_itemandcmd.take_bellsonly ask, in the game's own words, and the player decides. See taking items or Bells. - It cannot write the player's save on its own terms.
cmd.save()asks the game for the same save the Autosave setting makes, and the game writes it only outdoors in the player's own town, in free control. See saving the game. - It cannot make any weather it likes.
cmd.set_weatherasks for weather the game itself could have on that date, and the game changes it as it does on its own. See the weather. - It cannot read files or reach the internet. It cannot see the page, the player's account or other mods' variables.
- It cannot load more code or compiled Lua.
The reference lists every event, query and command.