Drag
This will explain how to create and use a Drag object
A "drag" is an object that allows for dragging on the gui screen with objects and adaptively changes the x and y values.
These x and y values save and load in when you enable and disable a script.

How to create a Drag object

1
var drag = createDrag({
2
initialX: 100,
3
initialY: 100
4
})
Copied!

Parameters

Parameter
Description
initialX
The initial x value for the drag
initialY
The initial y value for the drag
These values will be used when clicking the "Reset Draggables" button in the Gui Chat menu

How to use the Drag object

First off you will want to create the Drag object and then in an event you must set the width and height of the drag, this allows for you to adaptively change the width and height of the Drag.
1
var drag = createDrag({
2
initialX: 100,
3
initialY: 100
4
})
5
​
6
script.onRender2D(function (event) {
7
drag.setWidth(100)
8
drag.setHeight(100)
9
​
10
render.drawRect(drag.getX(), drag.getY(), drag.getWidth(), drag.getHeight(), color({red: 255, green: 255, blue: 255}))
11
12
})
Copied!

Functions

Function
Description
getX()
Gets the current x value of the Drag object
getY()
Gets the current y value of the Drag object
getWidth()
Gets the current width of the Drag object
getHeight()
Gets the current height of the Drag object
setWidth()
Sets the width of the Drag object
setHeight()
Sets the height of the Drag object