Module TheoTown

TheoTown specific functions that don't fit into other libraries.

Functions

getGlobalFunVar (name[, fallbackValue]) Returns the value of the global fun variable of the given name or fallbackValue if no such variable has been defined, yet.
setGlobalFunVar (name, value) Sets the value of a global fun variable called name.
getDiamonds () Returns the number of diamonds that the user currently has.
spendDiamonds (amount) Spends amount diamonds if possible.
getStorage () Returns a game wide storage table.
getFileStorage () Returns a game wide storage table that's backed by an actual file.
registerCommand (name, action) Registers a function that can then by called from console.
playSound (draft[, volume=1]) Plays a sound.
getPlayTime () Returns the play time in the game in seconds.
isMultiplayer () Returns true iff this version of the game is capable of running multiplayer games.


Functions

getGlobalFunVar (name[, fallbackValue])
Returns the value of the global fun variable of the given name or fallbackValue if no such variable has been defined, yet. fallbackValue is 0 by default. Note that fun variables can only contain numbers. Use City.getStorage() or TheoTown.getStorage() to store more fancy stuff. Global fun variables are indicated by a leading ! in their name.

Parameters:

  • name string
  • fallbackValue number (optional)

Returns:

    number
setGlobalFunVar (name, value)
Sets the value of a global fun variable called name. Note that fun variables can only contain numbers. Use City.getStorage() or TheoTown.getStorage() to store more fancy stuff. Global fun variables are indicated by a leading ! in their name.

Parameters:

getDiamonds ()
Returns the number of diamonds that the user currently has.

Returns:

    number
spendDiamonds (amount)
Spends amount diamonds if possible. Returns true iff spending was successful, false otherwise.

Parameters:

  • amount number
getStorage ()
Returns a game wide storage table. Use it to save data permanently accross all cities.

Returns:

    table
getFileStorage ()
Returns a game wide storage table that's backed by an actual file. The file will even persist if the user deleted the game. Only a deletion of the TheoTown folder will reset this storage.

Returns:

    table
registerCommand (name, action)
Registers a function that can then by called from console. Usage: TheoTown.registerCommand('test', function(name, arg) return arg end) Instead of a name you can provide a function that returns true for commands the second function should handle.

Parameters:

  • name string or function
  • action function
playSound (draft[, volume=1])
Plays a sound.

Parameters:

  • draft draft A sound draft or id of a sound draft.
  • volume number A value between 0 and 1. (default 1)
getPlayTime ()
Returns the play time in the game in seconds.

Returns:

    number Time in seconds.
isMultiplayer ()
Returns true iff this version of the game is capable of running multiplayer games.

Returns:

    bool
generated by LDoc 1.4.3 Last updated 2019-10-28 15:18:26