-
Notifications
You must be signed in to change notification settings - Fork 0
/
bod-trans.lua
98 lines (84 loc) · 3 KB
/
bod-trans.lua
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-------------------------------------------------------------------------------
-- Script Name: Transplace BOD
--
--
--
--
-- Load libraries
dofile("utilities.lua")
-- Global variables
local form, btnSourceBook, lblSourceBook, btnTargetBook, lblTargetBook
local sourceBook, targetBook
-- GUI methods
function onClose()
Obj.Exit()
end
function freeElements()
Obj.Free(form) --release object from memory
Obj.Free(btnSourceBook)
Obj.Free(lblSourceBook)
Obj.Free(btnTargetBook)
Obj.Free(lblTargetBook)
end
function onClickSourceBook()
local item = getTargetItem()
if item ~= nil and item.Type == 8793 then
if not (item.Property["Book Name"] == nil or #item.Property["Book Name"] == 0) then
lblSourceBook.Caption = item.Name..":"..item.Property["Book Name"]
else
lblSourceBook.Caption = item.Name
end
sourceBook = item
else
sourceBook = nil
lblSourceBook.Caption = "N/A"
end
end
function onClickTargetBook()
local item = getTargetItem()
if item ~= nil and item.Type == 8793 then
if not (item.Property["Book Name"] == nil or #item.Property["Book Name"] == 0) then
lblTargetBook.Caption = item.Name..":"..item.Property["Book Name"]
else
lblTargetBook.Caption = item.Name
end
targetBook = item
else
targetBook = nil
lblTargetBook.Caption = "N/A"
end
end
function main()
form = Obj.Create("TForm") --create a TForm object
form.OnClose = onClose
form.Caption = "BOD Transplacer"
form.FormStyle = 3 -- always on top
-- Button to choose source book
btnSourceBook = Obj.Create("TButton") --create a TButton object
btnSourceBook.Caption = "Source Book" --assign button text
btnSourceBook.OnClick = onClickSourceBook --assign event handler function
btnSourceBook.Parent = form --IMPORTANT: button is placed on form!
btnSourceBook.Top = 10
btnSourceBook.Left = 10
lblSourceBook = Obj.Create("TLabel")
lblSourceBook.Caption = "N/A"
lblSourceBook.Top = btnSourceBook.Top + (btnSourceBook.Height - lblSourceBook.Height) / 2
lblSourceBook.Left = btnSourceBook.Left + btnSourceBook.Width + 15
lblSourceBook.Parent = form
-- Button to choose target book
btnTargetBook = Obj.Create("TButton") --create a TButton object
btnTargetBook.Caption = "Target Book" --assign button text
btnTargetBook.OnClick = onClickTargetBook --assign event handler function
btnTargetBook.Parent = form --IMPORTANT: button is placed on form!
btnTargetBook.Top = 10 + btnSourceBook.Top + btnSourceBook.Height
btnTargetBook.Left = 10
lblTargetBook = Obj.Create("TLabel")
lblTargetBook.Caption = "N/A"
lblTargetBook.Top = btnTargetBook.Top + (btnTargetBook.Height - lblTargetBook.Height) / 2
lblTargetBook.Left = btnTargetBook.Left + btnTargetBook.Width + 15
lblTargetBook.Parent = form
form.Show()
Obj.Loop()
freeElements()
end
main()