basic setup

This commit is contained in:
webdesigner97 2016-01-26 15:56:01 +01:00
parent 9586e502c3
commit c9039bf290
4 changed files with 86 additions and 0 deletions

26
api.lua Normal file
View File

@ -0,0 +1,26 @@
--[[
## StreetsMod 2.0 ##
Submod: streetsmod
Optional: false
Category: Init
]]
function streets.load_submod(dirname)
-- Check whether submod's init file exists
local f = io.open(streets.conf.modpath .. "/" .. dirname .. "/init.lua")
if f ~= nil then
-- Load it
f.close()
dofile(streets.conf.modpath .. "/" .. dirname .. "/init.lua")
else
minetest.log("error", "[Streets] '" .. dirname .. "' does not exist")
end
end
function streets.register_road_surface(nodename, nodedef)
streets.api.register_road_surfaces[nodename] = nodedef
end
function streets.register_road_marking(markingname, texture)
streets.api.register_road_markings[markingname] = texture
end

25
api_register_all.lua Normal file
View File

@ -0,0 +1,25 @@
--[[
## StreetsMod 2.0 ##
Submod: streetsapi
Optional: false
Category: Init
]]
minetest.after(0, function()
for nodename, nodedef in pairs(streets.api.register_road_surfaces) do
-- Register the node
minetest.register_node(nodename, nodedef)
-- Register all markings for this node
for markingname, markingtexture in pairs(streets.api.register_road_markings) do
minetest.register_node(nodename .. "_" .. markingname, {
tiles = {nodedef.tiles[1] .. "^" .. markingtexture, nodedef.tiles[1]},
groups = nodedef.groups
})
end
-- Register the craft
if nodedef.craft ~= nil then
minetest.register_craft(nodedef.craft)
end
end
end)

1
depends.txt Normal file
View File

@ -0,0 +1 @@
default

34
init.lua Normal file
View File

@ -0,0 +1,34 @@
--[[
## StreetsMod 2.0 ##
Submod: streetsmod
Optional: false
Category: Init
]]
print("[Mod][StreetsMod] Loading...")
-- Register a global streets namespace to operate in
streets = {}
-- Config stuff goes here
streets.conf = {
version = "2.0",
licenseCode = "",
licenseMedia = "CC-BY-SA 3.0",
modpath = minetest.get_modpath("streets")
}
-- The API collects some data here
streets.api = {
register_road_surfaces = {},
register_road_markings = {}
}
-- Load the API file
dofile(streets.conf.modpath .. "/api.lua")
-- Load mod files
streets.load_submod("streets_roadsurface")
streets.load_submod("streets_roadmarkings")
-- Let the API register everything and finish the setup
dofile(streets.conf.modpath .. "/api_register_all.lua")