-
Notifications
You must be signed in to change notification settings - Fork 0
/
hud.js
103 lines (94 loc) · 2.14 KB
/
hud.js
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
var sprites = [
["bow", 1],
["boomerang", 1],
["hookshot", 1],
["bombs", 1],
["mushroom", 1],
["fireRod", 1],
["iceRod", 1],
["bombos", 1],
["ether", 1],
["quake", 1],
["lamp", 1],
["hammer", 1],
["flute", 1],
["bugNet", 1],
["book", 1],
["somaria", 1],
["byrna", 1],
["cape", 1],
["mirror", 2],
["gloves", 1],
["boots", 1],
["flippers", 1],
["moonPearl", 1],
["sword", 1],
["shield", 1],
["armor", 0],
["bottle", 1],
["bottle2", 1],
["bottle3", 1],
["bottle4", 1],
["pendant_green", 1],
["pendant_blue", 1],
["pendant_red", 1],
["crystal_mm", 1],
["crystal_pod", 1],
["crystal_ip", 1],
["crystal_tr", 1],
["crystal_sp", 1],
["crystal_tt", 1],
["crystal_sw", 1],
["boomerang", 2],
["sword", 2],
["sword", 3],
["sword", 4],
["armor", 1],
["armor", 2],
["gloves", 2],
["shield", 2],
["shield", 3],
["mushroom", 2],
["flute", 2],
["bow", 2],
["bow", 3],
["bottle", 3],
["bottle", 4],
["bottle", 5],
["bottle", 6],
["bottle", 7],
["aga", 1]
]
var update = function() {
document.getElementById("hud-data").remove()
var script = document.createElement("script")
script.id = "hud-data"
script.type = "text/javascript"
script.src = "items-data.js?" + new Date().getTime()
document.head.appendChild(script)
var itemDivs = document.getElementsByClassName("item")
for(var i = 0; i < itemDivs.length; i++) {
var div = itemDivs.item(i)
var firstSpriteIndex = null
var spriteIndex = null
var itemName = div.id
if (itemName.indexOf("bottle") > -1) itemName = "bottle"
for (var j = 0; j < sprites.length; j++) {
var itemStatus = items[div.id]
if (sprites[j][0] == itemName && sprites[j][1] <= itemStatus) {
spriteIndex = j
} else if (sprites[j][0] == itemName && firstSpriteIndex == null) {
firstSpriteIndex = j
}
}
if (spriteIndex == null) {
div.style.backgroundPositionX = (firstSpriteIndex * -16) + "px"
div.style.opacity = 0.5
} else {
div.style.backgroundPositionX = (spriteIndex * -16) + "px"
div.style.opacity = 1
}
}
}
update()
setInterval(update, 1000)