forked from Minetest/dripstone
Add Lua API for mod interop
parent
88085fed50
commit
2a8ff26dd7
17
API.md
17
API.md
|
@ -82,3 +82,20 @@ Dripstone blocks cannot be crafted.
|
||||||
All other sizes can be crafted using dripstone spikes. You can upgrade a
|
All other sizes can be crafted using dripstone spikes. You can upgrade a
|
||||||
dripstone item by surrounding it with (the same type of) dripstone spikes.
|
dripstone item by surrounding it with (the same type of) dripstone spikes.
|
||||||
Huge dripstone cannot be upgraded to a dripstone block, however.
|
Huge dripstone cannot be upgraded to a dripstone block, however.
|
||||||
|
|
||||||
|
## Lua modders
|
||||||
|
|
||||||
|
The following API functions are exposed for you to manipulate this mod with.
|
||||||
|
|
||||||
|
- `noordstar_dripstone.add_lava_source(nodename)` Add a node name that the mod
|
||||||
|
should consider a source of lava droplets above dripstone blocks.
|
||||||
|
- `noordstar_dripstone.add_water_source(nodename)` Add a node name that the mod
|
||||||
|
should consider a source of water droplets above dripstone blocks.
|
||||||
|
- `noordstar_dripstone.add_lava_catcher(oldnodename, newnodename)` Register a
|
||||||
|
node that can catch lava droplets to transform into a new node, such as a
|
||||||
|
cauldron.
|
||||||
|
- `noordstar_dripstone.add_water_catcher(oldnodename, newnodename)` Register a
|
||||||
|
node that can catch water droplets to transform into a new node, such as a
|
||||||
|
cauldron.
|
||||||
|
|
||||||
|
All input values are strings in this API.
|
||||||
|
|
146
init.lua
146
init.lua
|
@ -1,56 +1,4 @@
|
||||||
noordstar_dripstone = {
|
noordstar_dripstone = {}
|
||||||
-- Nodes that the mod should consider as sources to extract water from
|
|
||||||
water_nodes =
|
|
||||||
{ "default:river_water_source"
|
|
||||||
, "default:water_source"
|
|
||||||
, "mcl_core:water_source"
|
|
||||||
, "mclx_core:river_water_source"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Nodes that the mod should consider as sources to extract lava from
|
|
||||||
, lava_nodes =
|
|
||||||
{ "default:lava_source"
|
|
||||||
, "mcl_core:lava_source"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
|
||||||
|
|
||||||
local function load(module_name)
|
|
||||||
return dofile(modpath .. "/lua/" .. module_name .. ".lua")
|
|
||||||
end
|
|
||||||
local function schem(module_name)
|
|
||||||
return dofile(modpath .. "/schematics/" .. module_name .. ".lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create a node box for any given dripstone size.
|
|
||||||
-- Size 8 is a normal block size
|
|
||||||
local function nodebox_of_size(size)
|
|
||||||
if size >= 8 then
|
|
||||||
return nil
|
|
||||||
else
|
|
||||||
return {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{ - size / 16, -0.5, - size / 16, size / 16, 0.5, size / 16 },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function nodebox_type(size)
|
|
||||||
if size >= 8 then
|
|
||||||
return "normal"
|
|
||||||
else
|
|
||||||
return "nodebox"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Sounds
|
|
||||||
local dripstone_sounds = nil
|
|
||||||
if mcl_sounds then
|
|
||||||
dripstone_sounds = mcl_sounds.node_sound_stone_defaults()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Constants
|
-- Constants
|
||||||
local speed_factor = 30
|
local speed_factor = 30
|
||||||
|
@ -93,6 +41,82 @@ local watered_dripstone_small = "noordstar_dripstone:small_watered_dripstone"
|
||||||
local watered_dripstone_tiny = "noordstar_dripstone:tiny_watered_dripstone"
|
local watered_dripstone_tiny = "noordstar_dripstone:tiny_watered_dripstone"
|
||||||
local watered_dripstone_spike = "noordstar_dripstone:watered_dripstone_spike"
|
local watered_dripstone_spike = "noordstar_dripstone:watered_dripstone_spike"
|
||||||
|
|
||||||
|
local internal = {
|
||||||
|
-- Nodes that the mod should consider as sources to extract water from
|
||||||
|
water_nodes =
|
||||||
|
{ "default:river_water_source"
|
||||||
|
, "default:water_source"
|
||||||
|
, "mcl_core:water_source"
|
||||||
|
, "mclx_core:river_water_source"
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Nodes that the mod should consider as sources to extract lava from
|
||||||
|
lava_nodes =
|
||||||
|
{ "default:lava_source"
|
||||||
|
, "mcl_core:lava_source"
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Nodes that can catch a lava droplet instead of letting a spike grow on top
|
||||||
|
lava_cauldrons = {
|
||||||
|
{ from = dry_dripstone_spike, to = molten_dripstone_spike },
|
||||||
|
{ from = "mcl_cauldrons:cauldron", to = "mcl_cauldrons:cauldron_1_lava" },
|
||||||
|
{ from = "mcl_cauldrons:cauldron_1_lava", to = "mcl_cauldrons:cauldron_2_lava" },
|
||||||
|
{ from = "mcl_cauldrons:cauldron_2_lava", to = "mcl_cauldrons:cauldron_3_lava" },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Nodes that can catch a water droplet instead of letting a spike grow on top
|
||||||
|
water_cauldrons = {
|
||||||
|
{ from = dry_dripstone_spike, to = watered_dripstone_spike },
|
||||||
|
{ from = "mcl_cauldrons:cauldron", to = "mcl_cauldrons:cauldron_1" },
|
||||||
|
{ from = "mcl_cauldrons:cauldron_1", to = "mcl_cauldrons:cauldron_2" },
|
||||||
|
{ from = "mcl_cauldrons:cauldron_2", to = "mcl_cauldrons:cauldron_3" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function noordstar_dripstone.add_lava_source(nodename)
|
||||||
|
table.insert(internal.lava_nodes)
|
||||||
|
end
|
||||||
|
function noordstar_dripstone.add_water_source(nodename)
|
||||||
|
table.insert(internal.water_nodes, nodename)
|
||||||
|
end
|
||||||
|
|
||||||
|
function noordstar_dripstone.add_lava_catcher(nodename, newnodename)
|
||||||
|
table.insert(internal.lava_cauldrons, { from = nodename, to = newnodename })
|
||||||
|
end
|
||||||
|
function noordstar_dripstone.add_water_catcher(nodename, newnodename)
|
||||||
|
table.insert(internal.water_cauldrons, { from = nodename, to = newnodename })
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Create a node box for any given dripstone size.
|
||||||
|
-- Size 8 is a normal block size
|
||||||
|
local function nodebox_of_size(size)
|
||||||
|
if size >= 8 then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{ - size / 16, -0.5, - size / 16, size / 16, 0.5, size / 16 },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function nodebox_type(size)
|
||||||
|
if size >= 8 then
|
||||||
|
return "normal"
|
||||||
|
else
|
||||||
|
return "nodebox"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Sounds
|
||||||
|
local dripstone_sounds = nil
|
||||||
|
if mcl_sounds then
|
||||||
|
dripstone_sounds = mcl_sounds.node_sound_stone_defaults()
|
||||||
|
end
|
||||||
|
|
||||||
-- Trickle down config
|
-- Trickle down config
|
||||||
|
|
||||||
local lava_trickle_down = {
|
local lava_trickle_down = {
|
||||||
|
@ -171,20 +195,8 @@ local water_trickle_down_spike = {
|
||||||
{ from = molten_dripstone_spike, to = hardened_dripstone_spike },
|
{ from = molten_dripstone_spike, to = hardened_dripstone_spike },
|
||||||
}
|
}
|
||||||
|
|
||||||
local lava_drop_down = {
|
|
||||||
{ from = dry_dripstone_spike, to = molten_dripstone_spike },
|
|
||||||
{ from = "mcl_cauldrons:cauldron", to = "mcl_cauldrons:cauldron_1_lava" },
|
|
||||||
{ from = "mcl_cauldrons:cauldron_1_lava", to = "mcl_cauldrons:cauldron_2_lava" },
|
|
||||||
{ from = "mcl_cauldrons:cauldron_2_lava", to = "mcl_cauldrons:cauldron_3_lava" },
|
|
||||||
}
|
|
||||||
local water_drop_down = {
|
|
||||||
{ from = dry_dripstone_spike, to = watered_dripstone_spike },
|
|
||||||
{ from = "mcl_cauldrons:cauldron", to = "mcl_cauldrons:cauldron_1" },
|
|
||||||
{ from = "mcl_cauldrons:cauldron_1", to = "mcl_cauldrons:cauldron_2" },
|
|
||||||
{ from = "mcl_cauldrons:cauldron_2", to = "mcl_cauldrons:cauldron_3" },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Tiles for dripstone
|
-- Tiles for dripstone
|
||||||
|
|
||||||
local dry_dripstone_tiles =
|
local dry_dripstone_tiles =
|
||||||
{ "noordstar_dripstone_dripstone_top.png"
|
{ "noordstar_dripstone_dripstone_top.png"
|
||||||
, "noordstar_dripstone_dripstone_top.png"
|
, "noordstar_dripstone_dripstone_top.png"
|
||||||
|
@ -206,6 +218,8 @@ local watered_dripstone_tiles =
|
||||||
, "noordstar_dripstone_watered_dripstone_side.png"
|
, "noordstar_dripstone_watered_dripstone_side.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Register dripstone nodes
|
||||||
|
|
||||||
local function make_dripstone(name, desc, longdesc, tiles, drop, size)
|
local function make_dripstone(name, desc, longdesc, tiles, drop, size)
|
||||||
local sunlight_propagates = nil
|
local sunlight_propagates = nil
|
||||||
if size < 8 then
|
if size < 8 then
|
||||||
|
|
Loading…
Reference in New Issue