-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathmiddleware.lua
120 lines (100 loc) · 2.72 KB
/
middleware.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
setImagePath(dir)
local function ApplyDefaults()
local Defaults =
{
BoostItem_SelectionMode = "disabled",
Story_Skip = 0,
Debug_Mode = false,
StopAfterBond10 = 0,
UnstableFastSkipDeadAnimation = 0,
Withdraw_Enabled = false,
GameRegion = "EN",
Refill_Enabled = 0,
Refill_Resource = "All Apples",
Refill_Repetitions = 0,
Support_SelectionMode = "first",
Support_SwipesPerUpdate = 10,
Support_MaxUpdates = 3,
Support_FallbackTo = "manual",
Support_FriendsOnly = 0,
Support_FriendNames = "",
Support_PreferredServants = "",
Support_PreferredCEs = "",
Party_Number = nil,
Enable_Autoskill = 0,
Skill_Confirmation = 0,
Autoskill_List = { },
Battle_CardPriority = "BAQ",
Battle_AutoChooseTarget = 1,
Battle_NoblePhantasm = "disabled"
}
for key, defaultValue in pairs(Defaults) do
globalValue = _G[key]
if globalValue == nil then
_G[key] = defaultValue
end
end
end
-- Writes autoskill options into global variables
local function ExtractAutoskillOptions(selected_autoskill)
for key, value in pairs(selected_autoskill) do
-- We don't want to make Name a global variable
if key ~= "Name" then
-- _G is global variable table
_G[key] = value
end
end
end
local function AddRefillInfoToDialog()
if Refill_Enabled == 1 then
if Refill_Resource == "SQ" then
RefillType = "sq"
elseif Refill_Resource == "All Apples" then
RefillType = "all apples"
elseif Refill_Resource == "Gold" then
RefillType = "gold apples"
elseif Refill_Resource == "Silver" then
RefillType = "silver apples"
else
RefillType = "bronze apples"
end
addTextView("Auto Refill Enabled:")
newRow()
addTextView("You are going to use")
newRow()
addTextView(Refill_Repetitions .. " " .. RefillType .. ", ")
newRow()
addTextView("remember to check those values everytime you execute the script!")
addSeparator()
end
end
local function AddAutoskillListToDialog()
-- Autoskill list dialogue content generation.
if Enable_Autoskill == 1 then
addTextView("Please select your predefined Autoskill setting:")
newRow()
addRadioGroup("AutoSkillIndex", 1)
for key, value in ipairs(Autoskill_List)
do
addRadioButton(value["Name"], key)
end
end
end
--User option PSA dialogue. Also choosable list of predefined skill.
function PSADialogue()
dialogInit()
AddRefillInfoToDialog()
AddAutoskillListToDialog()
--Show the generated dialogue.
dialogShow("CAUTION")
if Enable_Autoskill == 1 then
--Put user selection into variables
local selected_autoskill = Autoskill_List[AutoSkillIndex]
ExtractAutoskillOptions(selected_autoskill)
else
addTextView("AutoSkill is disabled, the script will battle automatically.")
end
end
ApplyDefaults()
PSADialogue()
dofile(dir .. "regular.lua")