Skip to content
DDR0 edited this page Apr 11, 2012 · 37 revisions
  • achievement(id) : unlocks the achievement with the given id
  • add_level_module(string lvl, int xoffset, int yoffset) : adds the level module with the given level id at the given offset
  • add_object(object) : inserts the given object into the level. The object should not currently be persent in the level. The position of the object is tweaked to make sure there are no solid overlaps, however if it is not possible to reasonably place the object without a solid overlap, then the object will not be placed and the object and caller will both receive the event add_object_fail.
  • add_particles(string id) : adds the particle system with the given id to the object
  • add_water(int x1, int y1, int x2, int y2, (optional)[r,g,b,a]=[70,0,0,50]) : adds water of the given color in the given rectangle.
  • add_wave(int x, int y, int xvelocity, int height, int length, int delta_height, int delta_length) : will add a wave with the given characteristics at the surface of the water above the (x,y) point. (x,y) must be within a body of water. Waves are a visual effect only and may not display at all on slower devices.
  • animation(string id) : changes the current object's animation to the given animation. time_in_animation is reset to 0.
  • begin_script(string id) : begins the script with the given ID.
  • begin_skip_dialog_sequence() : command that will cause everything up until the next time end_skip_dialog_sequence() is called to be considered a single storyline sequence. If the player selects to skip the sequence between now and then everything up until the call to end_skip_dialog_sequence() will be skipped.
  • blur(int alpha=0, int fade=10, int granularity=1) : creates a motion blur for the current object.
  • can_load_game() : returns true if there is a saved game available to load
  • checkpoint_game() : saves a checkpoint of the game
  • circle_light(object, radius) : creates a circle of light with the given radius
  • collides(object a, string area_a, object b, string area_b) -> boolean : returns true iff area_a within object a collides with area_b within object b.
  • collides_with_level(object) -> boolean : returns true iff the given object collides with the level.
  • cosmic_shift(int xoffset, int yoffet) : adjust position of all objects and tiles in the level by the given offset
  • debug(...) : outputs arguments to the console
  • debug(msg, expr) : evaluates and returns expr. Will print 'msg' to stderr
  • debug_console() : provides an interactive debugging console
  • debug_rect(int x, int y, (optional)int w=1, (optional) int h=1) -> Draws, for one frame, a rectangle on the level
  • die() : causes the current object to die. The object will receive the on_die signal and may even use it to resurrect itself. Use remove_object() to remove an object from play without it receiving on_die.
  • distortion(int, int, int) : (currently unsupported)
  • dump(x) : Equivalent to debug_fn(x, x). Essentially a no-op code-wise, it prints whatever x is to console and returns x.
  • dump2(x, y) : Equivalent to debug_fn([x, y], y). Like dump, dump2 is also a no-op for your logic. However, now you can include an identifying string before the stuff to be dumped so you can actually tell which dump function is dumping what data.
  • end_game() : exits the game
  • end_script() : ends the most recent script to have begun.
  • end_skip_dialog_sequence() : ends the sequence begun with begin_skip_dialog_sequence().
  • eval(string formula, [obj context]) : evaluate the given formula in the given context
  • execute(object context, command cmd) : this function will execute the command or list of commands given by cmd on the object given by context. For instance, animation('foo') will set the current object to animation 'foo'. execute(obj, animation('foo')) can be used to set the object given by obj to the animation 'foo'.
  • facing(int new_facing) : changes the current object's facing according to the value of new_facing (1 for right, otherwise left).
  • fire_event((optional) object target, string id, (optional)callable arg) : fires the event with the given id. Targets the current object by default, or target if given. Sends arg as the event argument if given
  • get_document(string filename) : return reference to the given JSON document
  • get_object(level, string label) -> object : returns the object that is present in the given level that has the given label
  • group_size(level, int group_id) -> int : gives the number of objects in the object group given by group_id
  • load_game() : loads the saved game
  • move_to_standing() : tries to move the object downwards if it's in the air, or upwards if it's in solid space, until it's standing on solid ground.
  • music(string id) : plays the music file given by 'id' in a loop
  • music_onetime(string id) : plays the music file given by 'id' once
  • object(string type_id, int midpoint_x, int midpoint_y, int facing, (optional) map properties) -> object : constructs and returns a new object. Note that the difference between this and spawn is that spawn returns a command to actually place the object in the level. object only creates the object and returns it. It may be stored for later use.
  • orbit(x,y,rot,dist) : Return a list containing an x/y location dist away at rot degrees away from the x/y passed it. Useful in conjunction with angle_to(obj, obj).
  • paused_speech_dialog(...) : like speech_dialog(), except the game is paused while the dialog is displayed.
  • plot_x(int x) : plots a vertical debug line at the given position
  • plot_y(int x) : plots a horizontal debug line at the given position
  • preload_sound(string id) : preload the given sound so it'll be in the sound effects cache
  • radial_current(int intensity, int radius) -> current object : creates a current generator with the given intensity and radius
  • rect_current(int x, int y, int w, int h, int xvelocity, int yvelocity, int strength) -> current generator object : creates a current generator object that has a current with the given parameters. Set the return value of this function to an object's rect_current to attach it to an object and thus place it in the level.
  • remove_level_module(string lvl) : removes the given level module
  • remove_object(object) : removes the given object from the level. If there are no references to the object stored, then the object will immediately be destroyed. However it is possible to keep a reference to the object and even insert it back into the level later using add_object()
  • remove_water(int x1, int y1, int x2, int y2) : removes water that has the given rectangular area.
  • report() : Write a key and a value into [custom] in the stats.
  • resolve_solid(object, int xdir, int ydir, int max_cycles=100) : will attempt to move the given object in the direction indicated by xdir/ydir until the object no longer has a solid overlap. Gives up after max_cycles. If called with no arguments other than the object, will try desperately to place the object in the level.
  • rotate_rect(int center_x, int center_y, int rotation, int[8] rect) -> int[8] : rotates rect and returns the result
  • save_game() : saves the current game state
  • schedule(int cycles_in_future, list of commands) : schedules the given list of commands to be run on the current object the given number of cycles in the future. Note that the object must be valid (not destroyed) and still present in the level for the commands to be run.
  • screen_flash(list int[4] color, (optional) list int[4] delta, int duration) : flashes the screen the given color, and keeps the flash going for duration cycles. If delta is given, the color of the flash will be changed every cycle until the duration expires.
  • scroll_to(object target) : scrolls the screen to the target object
  • set_group((optional)int group_id) : sets the current object to have the given group id, or to be in no group if group_id is not given
  • set_save_slot() : Allows the user to select the save slot
  • set_solid(x1, y1, x2, y2, boolean is_solid=false) : modifies the solidity of the level such that the rectangle given by (x1, y1, x2, y2) will have its solidity set to the value of is_solid
  • set_var(string varname, variant value) : sets the variable named varname within the current object. Note that you should generally use set(vars.blah, x) rather than set_var('blah', x). The only exception is if you want to create the command and save it for later execution on an object you don't yet have access to -- most useful with the spawn() function.
  • shake_screen(int x_offset, int y_offset, int x_velocity, int y_velocity) : makes the screen camera shake
  • solid(level, int x, int y, (optional)int w=1, (optional) int h=1, (optional) int debug=0) -> boolean : returns true iff the level contains solid space within the given (x,y,w,h) rectangle. If 'debug' is set, then the tested area will be displayed on-screen.
  • sound(string id, decimal volume) : plays the sound file given by 'id'
  • sound_loop(string id, decimal volume) : plays the sound file given by 'id' in a loop
  • sound_volume(int volume) : sets the volume of sound effects
  • spawn(string type_id, int midpoint_x, int midpoint_y, int facing, (optional) list of commands cmd) : will create a new object of type given by type_id with the given midpoint and facing. Immediately after creation the object will have any commands given by cmd executed on it. The child object will have the spawned event sent to it, and the parent object will have the child_spawned event sent to it.
  • spawn_player(string type_id, int midpoint_x, int midpoint_y, int facing, (optional) list of commands cmd) : identical to spawn except that the new object is playable.
  • speech_dialog(...) : schedules a sequence of speech dialogs to be shown modally. Arguments may include a list of strings, which contain text. An integer which sets the duration of the dialog. An object which sets the speaker. A string by itself indicates an option that should be shown for the player to select from. A string should be followed by a list of commands that will be executed should the player choose that option.
  • standable(level, int x, int y, (optional)int w=1, (optional) int h=1) -> boolean : returns true iff the level contains standable space within the given (x,y,w,h) rectangle
  • stop_sound(string id) : stops the sound that the current object is playing with the given id
  • swallow_event() : when used in an instance-specific event handler, this causes the event to be swallowed and not passed to the object's main event handler.
  • teleport(string dest_level, (optional)string dest_label, (optional)string transition) : teleports the player to a new level. The level is given by dest_level, with null() for the current level. If dest_label is given then the player will be teleported to the object in the destination level with that label. If transition is given, it names are type of transition (such as 'flip' or 'fade') which indicates the kind of visual effect to use for the transition.
  • text(string text, (optional)string font='default', (optional)int size=1, (optional)bool centered=false) : adds text for the current object
  • tiles_at(x, y) : gives a list of the tiles at the given x, y position
  • time() -> timestamp : returns the current real time
  • title(string text, int duration=50) : shows level title text on the screen for duration cycles
  • transient_speech_dialog(...) : schedules a sequence of speech dialogs to be shown. Arguments may include a list of strings, which contain text. An integer which sets the duration of the dialog. An object which sets the speaker.

Clone this wiki locally