HomeIndex

Game Functions

overlayColor(color)
Sets the screen overlay color.
overlayFlashColor(color,time)
Flashes an overlay color for time seconds.
overlayColorTo
Changes the overlay to color over time seconds.
createFont(name,size)
Creates and returns a font from a .ttf at the given size
Any function that needs a font (like createTextImage()) require a font created with createFont(). The size of the font is fixed at creation. If you require a different size you'll need to create a new font. Best practice is to create all the fonts and sizes you need at boot and use them as needed. Scaling the image made from createTextImage() too much can create blurry characters and it's best to create a new font at the right size.
Pixel fonts need to be created at the base size of the original .ttf file. They can safely be scaled up in whole number multiples.
font = createFont("Savior.ttf", 16) image = createTextImage(font, "Hi there, nice day!")
There is no way to delete a font, so create them once and use them for the rest of the game.
fontProps(font,props_table)
Alter various properties of a font.
fontProps(font, { "lineSpacing": 20, "baseLine": -2 })
Changing properties have a global effect on all images rendered with the font. If you need the same font with different properties, create two fonts.
roomForID(id)
Returns a room table for the given int id.
objectForID(id)
Returns a object table for the given int id.
flipDir(dir)
Returns a 180 deg flip of a direction.
dir = flipDir(DIR_RIGHT) // dir is now DIR_LEFT
refreshUI(state)
Causes the game UI to refresh.
This includes refreshing all hover states for objects. If you change the name or show/hide an object the UI might need to be refreshed. For the most part this is handled automatically. If you're finding you need a lot of refreshUI() command in your code, the engine might need to change.
state == 0
Hover stats are refresh and _hoverObject called as needed.
Useful when an object name changes but it's not automatically caught by the system.
state == 1
All hover and drag states are cleared. Useful for going into cutscenes and the like.
New hovers will not be called until the mouse moves (assuming input is on).
iskeydown(key)
Returns true if the key is being held down.
Any key being held down is checked, this included keys like shift and control. The modified state of a key is not checked so you only know the 'a' key is down, not 'A'. Be careful of non-US keyboards where the shifted version of a key might not be the same. If that matters, it's best to use the keyDown(key, flags) callback event.
if (iskeydown('a')) { ... } if (iskeydown(KEY_SHIFT_LEFT)) { ... } if (iskeydown(KEY_CONTROL_RIGHT)) { ... } if (iskeydown(KEY_DOWN)) { .. }
inputState([state])
Set or get the current input state.
Setting input state to OFF will prevent all mouse/touch events, but won't stop key presses from being passed on. The game system will stop them from being passed to game code.
freezeGame([state])
Freezes the game or returns the freeze state.
When the game is frozen, all scripts are paused (even unpausesable ones) and only keyboard input is passed to the game. No new scripts can be started while the game is in a frozen state.
pauseGame([state])
pauses the game or returns the pause state.
When the game is paused, all scripts are paused (even unpausesable ones) and only keyboard input is passed to the game. No new scripts can be started while the game is in a frozen state.
quitGame()
Quits the game and saves all Pref files.
gameFullscreen([state])
If passed state changes fullscreen mode, otherwises returns screen state.