forked from Yahiamice/yahimod-balatro
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.lua
More file actions
445 lines (394 loc) · 11.9 KB
/
core.lua
File metadata and controls
445 lines (394 loc) · 11.9 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
----------------------------------------------------------
----------- MOD CODE -------------------------------------
-- shoutouts cryptid & mathisfun --
if not Yahimod then
Yahimod = {}
end
local global = {}
if next(SMODS.find_mod("Talisman")) then
Yahimod.hastalisman = true
print("Talisman found! Working on compatibility...")
else
Yahimod.hastalisman = false
print("No talisman found. YAHIMOD will do things as usual")
end
function tNum(number) -- for talisman compat
local _numnum = number
if Yahimod.hastalisman == true then _numnum = to_big(number) end -- this just crashes so often wtf
return _numnum
end
G.C.YAHIPURPLE = HEX("d342fe")
G.C.YAHIORANGE = HEX("ffd874")
G.C.mid_flash = 0
G.C.vort_time = 7
G.C.vort_speed = 0.4
-- from cryptid :}
local oldfunc = Game.main_menu
Game.main_menu = function(change_context)
local ret = oldfunc(change_context)
G.SPLASH_BACK:define_draw_steps({
{
shader = "splash",
send = {
{ name = "time", ref_table = G.TIMERS, ref_value = "REAL_SHADER" },
{name = 'vort_speed', val = G.C.vort_speed},
{name = 'colour_1', ref_table = G.C, ref_value = 'YAHIPURPLE'},
{name = 'colour_2', ref_table = G.C, ref_value = 'YAHIORANGE'},
{name = 'mid_flash', ref_table = G.C, ref_value = 'mid_flash'},
},
},
})
return ret
end
-- code borrowed (& modified) from NeatoJokers by LauraOnline!!
SMODS.current_mod.description_loc_vars = function()
return { background_colour = G.C.CLEAR, text_colour = G.C.WHITE, scale = 1.4, shadow = true }
end
local creditspage = {
"Yahiamice",
"(mod author, 99% of the work)",
"",
"Lisnovski, Blake Andrews, violxiv",
"Art assets",
"",
"Nova_422, Sciman101",
"Code contributions",
"",
"meganeko",
"Cybergrind soundtrack",
"",
"HexaCryonic, Burssty",
"Playtesting",
}
SMODS.current_mod.extra_tabs = function() --Credits tab
local scale = 0.5
return {
label = "Credits",
tab_definition_function = function()
return {
n = G.UIT.ROOT,
config = {
align = "cm",
padding = 0.05,
colour = G.C.CLEAR,
},
nodes = {
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "By Yahiamice",
shadow = false,
scale = scale*2,
colour = G.C.PURPLE
}
}
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Some art assets by",
shadow = false,
scale = scale*0.66,
colour = G.C.INACTIVE
}
},
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Lisnovski, Blake Andrews, violxiv",
shadow = false,
scale = scale,
colour = G.C.MONEY
}
},
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Code contributions by",
shadow = false,
scale = scale*0.66,
colour = G.C.INACTIVE
}
}
},
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Nova_422, Sciman101, enhancedrock",
shadow = false,
scale = scale,
colour = G.C.GREEN
}
}
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Music from",
shadow = false,
scale = scale*0.66,
colour = G.C.INACTIVE
}
}
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "The Cyber Grind - meganeko / Buy Somethin' Will Ya - Earthbound / Game Corner - Pokemon Emerald",
shadow = false,
scale = scale*0.75,
colour = G.C.RED
}
}
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Special thanks:",
shadow = false,
scale = scale*0.66,
colour = G.C.INACTIVE
}
}
}
},
{
n = G.UIT.R,
config = {
padding = 0,
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = "Burssty & HexaCryonic for playtesting & the Cryptid Discord for help!",
shadow = false,
scale = scale*0.66,
colour = G.C.BLUE
}
}
}
}
}
}
end
}
end
G.FUNCS.go_to_yahi_twitch = function(e)
love.system.openURL("https://twitch.tv/yahiamice")
end
G.FUNCS.go_to_yahi_yt = function(e)
love.system.openURL("https://youtube.com/yahiamicelive")
end
G.C.YAHIPURPLE = HEX("d342fe")
G.C.YAHIORANGE = HEX("ffd874")
G.C.mid_flash = 0
G.C.vort_time = 7
G.C.vort_speed = 0.4
-- from cryptid :}
local oldfunc = Game.main_menu
Game.main_menu = function(change_context)
local ret = oldfunc(change_context)
G.SPLASH_BACK:define_draw_steps({
{
shader = "splash",
send = {
{ name = "time", ref_table = G.TIMERS, ref_value = "REAL_SHADER" },
{name = 'vort_speed', val = G.C.vort_speed},
{name = 'colour_1', ref_table = G.C, ref_value = 'YAHIPURPLE'},
{name = 'colour_2', ref_table = G.C, ref_value = 'YAHIORANGE'},
{name = 'mid_flash', ref_table = G.C, ref_value = 'mid_flash'},
},
},
})
return ret
end
local mod_path = "" .. SMODS.current_mod.path
Yahimod.path = mod_path
Yahimod_config = SMODS.current_mod.config
SMODS.current_mod.optional_features = {
retrigger_joker = true,
post_trigger = true,
}
-- effect manager for particles etc
G.effectmanager = {}
-- safe json decoder
local function safe_json_decode(str)
if type(str) ~= "string" or str == "" then
return nil, "empty body"
end
local ok, result = pcall(json.decode, str)
if ok then
return result
else
return nil, result
end
end
--get twitch numbers
G.last_update_time = 0
function recheckTwitch(please)
if ((os.time() - G.last_update_time) >= 90) or please == "please" then
G.last_update_time = os.time()
local json = require "json"
local succ, https = pcall(require, "SMODS.https")
local url = "https://gql.twitch.tv/gql"
local options = {
method = "POST",
data = '[{"operationName":"VideoMetadata","variables":{"channelLogin":"Yahiamice","videoID":"0"},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"45111672eea2e507f8ba44d101a61862f9c56b11dee09a15634cb75cb9b9084d"}}}]',
headers = {
["Client-ID"] = "kimne78kx3ncx6brgo4mv6wki5h1ko",
["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
["Content-Type"] = "application/json"
}
}
local status, body, headers = https.request(url, options)
local ok, parsed = pcall(json.decode, body or "")
if not ok or type(parsed) ~= "table" then
G.yahifollowers = 67000
G.yahiviewers = 0
print("Couldn't JSON decode for some reason. Check your VPN?")
return
end
G.twitchbodyjson = json.decode(body)
G.yahifollowers = G.twitchbodyjson[1].data.user.followers.totalCount
G.yahiviewers = 0
if G.twitchbodyjson[1].data.user.stream then G.yahiviewers = G.twitchbodyjson[1].data.user.stream.viewersCount else print("Failed to parse yahi's viewer count! Maybe he's offline?") end
else
--print("Can't update! Wait " .. (90 - (os.time() - G.last_update_time)) .. " more seconds please...")
end
end
-- Cat joker pool
SMODS.ObjectType({
key = "Cat",
default = "j_reserved_parking",
cards = {},
inject = function(self)
SMODS.ObjectType.inject(self)
-- insert base game food jokers
self:inject_card(G.P_CENTERS.j_lucky_cat)
end,
})
-- Yahimod joker pool
SMODS.ObjectType({
key = "Yahimodaddition",
default = "j_reserved_parking",
cards = {},
inject = function(self)
SMODS.ObjectType.inject(self)
-- insert base game food jokers
end,
})
--Yahimod.nuuhstream = love.graphics.newVideoStream( Yahimod.path .. "nuuh.ogv" )
--Yahimod.nuuh = love.graphics.newVideo( Yahimod.nuuhstream )
--Load item files
local files = NFS.getDirectoryItems(mod_path .. "items")
for _, file in ipairs(files) do
print("[YAHIMOD] Loading lua file " .. file)
local f, err = SMODS.load_file("items/" .. file)
if err then
error(err)
end
f()
end
--Load lib files
local files = NFS.getDirectoryItems(mod_path .. "libs/")
for _, file in ipairs(files) do
print("[YAHIMOD] Loading lib file " .. file)
local f, err = SMODS.load_file("libs/" .. file)
if err then
error(err)
end
f()
end
--Load Localization file
local files = NFS.getDirectoryItems(mod_path .. "localization")
for _, file in ipairs(files) do
print("[YAHIMOD] Loading localization file " .. file)
local f, err = SMODS.load_file("localization/" .. file)
if err then
error(err)
end
f()
end
--Load misc stuff so i only hook things once
--local hook = love.load
--function love.load()
-- hook()
-- local full_path = (Yahimod.path
-- .."assets/"
-- .. G.SETTINGS.GRAPHICS.texture_scaling
-- .. "x/"
-- .. "horse.png")
-- file_data = assert(NFS.newFileData(full_path),("Epic fail"))
-- Yahimod.horsepngimagedata = assert(love.image.newImageData(file_data),("Epic fail 2"))
-- Yahimod.horsepng = assert(love.graphics.newImage(Yahimod.horsepngimagedata),("Epic fail 3"))
--
--end
----------------------------------------------------------
----------- MOD CODE END ----------------------------------