-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathother functions.lua
184 lines (163 loc) · 5.5 KB
/
other functions.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
function pause(pause)
if pause ~= nil then
paused = pause
else
paused = not paused
end
if songs[1] then
if paused then songs[currentSong]:pause() else songs[currentSong]:play() end
end
if background['Video'] then
if paused then background['Background']:pause() else background['Background']:play() end
end
gStateMachine:pause()
end
function createBackground()
if background['Video'] then
background['Background'] = love.graphics.newVideo(background['Filename'])
background['Background']:play()
else
if love.filesystem.getInfo(background['Filename']) then
background['Background'] = love.graphics.newImage(background['Filename'])
end
end
end
function updateBackground()
background['Filename'], background['Video'], background['Seek'] = backgroundInfo(background['Name'])
createBackground()
collectgarbage()
end
function repositionMouse(index)
if gui[index] then
mouseTouching = gui[index]
else
for k, pair in pairs(gui) do
if pair == index then
mouseTouching = index
break
end
end
if mouseTouching ~= index then
return
end
end
if mouseTouching.y + mouseTouching.height > VIRTUALHEIGHT then
yscroll = yscroll + (VIRTUALHEIGHT - (mouseTouching.y + mouseTouching.height + 50))
mouseTouching.y = mouseTouching.initialY + yscroll
elseif mouseTouching.y < 0 then
yscroll = yscroll - (mouseTouching.y - 50)
mouseTouching.y = mouseTouching.initialY + yscroll
end
if mouseTouching.percentage then
mouseButtonX,mouseButtonY = push.toReal(mouseTouching.x + (mouseTouching.width*mouseTouching.percentage),mouseTouching.y + mouseTouching.height/2)
else
mouseButtonX,mouseButtonY = push.toReal(mouseTouching.x+mouseTouching.width/2,mouseTouching.y+mouseTouching.height/2)
end
love.mouse.setPosition(mouseButtonX,mouseButtonY)
love.mouse.setVisible(false)
end
function toggleSetting(setting,toggle)
if toggle ~= nil then
if toggle == Settings[setting] then return false end
Settings[setting] = toggle
else
Settings[setting] = not Settings[setting]
end
bitser.dumpLoveFile('Settings.txt',Settings)
end
function controllerBinds(button)
if button == 'a' then
return 'return'
elseif button == 'b' then
return 'escape'
elseif button == 'start' then
return 'space'
elseif button == 'dpleft' then
return 'left'
elseif button == 'dpright' then
return 'right'
elseif button == 'dpup' then
return 'up'
elseif button == 'dpdown' then
return 'down'
end
return false
end
function wrap(str, limit)
local limit = limit or 72
local here = 1
-- the "".. is there because :gsub returns multiple values
return ""..str:gsub("(%s+)()(%S+)()",
function(sp, st, word, fi)
if fi-here > limit then
here = st
return "\n"..word
end
end)
end
function P1deckEdit(position,name,nosave)
if name and name[1] == 'Blank' then name = nil end
P1deckCards[position] = name
if not nosave then
bitser.dumpLoveFile(Settings['active_deck'],P1deckCards)
end
end
function P1cardsEdit(position,name,nosave)
if name and name[1] == 'Blank' then name = nil end
P1cards[position] = name
if not nosave then
bitser.dumpLoveFile('Player 1 cards.txt',P1cards)
end
end
function characterStrength(character)
if character == nil then return 0 end
local stats
local modifier
local offense
if character[1] then
stats = Characters[character[1]]
modifier = ((character[2] + (60 - character[2]) / 1.7) / 60) * (1 - ((4 - character[3]) * 0.1))
else
stats = Characters[character]
modifier = 1
end
if stats['range'] == 1 then
offense = ((stats['meleeOffense']*modifier)/800)^4 * 0.9
else
local meleeOffense = ((stats['meleeOffense']*modifier)/800)^4
local rangedOffense
if stats['rangedOffense'] then
rangedOffense = ((stats['rangedOffense']*modifier)/800)^4
else
rangedOffense = meleeOffense
end
local rangeFactor = ((stats['range']-1.5)/20)^0.55*4.6
if rangedOffense < meleeOffense then
offense = meleeOffense * 0.9 + rangedOffense * 0.1 * rangeFactor^0.1
else
local rangeProportion = rangeFactor / (rangeFactor + 1)
offense = meleeOffense * (1-rangeProportion) + rangedOffense * rangeProportion + (rangedOffense * rangeFactor^0.1 - rangedOffense) * 0.1
end
end
if offense < 10 then
offense = 10 - (10-offense) / 2
end
return offense+((stats['defense']*modifier)/800)^4*(1+stats['evade']^0.6*0.3)
end
function compareCharacterStrength(character1, character2)
local strength = characterStrength
return strength(character1) > strength(character2)
end
function tutorial()
P1deckCards = {}
P1deckEdit(1,{'Grogu',60,4},true)
P1deckEdit(2,{'Farmboy Luke Skywalker',60,4},true)
P1deckEdit(3,{'C-3PO',60,4},true)
P1deckEdit(4,{'R2-D2',60,4},true)
bitser.dumpLoveFile('Player 1 deck.txt',P1deckCards)
bitser.dumpLoveFile('Player 1 deck 2.txt',{})
bitser.dumpLoveFile('Player 1 deck 3.txt',{})
bitser.dumpLoveFile('Player 1 cards.txt',{})
UserData['Credits'] = 100
bitser.dumpLoveFile('User Data.txt',UserData)
end