-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_save.lua
More file actions
33 lines (23 loc) · 957 Bytes
/
generate_save.lua
File metadata and controls
33 lines (23 loc) · 957 Bytes
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
util = require "util"
there =
"/home/kitten/.minecraft/saves/GB Emulator 1_18_2/datapacks/CraftBoyDatapack/data/"
therefile = "craftboy/functions/load_save.mcfunction"
save = {}
directory = "/home/kitten/プロジェクト/Gameboy/Badboy/tests/saves/"
save.filename = "pkred.sav"
save.file = io.open(directory .. save.filename, "r")
save.data = {}
util.file_to_bytes(save.file, save.data, 0x0000)
save.mcfunction = io.open(there .. therefile, "w")
save.mcfunction:write("say LOADING " .. save.filename .. "\n")
for i = 0, 0x7FFF do
if not save.data[i] then
save.mcfunction:write("scoreboard players set " .. i .. " sram 255\n")
else
save.mcfunction:write("scoreboard players set " .. i .. " sram " ..
save.data[i] .. "\n")
end
end
save.mcfunction:write("scoreboard players set ram_bank craftboy 0\n")
save.mcfunction:write("function craftboy:mbc/ram_load")
save.mcfunction:close()