Interface Scripting
Create a Client.lua file in the Scripts folder.
Add the test.jpg image file to the Pictures folder in the resource manager.
Now input the code block below in Client.lua.
– Floats an image (X=10, Y=10, width=100, height=100)
1
2
3
4
5
6
7
image = Image("Pictures/test.jpg", Rect(10, 10, 100, 100))
-- Change image
-- ex1
image.image = "Icons/01.png"
--ex2
image.SetImage("Icons/05.png")
– Makes a button prompt that displays a message when clicked (X=200, Y=200, width=100, height=100)
1
2
3
4
button = Button("Hi", Rect(200, 200, 100, 100))
button.onClick.Add(function()
Client.ShowAlert("Nice to meet you")
end)
– Creates panels and places text inside the panels
1
2
3
4
panel = Panel()
panel.rect = Rect(300, 200, 50, 50)
text = Text("hooray", Rect(0, 0, 40, 20))
panel.AddChild(text)
– Deletes the created button on click
1
2
3
4
button = Button("hi", Rect(200, 200, 100, 100))
button.onClick.Add(function()
button.Destroy()
end)
– Changes the color of the button
1
2
button = Button("Hi", Rect(200, 200, 100, 100))
button.color = Color(r, g, b, transparency)
– Makes a button prompt that displays a message on the entire server when clicked
1
2
3
4
button = Button("Hi", Rect(200, 200, 100, 100))
button.onClick.Add(function()
Client.FireEvent("HELLO", "Kids, can you hear me?")
end)
Create a Server.lua file in the Scripts/Servers folder and then input the code in the block below.
– Responds to an event named HELLO
1
2
3
Server.GetTopic("HELLO").Add(function(text)
Server.SendCenterLabel(text)
end)
– Adjusts the default UI script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function DefaultUI ()
-- Sets up a controller
controller = Client.controller
-- Changes background image
controller.backgroundImage = "Icons / 01.png";
-- Changes ball image
controller.ballImage = "Icons / 05.png";
-- Changes first path background image, second path ball image
controller.SetControllerImage ("Icons / 01.png", "Icons / 05.png");
-- See ScriptBaseControl for more property values. (See Layout Manager for default location values.)
controller.x = 300-set background position
controller.y = -100
controller.width = 100-change size
controller.height = 200
-- Adjusts the ball position (See ScriptBaseControl for more properties.)
controller.ball.x = 100
-- Set up quick slots (the example covers only one, but there are four quick slots)
slot1 = Client.quickSlots [1]
-- Changes image
-- e.g., 1
slot1.slotImage = "Icons / 01.png"
-- e.g., 2
slot1.SetSlotImage ("Icons / 05.png")
-- See ScriptBaseControl for more property values. (See Layout Manager for default location values.)
slot1.x = -297
slot1.y = -176
slot1.width = 50
slot1.height = 50
-- Changes the location, size, etc. of icons in the Skill Slot. (See ScriptBaseControl for more properties.)
slot1.icon.x = -297
-- Sets up replacement slots
changeSlot = Client.changeSlot;
-- Changes swap slot image
-ex1
changeSlot.slotImage = "Icons / 01.png"
-ex2
changeSlot.SetSlotImage ("Icons / 05.png")
-- See ScriptBaseControl for more property values. (See Layout Manager for default location values.)
changeSlot.x = -297
changeSlot.y = -105
changeSlot.width = 70
changeSlot.height = 70
-- Changes the position, size, etc. of icons in the swap slot. (See ScriptBaseControl for more properties.)
changeSlot.icon.x = -297
end
– Adjusts the default ScreenUI
1
2
3
4
5
6
7
8
9
10
11
12
-If all values are set to true or false, the value disappears from the screen.
ScreenUI.visible = false;
ScreenUI.hpBarVisible = false
ScreenUI.mpBarVisible = false
ScreenUI.levelVisible = false
ScreenUI.gameMoneyVisible = false
ScreenUI.bagVisible = false
ScreenUI.expBarVisible = false
ScreenUI.chatViewVisible = false
ScreenUI.chatInputVisible = false
ScreenUI.buffPanelVisible = false;
– Prints the picture file name
1
print(Client.GetImageName(Client.GetItem(0).imageID))