/
init.lua
149 lines (136 loc) · 4.16 KB
/
init.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
local variables = {
version = "1.1.0",
achievement_list = {
"All The President's Men",
"City Lights",
"To Bad Decisions!",
"Breathtaking",
"Bushido and Chill",
"Full Body Conversion",
"Right Back At Ya",
"Dirty Deeds",
"The APB is Not Enough",
"Easy Come, Easy Go",
"To Protect and Serve",
"The Wandering Fool",
"Autojock",
"Frequent Flyer",
"Gun Fu",
"Gunslinger",
"Master Crafter",
"Judgment Day",
"I Am The Law",
"Arachnophobia",
"King of Cups",
"King of Pentacles",
"King of Swords",
"King of Wands",
"Spin Doctor",
"Mean Streets",
"Little Tokyo",
"Christmas Tree Attack",
"The Quick and the Dead",
"Must Be Rats",
"Never Fade Away",
"The Wasteland",
"Daemon In The Shell",
"Life of the Road",
"Relic Ruler",
"Stanislavski's Method",
"Ten out of Ten",
"Temperance",
"Rough Landing",
"The Devil",
"The Fool",
"The Hermit",
"The High Priestess",
"The Lovers",
"The Star",
"The Sun",
"The Tower",
"The Wheel of Fortune",
"The World",
"Greetings from Pacifica!",
"The Jungle",
"True Soldier",
"True Warrior",
"Two Heads, One Bullet",
"Judy vs Night City",
"V for Vendetta",
"It's Elementary",
"Legend of The Afterlife"
} -- Dumped from TweakDB
}
local settings = {
is_overlay_open = false,
achievement_index = 1
}
local local_player = function()
local player = Game.GetPlayer()
if player then
local player_position = player:GetWorldPosition()
if math.floor(player_position.z) ~= 0 then
return true
end
end
print("[achievement_unlocker] Load into the game before using this script")
return false
end
local unlock_all_achievements = function()
if local_player() then
for key, value in pairs(TweakDB:GetRecords("gamedataAchievement_Record")) do
Game.GetAchievementSystem():UnlockAchievement(value)
end
print("[achievement_unlocker] Successfully unlocked all achievements")
end
end
local unlock_achievement_index = function(index)
if local_player() then
for key, value in pairs(TweakDB:GetRecords("gamedataAchievement_Record")) do
if key == index then
Game.GetAchievementSystem():UnlockAchievement(value)
end
end
print("[achievement_unlocker] Successfully unlocked achievement: " .. variables.achievement_list[index])
end
end
registerForEvent("onDraw", function()
if not settings.is_overlay_open then
return
end
ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, 300, 40)
ImGui.Begin("Achievement Unlocker", ImGuiWindowFlags.AlwaysAutoResize)
local unlock_all_toggled = ImGui.Button("Unlock All Achievements")
if unlock_all_toggled then
unlock_all_achievements()
end
ImGui.Spacing()
ImGui.Separator()
local unlock_specific_toggled = ImGui.Button("Unlock Achievement")
if unlock_specific_toggled then
unlock_achievement_index(settings.achievement_index)
end
if ImGui.BeginCombo("Achievement Name", variables.achievement_list[settings.achievement_index]) then
for index, achievement in ipairs(variables.achievement_list) do
local is_selected = (settings.achievement_index == index)
if ImGui.Selectable(achievement, is_selected) then
settings.achievement_index = index
end
if is_selected then
ImGui.SetItemDefaultFocus()
end
end
ImGui.EndCombo()
end
ImGui.End()
ImGui.PopStyleVar(1)
end)
registerForEvent("onInit", function()
print("[achievement_unlocker] Successfully loaded - version: " .. variables.version)
end)
registerForEvent("onOverlayOpen", function()
settings.is_overlay_open = true
end)
registerForEvent("onOverlayClose", function()
settings.is_overlay_open = false
end)