mirror of
https://github.com/cuberite/cuberite.git
synced 2025-01-07 03:16:55 +08:00
Update ItemGenerator.lua
This commit is contained in:
parent
dfa2f3687c
commit
77ee79d35c
@ -197,26 +197,39 @@ local function writeItems(registry)
|
||||
io.write("\nenum class Statistic\n{\n", table.concat(names, ",\n"), "\n};")
|
||||
end
|
||||
|
||||
local function writeGlobalPalette(registry)
|
||||
io.write("UInt32 FromItem(Statistic ID)\n{\nswitch (ID)\n{")
|
||||
local function writeGlobalPalette(registry)
|
||||
io.write("UInt32 From(const Statistic ID)\n{\nswitch (ID)\n{")
|
||||
for itemName, id in spairs(registry) do
|
||||
io.write("\ncase Statistic::", makeTitleCase(itemName), ": return ", id, ";")
|
||||
end
|
||||
io.write("\ndefault: return 0;\n}\n}")
|
||||
io.write("\ndefault: return -1;\n}\n}")
|
||||
end
|
||||
|
||||
local function writeReverseGlobalPalette(registry)
|
||||
io.write("Item ToStatistic(UInt32 ID)\n{\nswitch (ID)\n{")
|
||||
io.write("Item ToStatistic(const UInt32 ID)\n{\nswitch (ID)\n{")
|
||||
for itemName, id in spairs(registry) do
|
||||
io.write("\ncase ", id, ": return Item::", makeTitleCase(itemName), ";")
|
||||
end
|
||||
io.write("\ndefault: return Statistic::Air;\n}\n}")
|
||||
end
|
||||
|
||||
if true then
|
||||
writeItems(registry)
|
||||
else
|
||||
writeGlobalPalette(registry)
|
||||
io.write("\n\n")
|
||||
writeReverseGlobalPalette(registry)
|
||||
|
||||
local function writeReverseSerializer(registry)
|
||||
for itemName in spairs(registry) do
|
||||
io.write("{ \"", itemName, "\", Statistic::", makeTitleCase(itemName), " },\n")
|
||||
end
|
||||
end
|
||||
|
||||
local function writeSerializer(registry)
|
||||
io.write("const char * From(const Statistic ID)\n{\nswitch (ID)\n{")
|
||||
for itemName in spairs(registry) do
|
||||
io.write("\ncase Statistic::", makeTitleCase(itemName), ": return \"", itemName, "\";")
|
||||
end
|
||||
end
|
||||
|
||||
-- writeSerializer(registry)
|
||||
|
||||
-- writeItems(registry)
|
||||
|
||||
writeGlobalPalette(registry)
|
||||
-- io.write("\n\n")
|
||||
-- writeReverseGlobalPalette(registry)
|
||||
|
Loading…
Reference in New Issue
Block a user