export data as js-files with global storage
makes it possible to view it locally without webserver
This commit is contained in:
parent
bd443bfc9b
commit
c3f1070630
2
abm.lua
2
abm.lua
@ -12,5 +12,5 @@ minetest.register_on_mods_loaded(function()
|
||||
local data = {}
|
||||
|
||||
mtinfo.map_list(data, minetest.registered_abms, abm_mapped_keys)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/abm.json", data)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/abm.js", data, "mtinfo.abm")
|
||||
end)
|
||||
|
@ -13,6 +13,7 @@
|
||||
mtinfo = {};
|
||||
</script>
|
||||
<script src="js/util/imageresolver.js"></script>
|
||||
<script src="data/nodes.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
m.request("./data/nodes.json")
|
||||
.then(nodes => {
|
||||
const list = [];
|
||||
function init(){
|
||||
|
||||
Object.keys(nodes)
|
||||
.map(name => nodes[name])
|
||||
var list = [];
|
||||
|
||||
Object.keys(mtinfo.nodes)
|
||||
.map(name => mtinfo.nodes[name])
|
||||
.forEach(node => list.push(node));
|
||||
|
||||
let rows = list
|
||||
@ -31,4 +31,6 @@ m.request("./data/nodes.json")
|
||||
]);
|
||||
|
||||
m.render(document.getElementById("app"), table);
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
|
@ -48,12 +48,14 @@ function mtinfo.copyrecursive(src, target)
|
||||
end
|
||||
end
|
||||
|
||||
function mtinfo.export_json(fname, data)
|
||||
function mtinfo.export_json(fname, data, varname)
|
||||
local f = io.open(fname, "w")
|
||||
local data_string, err = minetest.write_json(data)
|
||||
if err then
|
||||
error(err)
|
||||
end
|
||||
f:write(varname .. "=")
|
||||
f:write(data_string)
|
||||
f:write(";")
|
||||
io.close(f)
|
||||
end
|
||||
|
@ -12,5 +12,5 @@ minetest.register_on_mods_loaded(function()
|
||||
local data = {}
|
||||
|
||||
mtinfo.map_list(data, minetest.registered_items, item_mapped_keys)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/items.json", data)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/items.js", data, "mtinfo.items")
|
||||
end)
|
||||
|
2
lbm.lua
2
lbm.lua
@ -10,5 +10,5 @@ minetest.register_on_mods_loaded(function()
|
||||
local data = {}
|
||||
|
||||
mtinfo.map_list(data, minetest.registered_lbms, lbm_mapped_keys)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/lbm.json", data)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/lbm.js", data, "mtinfo.lbm")
|
||||
end)
|
||||
|
@ -36,5 +36,5 @@ minetest.register_on_mods_loaded(function()
|
||||
return true
|
||||
end
|
||||
end)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/nodes.json", data)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/nodes.js", data, "mtinfo.nodes")
|
||||
end)
|
||||
|
@ -6,5 +6,5 @@ minetest.register_on_mods_loaded(function()
|
||||
data[name] = minetest.get_all_craft_recipes(name)
|
||||
end
|
||||
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/recipes.json", data)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/recipes.js", data, "mtinfo.recipes")
|
||||
end)
|
||||
|
@ -12,5 +12,5 @@ minetest.register_on_mods_loaded(function()
|
||||
local data = {}
|
||||
|
||||
mtinfo.map_list(data, minetest.registered_tools, tool_mapped_keys)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/tools.json", data)
|
||||
mtinfo.export_json(mtinfo.basepath.."/data/tools.js", data, "mtinfo.tools")
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user