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