# mapobjects.lua¶

This script contains some convenience functions for loading the tribes and world.

Prints a message containing the duration func() required to run.

Parameters
• preamble (string) – The name of the item that was being loaded

• func (function) – The function to time execution off.

add_animation(animationtable, animationname, dirname, basename, hotspot[, fps])

Convenience function for adding an animation to animationtable. Supports both simple animations and mipmaps. See Animations for more documentation and code examples.

Parameters
• animationtable (table) – The table that the animation data will be added to. It may already contain some animations.

• animationname (string) – The name of the animation to be added, e.g. idle.

• dirname (string) – The name of the directory where the animation image files are located.

• basename (string) – The basename of the animation files. The filenames of the animation files need to have the format <basename>_[_\d+].png for simple file animations, and <basename>_<scale>[_\d+].png for mipmaps. Supported scales are 0.5, 1, 2 and 4.

• hotspot (array) – The hotspot coordinates for blitting, e.g. {2, 20}.

• fps (integer) – Frames per second. Only use this if the animation has more than 1 frame, and if you need to deviate from the default frame rate.

add_directional_animation(animationtable, animationname, dirname, basename, hotspot[, fps])

Adds 6 walk or sail animations - one for each walking direction - to animationtable. Supports both simple animations and mipmaps. See Animations for more documentation and code examples.

Parameters
• animationtable (table) – The table that the animation data will be added to. It may already contain some animations.

• animationname (string) – The name of the animation to be added, e.g. walkload.

• dirname (string) – The name of the directory where the animation image files are located.

• basename (string) – The basename of the animation files. The filenames of the animation files need to have the format <basename>_(e|ne|se|sw|w|nw)_\d{2,3}.png for simple animations, and <basename>_(e|ne|se|sw|w|nw)_<scale>_\d{2,3}.png for mipmaps. Supported scales are 0.5, 1, 2 and 4.

• hotspot (array) – The hotspot coordinates for blitting, e.g. {2, 20}.

• fps (integer) – Frames per second. Only use this if the animation has more than 1 frame, and if you need to deviate from the default frame rate.