Meteor 2 Scripting Functions
UI
vector2 getScreenSize()
Get the screen size in pixels
print("Screen size is " + getScreenSize().x + " by " + getScreenSize().y);
print("Screen size is " + SCREEN_W + " by " + SCREEN_H);
Two static float variables SCREEN_W and SCREEN_H are also available.
void screenToWorld(vector2 screenPos)
Convert screen pixel coordinates to a world position.
print(screenToWorld(vector2(SCREEN_W * 0.5, SCREEN_H * 0.5)));
Result may be outside of world/map bounds.
void worldToScreen(vector2 screenPos)
Convert a world position to screen pixel coordinates.
print(worldToScreen(getPos(getPlayer())));
Result may be outside of screen bounds.
vector2 getWorldWindowStart()
Get the world window start position (world position under top-left pixel).
print(getWorldWindowStart());
vector2 getWorldWindowSize()
Get the world window size in world pixels (not metres or screen pixels).
print(getWorldWindowSize());
bool posInWorldWindow()
Determine is a world position (in world pixels) is within the world window.
print(posInWorldWindow(1));
float getWorldRenderScale()
Get the current world render scale (zoom level).
print(getWorldRenderScale());
string colToHTML(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Convert a unsigned byte colour in the format RGBA to HTML style string.
print(colToHTML(255,255,255,255));
print(colToHTML(255,255,255,128));
print(colToHTML(255,0,0,255));
print(colToHTML(0,255,0,128));
print(colToHTML(0,0,255,255));
void gameMessage(string text)
Display a game message (local only).
gameMessage("This is a game message");
none
void introMessage(string text)
Display an intro message (local only).
introMessage("This is a intro message");
Intro messages are displayed near the bottom of the screen and fade out after around 8 seconds.
void messageBox(string text)
Display a message box (local only).
messageBox("This is a message box");
none
bool confirmBox(string text)
Display a confirmation box with message (local only).
if(confirmBox("Are you sure?"))
{
print("You are sure");
}
none
bool stringInputBox(string str, int maxLen, string message)
Display a string input box with message (local only).
string name = "";
if(stringInputBox(name, 32, "Enter your name"))
{
print("Your name is " + name);
}
none
bool createToolbar(int toolbarNumber, string title, vector2 screenPos, bool docked)
Create a toolbar (local only).
createToolbar(0, "Test Toolbar", vector2(10, 10), false);
toolbarNumber should simply be unique number that refers to this toolbar.
docked toolbars cannot be moved.
See base\maps\examples\Text_Toolbar.as for a working example.
void deleteToolbar(int toolbarNumber, bool localOnly)
Delete a toolbar and all associated buttons (local only).
deleteToolbar(0);
void addToolbarButton(int toolbarNumber, string caption, string imageFilename, string triggerText)
Add a button to an existing toolbar (local only).
addToolbarButton(0, "Sheep", "objects\\sheep01_01.png", "print(\"You pressed the sheep button\");");
toolbarNumber is the unique toolbar number to add the button to.
imageFilename must be image filename from within an INI file from the images folder.
void addToolbarSeparator(int toolbarNumber)
Add a separator to an existing toolbar (local only).
addToolbarSeparator(0);
Add an interaction menu.
int menuId = addMenu("Test Menu");
Remove an interaction menu.
int menuId = addMenu("Test Menu");
removeMenu(menuId);
Add an interaction menu item.
int menuId = addMenu("Test Menu");
int menuItemId = addMenuItem(menuId, "Test Item", "print(\"Hello!\");");
int rootMenuItemId = addMenuItem(0, "Test Menu >", "openInteractionMenu(" + menuId + ");", false);
Use a menu id of 0 to add to the root menu.
Remove an interaction menu item.
int menuId = addMenu("Test Menu");
int menuItemId = addMenuItem(menuId, "Test Item", "print(\"Hello!\");");
removeMenuItem(menuId, menuItemId);
Get if an interaction menu item is hidden.
int menuId = addMenu("Test Menu");
int menuItemId = addMenuItem(menuId, "Test Item", "print(\"Hello!\");");
if (getMenuItemHidden(menuId, menuItemId))
{
print("Item is hidden");
}
else
{
print("Item is not hidden");
}
Set if an interaction menu item is hidden.
int menuId = addMenu("Test Menu");
int menuItemId = addMenuItem(menuId, "Test Item", "print(\"Hello!\");");
setMenuItemHidden(menuId, menuItemId, true);
Open specified interaction menu.
openInteractionMenu(0);
int menuId = addMenu("Test Menu");
openInteractionMenu(menuId);
openInteractionMenu(-1);
Use -1 to close the interaction menu.
Show an interaction menu from an array of items.
array<InteractionMenuItem> menuData;
menuData.insertLast({ "Root >", "openInteractionMenu(0);", false });
menuData.insertLast({ "Item 1", "print(\"Item 1\");" });
menuData.insertLast({ "Item 2", "print(\"Item 2\");" });
showInteractionMenu("Test Menu", menuData);
Index