World of Hello
|
a 2D GUI element. More...
Public Member Functions | |
conditional< string, bool > | runScript () |
run the element's script once. More... | |
element | setRunScript (bool runScript=true) |
runs the script each frame. More... | |
element | setScript (string code) |
set the element's script. More... | |
string | getScript () |
get the current code of the element. More... | |
conditional< string, bool > | doScriptString (string code) |
does a script string. More... | |
element | blockFunction (string functionName, bool block=true) |
blocks a function from being used outside of the current script. More... | |
string | getID () |
get the ID of the element. More... | |
bool | setID (string ID) |
set the ID of the element. More... | |
float | getX () |
get the X axis of the element. More... | |
float | getY () |
get the Y axis of the element. More... | |
float | getWidth () |
get the width of the element. More... | |
float | getHeight () |
get the height of the element. More... | |
element | bringToFront () |
brings the element to the top-most layer. More... | |
element | bringToBack () |
brings the element to the bottom-most layer. More... | |
element | setX (float X) |
sets the X axis of the element More... | |
element | setY (float Y) |
sets the Y axis of the element. More... | |
element | setWidth (float width) |
sets the width of the element. More... | |
element | setWidth (float height) |
sets the height of the element. More... | |
element | setScale (float scale) |
sets the scale of the element. More... | |
element | setScale (float widthScale, float heightScale) |
sets the width and height scale of the element. More... | |
element | setMaintainAspectRatio (bool maintainAspectRatio=true) |
sets whether or not changing the width/height maintains aspect ratio scaling. More... | |
element | center () |
centers the element. More... | |
element | setScalePosition () |
sets that setScale() should also scale the element's position. More... | |
element | setScalePosition (bool scalePosition) |
sets whether or not setScale() should also scale the element's position. More... | |
element | setScalePosition (bool scaleX, bool scaleY) |
sets whether or not setScale() should also scale the element's X and Y position. More... | |
element | setCollisionWith (element elem) |
add collision with another element. More... | |
element | removeCollisionWith (element elem) |
removes the collision with another element. More... | |
element | setMinWidth (float minWidth) |
sets the minimum resize width. More... | |
element | setMinHeight (float minHeight) |
sets the minimum resize height. More... | |
element | setMaxWidth (float maxWidth) |
sets the maximum resize width. More... | |
element | setMaxHeight (float maxHeight) |
sets the maximum resize height. More... | |
string | getType () |
get the type of this element. More... | |
element | setPosition (float X, float Y) |
set the position of the element. More... | |
multiReturn< float, float > | getPosition () |
gets the position of the element. More... | |
element | setTabEnabled (bool enabled=true) |
sets whether or not you can tab to get to this element. More... | |
element | setTabOrder (int orderNo) |
sets the order in which this element can be tabbed to. More... | |
element | setClipped (bool clipped) |
sets whether the element should be cut off by it's rectangle. More... | |
element | setDPIAware (bool dpiAware=true) |
element | setDefaultControls (bool defaultControls, float speed) |
sets whether the element can be moves with keys. More... | |
element | setFocused (bool focused=true) |
set the focus of the element. More... | |
bool | isFocused () |
get whether or not the element is in focus. More... | |
element | setMovable (bool movable=true, int movableHeight=-1) |
sets the movability of the element. More... | |
element | setMovableBoundaries (int x, int y, int endX, int endY) |
sets the movable boundaries. More... | |
multiReturn< int, int, int, int > | getMovableBoundaries () |
gets the movable boundaries. More... | |
bool | hitsBoundary (string direction) |
checks if the element has collided with a boundary. More... | |
element | setResizable (bool resizable=true) |
sets whether the element is resizable. More... | |
element | setResizableDepth (int resizableDepth) |
sets the depth of the pixels the user must click to resize an element. More... | |
element | setRect (int x, int y, int width, int height) |
sets the rectangle of the element. More... | |
element | hide () |
sets the element to be invisible. More... | |
element | show () |
sets the element to be visible. More... | |
element | setVisible (bool visible=true) |
sets the visibility of the element. More... | |
bool | isVisible () |
get the visibility of the element. More... | |
element | addElement (element elem) |
adds a child element. More... | |
element | setParent (element elem) |
adds this element as a child of the given element. More... | |
element | removeElement (element elem) |
removes a child element. More... | |
element[] | getElements () |
gets all child elements. More... | |
element | getParent () |
get the parent element. More... | |
element | resetLayers () |
resets the order of the layers. More... | |
void | remove () |
removes the element. More... | |
string | getObject (bool includeChildren=true) |
get the element as a total object. More... | |
element | doCommands (string cmd) |
creates the element from an object like a server command. More... | |
element | removeFromClients () |
removes the element from all online clients. More... | |
element | sendToClients (bool removeOthers=false, string key="", string keyAns="") |
sends the element to all connected clients who meet the criteria. More... | |
element | setProperty (string property, string value) |
sets a property of the element to be sent next. More... | |
string | getProperty (string property) |
gets the value of a set property. More... | |
string[] | getProperties () |
gets all properties from the object. More... | |
element | removeProperty (string property) |
removes a property from the object. More... | |
element | clearProperties () |
removes all properties from the object. See removeProperty() More... | |
bool | setParentScript (string scriptPath) |
sets the parent script. More... | |
![]() | |
void | setEventListener (ElementEvent event, function func,...) |
sets a function to run on the given event. Removes all other event listeners of the same event type. More... | |
void | addEventListener (ElementEvent event, function func,...) |
adds a function to run on the given event. More... | |
Static Public Member Functions | |
static void | drawRectangle (int x, int y, int width=100, int height=50, bool border=false, int r=0, int g=0, int b=0, int a=255, clipX=0, clipY=0, clipWidth=game:getWindowWidth(), clipHeight=game:getWindowHeight()) |
draws a 2D rectangle on top of the element. More... | |
a 2D GUI element.
Elements (such as CreateImage or CreateButton) derive all of the functions in this class.\n This means that any element may use these by using something like "elementName:setX(10)".\n WARNING: The user must have sufficient access rights to call any functions. These permissions can be set or removed using element:blockFunction(). The function may only be unblocked in the same script that it was blocked in.\n WARNING: Online elements with an unset ID (or set IDs without a leading '-') are destroyed when the object creator disconnects.
adds a child element.
Adds an element to this element.\n The child element that is added will always have a position and clip source relative to this element.
The | element to add to this element. |
element element::blockFunction | ( | string | functionName, |
bool | block = true |
||
) |
blocks a function from being used outside of the current script.
After a function is blocked, the function can no longer be used. The function may only be unblocked in the same script that blocked the function.\n Good for security purposes. For example, if you create a password editbox, and someone has access to other scripts, by blocking the element:getText() function, they cannot get the text of the editbox.
The | name of the function to be blocked. I.E "getText". |
(optional) | Whether the function should be blocked or unblocked. |
element element::bringToBack | ( | ) |
brings the element to the bottom-most layer.
element element::bringToFront | ( | ) |
brings the element to the top-most layer.
element element::center | ( | ) |
centers the element.
element element::clearProperties | ( | ) |
removes all properties from the object. See removeProperty()
element element::doCommands | ( | string | cmd | ) |
creates the element from an object like a server command.
Uses the given comma-separated properties and creates the element like a command. You may get the object (see element:getObject()) and use this function to make the element load the same data as the given object.\n WARNING: children may also be created, if given.
The | object command. |
conditional<string, bool> element::doScriptString | ( | string | code | ) |
does a script string.
Instead of setting the script to be ran by the element, this does the string as a script just one time. Does not change the set script.
The | code the element should run. |
|
static |
draws a 2D rectangle on top of the element.
The | X axis of the rectangle. |
The | Y axis of the rectangle. |
(optional) | The width of the rectangle. |
(optional) | The height of the rectangle. |
(optional) | Whether the rectangle is only the border or filled. |
(optional) | The amount of red (0-255). |
(optional) | The amount of green (0-255). |
(optional) | The amount of blue (0-255). |
(optional) | The amount of alpha (transparency) (0-255). |
(optional) | The clipping X (the rectangle will not draw pixels lower than the clipping X). |
(optional) | The clipping Y. |
(optional) | The clipping width (the rectangle will not draw pixels above the clipping X + the clipping width). |
(optional) | The clipping height. |
element [] element::getElements | ( | ) |
gets all child elements.
Returns an array of elements added with the addElement() function.\n Returns nil if there are no added elements.
float element::getHeight | ( | ) |
get the height of the element.
Gets the height of the element in pixels.\n WARNING: this gets the set height of the element. If you are trying to get the text height of a CreateText element, you should instead use CreateText:getTextHeight()
string element::getID | ( | ) |
get the ID of the element.
multiReturn<int, int, int, int> element::getMovableBoundaries | ( | ) |
gets the movable boundaries.
Gets the boundaries set using setMovableBoundaries(). If no boundaries are set, then returns -1 for all values.
string element::getObject | ( | bool | includeChildren = true | ) |
get the element as a total object.
Gets the element and all of it's set properties as a string object. Can be used to save the element into a data file.
Whether | or not the children objects should also be returned. |
element element::getParent | ( | ) |
get the parent element.
Gets the element who added this element (see element:addElement()), if any.
multiReturn<float, float> element::getPosition | ( | ) |
gets the position of the element.
string [] element::getProperties | ( | ) |
gets all properties from the object.
string element::getProperty | ( | string | property | ) |
gets the value of a set property.
The | property to get the value of. |
string element::getScript | ( | ) |
get the current code of the element.
string element::getType | ( | ) |
get the type of this element.
Gets the type of element. For example, if this is a button, the type is "CreateButton".
float element::getWidth | ( | ) |
get the width of the element.
Gets the width of the element in pixels.\n WARNING: this gets the set width of the element. If you are trying to get the text width of a CreateText element, you should instead use CreateText:getTextWidth()
float element::getX | ( | ) |
get the X axis of the element.
float element::getY | ( | ) |
get the Y axis of the element.
element element::hide | ( | ) |
sets the element to be invisible.
bool element::hitsBoundary | ( | string | direction | ) |
checks if the element has collided with a boundary.
If a boundary is set (see element:setMovableBoundaries()), you may check if an element has hit a boundary by using this function.\n Use element:hitsBoundary("up"), element:hitsBoundary("down"), etc. to check boundary collision.
The | direction of the boundary. |
bool element::isFocused | ( | ) |
get whether or not the element is in focus.
Gets the focus of the element.\n If an element was last clicked, it is in focus.
bool element::isVisible | ( | ) |
get the visibility of the element.
Get whether the element is visible or not.\n See element:setVisible(), element:show(), and element:hide() for more information.
void element::remove | ( | ) |
removes the element.
Destroys the element, removing it completely.
removes the collision with another element.
Removes the collision from this element with another element. Check out element:setCollisionWith() for more information.
The | element to remove collision with. |
removes a child element.
Removes an element from this element.\n Not to be confused with element::remove(), this function detaches an added element using element:addElement().
The | element to remove from this element. |
element element::removeFromClients | ( | ) |
removes the element from all online clients.
Removes the element from all online clients.\n WARNING: this does not remove the element from the user.\n WARNING: this removes the element entirely from the server.
element element::removeProperty | ( | string | property | ) |
removes a property from the object.
Note that setting the property's value to an empty string will also call removeProperty().
The | property to be removed. |
element element::resetLayers | ( | ) |
resets the order of the layers.
Resets the layer ordering. Elements who were created last go on the top layer.
conditional<string, bool> element::runScript | ( | ) |
run the element's script once.
Runs the script set by element:setScript() one time.
element element::sendToClients | ( | bool | removeOthers = false , |
string | key = "" , |
||
string | keyAns = "" |
||
) |
sends the element to all connected clients who meet the criteria.
Sends the element to all clients who are connected to this world.\n When the element is received, it is caught as a command (see element:doCommands()).\n The element is then stored in the server based on it's ID (see element:setID()).
(optional) | Whether or not all of the object's properties are required to be sent. |
(optional) | The send key who all clients must have in order to get the object. |
(optional) | The send key value all clients must also have. |
element element::setClipped | ( | bool | clipped | ) |
sets whether the element should be cut off by it's rectangle.
Sets whether or not the element should get cut off (or clipped) due to it's position, width, and height.\n For example, if a CreateText element width is less than the CreateText text width, then the text gets cut off. By setting clipped to false, the entire text will show regardless of it's width.\n Likewise, elements get cut off outside of parent elements (using element:addChild()). Setting clipped to false will ensure they don't get cut off.
Sets | whether or not the element should be clipped. |
add collision with another element.
Sets bounding box collision with another element. This means that the rectangle around the x, y, width, and height of this element cannot move through the other.\n WARNING: the other element may still move through this element if that element does not have a set collision with this element.\n WARNING: this does not use pixel-collision. Transparent pixels still collide.\n
The | element that this element collides with. |
element element::setDefaultControls | ( | bool | defaultControls, |
float | speed | ||
) |
sets whether the element can be moves with keys.
Sets whether or not the element can be moved using the arrow keys and WSAD keys.\n You may also change the movement speed of the element.
Whether | or not the element is movable with keys. |
The | speed of the element's movement. |
element element::setDPIAware | ( | bool | dpiAware = true | ) |
/brief sets whether the element is DPI aware or not.
True by default, sets whether or not the element should be scaled based on screen density.\n DPI-aware elements are elements that remain the same size between all devices and screen monitors.\n By disabling DPI-awareness, elements may need to have additional code to accomodate viewing them on different systems, like mobile vs. PC.
(optional) | Whether or not the element is DPI aware. |
element element::setFocused | ( | bool | focused = true | ) |
set the focus of the element.
Sets whether or not the element is in focus.\n See element:isFocused() for more information.
(optional) | Whether the element should be focused or not. |
bool element::setID | ( | string | ID | ) |
set the ID of the element.
Sets the ID of the element. By default, the element has a unique ID.\n WARNING: If the ID has a minus sign ("-") at the beginning of the new ID to be set, the ID will remain static, even for online objects when being sent. Otherwise if there is no minus sign, a unique ID will be generated for online objects, and the online object (if sent) will be removed by default on disconnect.\n For example, if you want to create an online object only one time total that all clients can see and modify (opposed to one online object per client), you may want to add a minus sign to the beginning of the ID. Used in the case of real-time editing game town elements.
The | new ID to be set. |
element element::setMaintainAspectRatio | ( | bool | maintainAspectRatio = true | ) |
sets whether or not changing the width/height maintains aspect ratio scaling.
(optional) | Whether or not the element should maintain aspect ratio. |
element element::setMaxHeight | ( | float | maxHeight | ) |
sets the maximum resize height.
If an has a maximum height, it cannot be resized to be larger than that height. If it does get resized to above the maximum height, it is instead set to the maximum height.\n
The | maximum height to be set. |
element element::setMaxWidth | ( | float | maxWidth | ) |
sets the maximum resize width.
If an has a maximum width, it cannot be resized to be larger than that width. If it does get resized to above the maximum width, it is instead set to the maximum width.\n
The | maximum width to be set. |
element element::setMinHeight | ( | float | minHeight | ) |
sets the minimum resize height.
If an has a minimum height, it cannot be resized to be smaller than that height. If it does get resized to below the minimum height, it is instead set to the minimum height.\n
The | minimum height to be set. |
element element::setMinWidth | ( | float | minWidth | ) |
sets the minimum resize width.
If an has a minimum width, it cannot be resized to be smaller than that width. If it does get resized to below the minimum width, it is instead set to the minimum width.\n
The | minimum width to be set. |
element element::setMovable | ( | bool | movable = true , |
int | movableHeight = -1 |
||
) |
sets the movability of the element.
Enables (or disables) the element from being moved using a cursor or finger.\n If there are multi-touch events, more than one element can be moved at the same time.\n 20 by default, if the movableHeight is greater than or equal to 0, it is the height of where the user must drag to move the element.\n For example, if the movableHeight is 10, the user must click anywhere above the element's Y axis plus 10.\n If the element is also resizable (see element:setResizable()), the movableHeight is cut by the resizableDepth (see element:setResizableDepth()).\n The event onElementMove() is triggered when the element is moved.
(optional) | Whether or not the element is draggable. |
(optional) | The Y axis that the mouse click above to become dragged. |
element element::setMovableBoundaries | ( | int | x, |
int | y, | ||
int | endX, | ||
int | endY | ||
) |
sets the movable boundaries.
An element cannot be dragged out of it's movable boundaries. If the element is dragged while out of bounds, it will be moved inside of the bounds.
The | starting X axis the element cannot be moved behind. |
The | starting Y axis the element cannot be moved behind. |
The | ending X axis the element cannot be moved passed. |
The | ending Y axis the element cannot be moved passed. |
adds this element as a child of the given element.
Adds this element to the given element.\n This is the same as addElement(), but is the opposite direction.
The | element to add this element to. |
bool element::setParentScript | ( | string | scriptPath | ) |
sets the parent script.
Sets the parent script which contains the element. Elements are destroyed when their parent script is removed or modified.\n To avoid a temporary script's removal also destroying a created element, you can use this function to move it to a new script.\n WARNING: Moving an element to a new script also moves it's callback event functions (onButtonPressed, onResized, etc.) to the new parent script.
The | path of the new parent script. |
element element::setPosition | ( | float | X, |
float | Y | ||
) |
set the position of the element.
Sets the X and Y position of the element.\n
The | new X axis. |
The | new Y axis. |
element element::setProperty | ( | string | property, |
string | value | ||
) |
sets a property of the element to be sent next.
Sets the property to the previous property, and acts like it has been changed. This is used in the case that you want to send a property, regardless of it's change status. WARNING: Setting the value to an empty string removes the property.
The | property to be set. |
The | value of the property. |
element element::setRect | ( | int | x, |
int | y, | ||
int | width, | ||
int | height | ||
) |
sets the rectangle of the element.
Sets the X axis, Y axis, width, and height of the element.
The | new X axis. |
The | new Y axis. |
The | new width. |
The | new height. |
element element::setResizable | ( | bool | resizable = true | ) |
sets whether the element is resizable.
Sets whether or not the element is resizable. The element can be movable and resizable at the same time. More than one element may be resized at the same time with multi-touch events, but one element can only be resized in one position at once (I.E you cannot resize an element left and right at the same time).\n The event onResize is triggered when the element is resized.
(optional) | Whether the element is resizable. |
element element::setResizableDepth | ( | int | resizableDepth | ) |
sets the depth of the pixels the user must click to resize an element.
Set the depth of the resizable window. If the depth is 5, the user must click on the element, for example, at a position of the element's X axis plus 5 or greater than the element's Y axis plus it's height minus 5.
The | amount of pixels the user must click out of to resize the element. |
element element::setRunScript | ( | bool | runScript = true | ) |
runs the script each frame.
Similar to element:runScript(), but always runs the script for each frame if set to true.\n Sets the property "runningScript" to the element for sending to clients.
(optional) | Sets whether the script should be set to run or not. |
element element::setScale | ( | float | scale | ) |
sets the scale of the element.
The | new scale of the element. |
element element::setScale | ( | float | widthScale, |
float | heightScale | ||
) |
sets the width and height scale of the element.
The | new scaled width of the element. |
The | new scaled height of the element. |
element element::setScalePosition | ( | ) |
sets that setScale() should also scale the element's position.
element element::setScalePosition | ( | bool | scalePosition | ) |
sets whether or not setScale() should also scale the element's position.
element element::setScalePosition | ( | bool | scaleX, |
bool | scaleY | ||
) |
sets whether or not setScale() should also scale the element's X and Y position.
element element::setScript | ( | string | code | ) |
set the element's script.
Set the script to be ran by element:setRunScript() or element:runScript().\n Sets the property "script" to the element for sending to clients.
The | code the element should run. |
element element::setTabEnabled | ( | bool | enabled = true | ) |
sets whether or not you can tab to get to this element.
False by default, sets whether this element can be tabbed to or not. In order to tab to this element, you must first use element:setTabOrder() for indexing.
(optional) | Sets whether or not this element can be tabbed to. |
element element::setTabOrder | ( | int | orderNo | ) |
sets the order in which this element can be tabbed to.
Indexing starts at 0. If this item is at index 5, it will take 5 tabs to focus this element. If the tab order stops at 5, one more tab will bring back to the first element at index 0.\n WARNING: by using this function, we do element:setTabEnabled(true) for you.
The | number of tabs to get to this item. |
element element::setVisible | ( | bool | visible = true | ) |
sets the visibility of the element.
(optional) | The visibility to be set. |
element element::setWidth | ( | float | height | ) |
sets the height of the element.
The | new height. |
element element::setWidth | ( | float | width | ) |
sets the width of the element.
The | new width. |
element element::setX | ( | float | X | ) |
sets the X axis of the element
The | new X position. |
element element::setY | ( | float | Y | ) |
sets the Y axis of the element.
The | new Y position. |
element element::show | ( | ) |
sets the element to be visible.