Controls whether an interactive element is enabled/disabled.
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a checkbox that is interactable, and one that is not
local interactableCheckbox = osrs.Ui.checkbox(
{
label = "Interactable",
onValueChange = function()
osrs.print("Checkbox is Interactable")
end
}
)
local notInteractableCheckbox = osrs.Ui.checkbox(
{
label = "Not Interactable",
enabled = false,
onValueChange = function()
osrs.print("Checkbox is not Interactable, this should not print")
end
}
)
-- Add the Checkbox's to the container
newWindow:addChild(interactableCheckbox)
newWindow:addChild(notInteractableCheckbox)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
The height of this element, in UI coordinate space.
The percentage height of the screen this element should take up when sizeMode is set to LayoutMode.PROPORTIONAL. The number needs to be a decimal.
OptionalonThe callback function triggered when the button is clicked.
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a button with an onClick function
local button = osrs.Ui.textButton(
{
text = "Button",
onClick = function()
osrs.print("button clicked")
end
}
)
-- Add button to the container
newWindow:addChild(button)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
How this element should position itself.
-- Create a window that has automatic position mode, this is default
local window1 = osrs.Ui.window({title = "Automatic Position Mode"})
-- Create a window that has manual position mode
local window2 = osrs.Ui.window(
{
title = "Manual Position Mode",
positionMode = osrs.Ui.LayoutMode.MANUAL
}
)
-- Add the windows to the canvas
osrs.Ui.canvas:addChild(window1)
osrs.Ui.canvas:addChild(window2)
Flag to control whether this element should be placed on the same line as the previous element.
-- Create a container
local window = osrs.Ui.window({title = "Example Window"})
-- Create three buttons, with two of them on the same line
local button1 = osrs.Ui.textButton({text = "Button 1"})
local button2 = osrs.Ui.textButton({text = "Button 2"})
local button3 = osrs.Ui.textButton({text = "Button 3", sameLine = true})
-- Add buttons to the container
window:addChild(button1)
window:addChild(button2)
window:addChild(button3)
-- Add container to the canvas
osrs.Ui.canvas:addChild(window)
How this element should size itself.
-- Create a window that has automatic size mode, this is default
local window1 = osrs.Ui.window({title = "Automatic Size Mode"})
-- Create a window that has manual size mode
local window2 = osrs.Ui.window(
{
title = "Manual Size Mode",
sizeMode = osrs.Ui.LayoutMode.MANUAL,
height = 200,
width = 200
}
)
-- Add the windows to the canvas
osrs.Ui.canvas:addChild(window1)
osrs.Ui.canvas:addChild(window2)
The style, if any, that should be applied to this element.
String to display to the user when hovered over the element.
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a button with a tooltip
local button = osrs.Ui.textButton({text = "Test", tooltip = "This is a Tooltip!"})
-- Add slider to the container
newWindow:addChild(button)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
Boolean indicating whether this UI element should draw itself.
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a button that is renderable, and one that is not
local button1 = osrs.Ui.textButton(
{
text = "Peek-a-Boo",
visible = false,
onClick = function()
osrs.print("BOO!")
end
}
)
local button2 = osrs.Ui.textButton(
{
text = "Render",
onClick = function()
button1.visible = not button1.visible
end
}
)
-- Add buttons to the container
newWindow:addChild(button1)
newWindow:addChild(button2)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
The width of this element, in UI coordinate space.
The percentage width of the screen this element should take up when sizeMode is set to LayoutMode.PROPORTIONAL. The number needs to be a decimal.
The horizontal component of this element's position, in UI coordinate space.
The percentage distance from the left side of the screen that this element's top-left corner should be placed at when positionMode is set to LayoutMode.PROPORTIONAL. The number needs to be a decimal.
The vertical component of this element's position, in UI coordinate space.
The percentage distance from the top side of the screen that this element's top-left corner should be placed at when positionMode is set to LayoutMode.PROPORTIONAL. The number needs to be a decimal.
Adds a UI element to the pop up container.
Imgui element to add to the pop up menu
local button = osrs.Ui.textButton( { text="Clear", tooltip="Test" })
local selectable = osrs.Ui.selectable({text = "Example", onClick = function() osrs.print("Example Print") end}) clear:addPopUpElement(test) osrs.Ui.leftPanel:addChild(button)
Clears the currently displayed image.
local img = osrs.Ui.image({width = 100, height = 100, sizeMode = 1})
local keyDown = function(keycode)
img:clearImage();
end
-- Subscribe to the function
osrs.Events.subscribe(keyDown, osrs.Events.KEY_DOWN)
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns the id of the image currently displayed, if either a sprite or object. via setSpriteId or setObjId. Otherwise, returns -1.
Current id of the image, if sprite or obj.
local img = osrs.Ui.image()
img:setObjId(1511)
if(img:getImageId() == 1511) then
osrs.print("Image ID correctly pulled")
end
img:setSpriteId(780)
if(img:getImageId() == 780) then
osrs.print("Image ID correctly pulled")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns the relative path of the image currently displayed, if set via setImagePath. Otherwise, returns an empty string.
Current path of the image, if currently displaying a local image.
local img = osrs.Ui.image({width = 100, height = 100, sizeMode = 1})
img:setImagePath("example.png")
if(img:getImagePath() == "example.png") then
osrs.print("Image Path correctly pulled")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns the URL of the image currently displayed, if set via setImageURL. Otherwise, returns an empty string.
Current path of the image, if currently displaying an image via URL.
local img = osrs.Ui.image({width = 100, height = 100, sizeMode = 1})
img:setImageURL("https://assets.modcdn.io/images/placeholder/avatar.png")
if(img:getImageURL() == "https://assets.modcdn.io/images/placeholder/avatar.png") then
osrs.print("Image URL correctly pulled")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns the id of the object currently displayed by the image, if the most recent set call was setObjId. Otherwise, returns -1.
Current id of the image, if object.
Returns the id of the sprite currently displayed by the image, if the most recent set call was setSpriteId. Otherwise, returns -1.
Current id of the image, if sprite.
Returns true if the current image is set to display an object image.
If current image is an object.
local img = osrs.Ui.image()
img:setObjId(780)
if(img:isObjImage()) then
osrs.print("This image is correctly recognized as an object")
end
img:setSpriteId(780)
if(not img:isObjImage()) then
osrs.print("This image is correctly recognized as not an object")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns true if the current image is set to display an image from a local path.
If current image is from a local path
local img = osrs.Ui.image()
img:setImagePath("example.png")
if(img:isPathImage()) then
osrs.print("This image is correctly recognized as a local image")
end
img:setSpriteId(780)
if(not img:isPathImage()) then
osrs.print("This image is correctly recognized as not a local image")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns true if the current image is set to display a sprite image.
If current image is a sprite.
local img = osrs.Ui.image()
img:setSpriteId(780)
if(img:isSpriteImage()) then
osrs.print("This image is correctly recognized as a sprite")
end
img:setObjId(780)
if(not img:isSpriteImage()) then
osrs.print("This image is correctly recognized as not a sprite")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns true if the current image is set to display an image from a URL.
If current image is from a URL
local img = osrs.Ui.image()
img:setImagePath("example.png")
if(not img:isURLImage()) then
osrs.print("This image is correctly recognized as not a linked image")
end
img:setImageURL("https://assets.modcdn.io/images/placeholder/avatar.png")
if(img:isURLImage()) then
osrs.print("This image is correctly recognized as a linked image")
end
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Returns whether the path set by setImagePath or the URL set via setImageURL are valid. Returns false and prints to development console if image is not currently set to path or URL. Note that due URL requests being asynchronous, URL validation can only occur after allowing time for the process to complete.
whether an image has been correctly obtained after being set via path or URL.
local img = osrs.Ui.image({width = 100, height = 100, sizeMode = 1})
img:setImagePath("https://assets.modcdn.io/images/placeholder/avatar.png")
if(img:isValid() == false) then
osrs.print("Image URL recognized as not a path")
end
img:setImagePath("example.png")
if(img:isValid() == true) then
osrs.print("Image Path validated")
end
img:setObjId(780)
if(img:isValid() == false) then
osrs.print("Image recognized as not PATH or URL")
end
img:setImageURL("https://assets.modcdn.io/images/placeholder/avatar.png")
osrs.setInterval(function()
if(img:isValid() == true) then
osrs.print("Image URL validated.")
end
end, 1)
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
osrs.Ui.canvas:addChild(newWindow)
Removes a UI element from the pop up container.
Imgui element to remove from the pop up menu.
local button = osrs.Ui.textButton( { text="Clear", tooltip="Test" })
local selectable = osrs.Ui.selectable({text = "Example", onClick = function() osrs.print("Example Print") end}) clear:addPopUpElement(test) clear:removePopUpElement(test) osrs.Ui.leftPanel:addChild(button)
Sets the image to display the image pointed to by the provided path, relative to the plugin folder. Overwrites the current image, and sets isPathImage to return true. Additionally, getImagePath returns the provided path. All other getters return -1 or an empty string. Pass an empty string to clear active image.
Relative path to image to display
local img = osrs.Ui.image({width = 100, height = 100, sizeMode = 1})
img:setImagePath("example.png")
local imgBtn = osrs.Ui.imageButton({width = 100, height = 100, sizeMode = 1})
imgBtn:setImagePath("example.png")
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
newWindow:addChild(imgBtn)
osrs.Ui.canvas:addChild(newWindow)
Sets the image to display the image retrieved from the provided URL, if a valid png is linked. Overwrites the current image, and sets isURLImage to return true. Additionally, getImageURL returns the provided url. All other getters return -1 or an empty string. Pass an empty string to clear active image.
URL of the image to display
local img = osrs.Ui.image({width = 100, height = 100, sizeMode = 1})
img:setImageURL("https://assets.modcdn.io/images/placeholder/avatar.png")
local imgBtn = osrs.Ui.imageButton({width = 100, height = 100, sizeMode = 1})
imgBtn:setImageURL("https://assets.modcdn.io/images/placeholder/avatar.png")
local newWindow = osrs.Ui.window({title="Test"})
newWindow:addChild(img)
newWindow:addChild(imgBtn)
osrs.Ui.canvas:addChild(newWindow)
Sets the image to display the object image of the provided Id. Overwrites the current image, and sets isObjImage to return true. Additionally, both getObjId and getImageId returns the provided id. All other getters return -1 or an empty string. Set to -1 to clear clear active image.
Id of the object to display
Sets the image to display the sprite of the provided Id. Overwrites the current image, and sets isSpriteImage to return true. Additionally, both getSpriteId and getImageId returns the provided id. All other getters return -1 or an empty string. Set to -1 to clear clear active image.
Id of the object to display
A clickable UI element that displays an image specified by an object Id.