master
maikerumine 2017-11-11 11:10:18 -05:00
parent ccc3605281
commit a39ad1ee0e
83 changed files with 2139 additions and 2842 deletions

View File

@ -18,15 +18,14 @@ local modpath = minetest.get_modpath("alias")
alias.modpath = modpath
minetest.register_alias("es:furnace", "es:cfurnace")
minetest.register_alias("es:furnace_active", "es:cfurnace_active")
--dofile(modpath.."/alias.lua")
dofile(modpath.."/moreorerem.lua")
dofile(modpath.."/pathv6rem.lua")
dofile(modpath.."/technodrem.lua")
--dofile(modpath.."/villrem.lua")
--dofile(modpath.."/esorerem.lua")
dofile(modpath.."/esorerem.lua")
dofile(modpath.."/esmobs.lua")
--dofile(modpath.."/moreblocksrem.lua")
--dofile(modpath.."/moresnowrem.lua")

View File

@ -14,9 +14,9 @@
es = {}
minetest.register_alias("moreores:mineral_mithril", "default:stone_with_iron")
minetest.register_alias("moreores:mineral_silver", "default:stone_with_iron")
minetest.register_alias("moreores:mineral_tin", "default:stone_with_iron")
minetest.register_alias("moreores:mineral_mithril", "default:stone_with_tin")
minetest.register_alias("moreores:mineral_silver", "default:stone_with_tin")
minetest.register_alias("moreores:mineral_tin", "default:stone_with_tin")
minetest.register_alias("moreores:mithril_block", "es:aikerumblock")
minetest.register_alias("moreores:silver_block", "es:rubyblock")
minetest.register_alias("moreores:tin_block", "default:steelblock")

View File

@ -12,6 +12,8 @@ anvil = {
}
minetest.register_alias("castle:anvil", "anvil:anvil")
minetest.register_alias("cottages:hammer", "anvil:hammer")
minetest.register_alias("cottages:anvil", "anvil:anvil")
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())

View File

@ -60,7 +60,7 @@ cottages.handmill_min_per_turn = 0;
dofile(minetest.get_modpath("cottages").."/nodes_furniture.lua");
dofile(minetest.get_modpath("cottages").."/nodes_historic.lua");
dofile(minetest.get_modpath("cottages").."/nodes_straw.lua");
dofile(minetest.get_modpath("cottages").."/nodes_anvil.lua");
--dofile(minetest.get_modpath("cottages").."/nodes_anvil.lua");
dofile(minetest.get_modpath("cottages").."/nodes_doorlike.lua");
dofile(minetest.get_modpath("cottages").."/nodes_fences.lua");
dofile(minetest.get_modpath("cottages").."/nodes_roof.lua");

View File

@ -22,6 +22,11 @@ minetest.register_alias("vendor:depositor", "smartshop:shop")
minetest.register_alias("vendorgoldblock:vendor", "smartshop:shop")
minetest.register_alias("vendorgoldblock:depositor", "smartshop:shop")
minetest.register_alias("es:furnace", "es:infiniumblock")
minetest.register_alias("es:furnace_active", "es:infiniumblock")
minetest.register_alias("es:cfurnace", "es:infiniumblock")
minetest.register_alias("es:cfurnace_active", "es:infiniumblock")
minetest.register_alias("esmobs:cobweb", "mobs:cobweb")

532
mods/es/builtin_flowlib.lua Normal file
View File

@ -0,0 +1,532 @@
local function drop_attached_node(p)
local nn = minetest.get_node(p).name
minetest.remove_node(p)
for _, item in pairs(minetest.get_node_drops(nn, "")) do
local pos = {
x = p.x + math.random()/2 - 0.25,
y = p.y + math.random()/2 - 0.25,
z = p.z + math.random()/2 - 0.25,
}
minetest.add_item(pos, item)
end
end
-- Helper function for node actions for liquid flow
local liquid_flow_action = function(pos, group, action)
local check_detach = function(pos, xp, yp, zp)
local p = {x=pos.x+xp, y=pos.y+yp, z=pos.z+zp}
local n = minetest.get_node_or_nil(p)
if not n then
return false
end
local d = minetest.registered_nodes[n.name]
if not d then
return false
end
--[[ Check if we want to perform the liquid action.
* 1: Item must be in liquid group
* 2a: If target node is below liquid, always succeed
* 2b: If target node is horizontal to liquid: succeed if source, otherwise check param2 for horizontal flow direction ]]
local range = d.liquid_range or 8
if (minetest.get_item_group(n.name, group) ~= 0) and
((yp > 0) or
(yp == 0 and ((d.liquidtype == "source") or (n.param2 > (8-range) and n.param2 < 9)))) then
action(pos)
end
end
local posses = {
{ x=-1, y=0, z=0 },
{ x=1, y=0, z=0 },
{ x=0, y=0, z=-1 },
{ x=0, y=0, z=1 },
{ x=0, y=1, z=0 },
}
for p=1,#posses do
check_detach(pos, posses[p].x, posses[p].y, posses[p].z)
end
end
-- Drop some nodes next to flowing water, if it would flow into the node
minetest.register_abm({
label = "Wash away dig_by_water nodes by water flow",
nodenames = {"group:dig_by_water"},
neighbors = {"group:water"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
liquid_flow_action(pos, "water", function(pos)
drop_attached_node(pos)
minetest.dig_node(pos)
end)
end,
})
-- Destroy some nodes next to flowing lava, if it would flow into the node
minetest.register_abm({
label = "Destroy destroy_by_lava_flow nodes by lava flow",
nodenames = {"group:destroy_by_lava_flow"},
neighbors = {"group:lava"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
liquid_flow_action(pos, "lava", function(pos)
minetest.remove_node(pos)
--minetest.sound_play("builtin_item_lava", {pos = pos, gain = 0.25, max_hear_distance = 16})
core.check_for_falling(pos)
end)
end,
})
-- Minetest: builtin/item_entity.lua (27th January 2016)
-- water flow functions by QwertyMine3, edited by TenPlus1
local function to_unit_vector(dir_vector)
local inv_roots = {
[0] = 1,
[1] = 1,
[2] = 0.70710678118655,
[4] = 0.5,
[5] = 0.44721359549996,
[8] = 0.35355339059327
}
local sum = dir_vector.x * dir_vector.x + dir_vector.z * dir_vector.z
return {
x = dir_vector.x * inv_roots[sum],
y = dir_vector.y,
z = dir_vector.z * inv_roots[sum]
}
end
local function is_touching(realpos, nodepos, radius)
return (math.abs(realpos - nodepos) > (0.5 - radius))
end
local function node_ok(pos)
local node = minetest.get_node_or_nil(pos)
if not node then
return minetest.registered_nodes["default:dirt"]
end
if minetest.registered_nodes[node.name] then
return node
end
return minetest.registered_nodes["default:dirt"]
end
local function is_water(pos)
return (minetest.registered_nodes[
node_ok({x = pos.x, y = pos.y, z = pos.z}).name].groups.water)
end
local function is_liquid(pos)
return (minetest.registered_nodes[
node_ok({x = pos.x, y = pos.y, z = pos.z}).name].groups.liquid)
end
local function node_is_liquid(node)
return (minetest.registered_nodes[node.name].groups.liquid)
end
local function quick_flow_logic(node, pos_testing, direction)
if minetest.registered_nodes[node.name].liquidtype == "source" then
local node_testing = node_ok(pos_testing)
local param2_testing = node_testing.param2
if minetest.registered_nodes[node_testing.name].liquidtype ~= "flowing" then
return 0
else
return direction
end
elseif minetest.registered_nodes[node.name].liquidtype == "flowing" then
local node_testing = node_ok(pos_testing)
local param2_testing = node_testing.param2
if minetest.registered_nodes[node_testing.name].liquidtype == "source" then
return -direction
elseif minetest.registered_nodes[node_testing.name].liquidtype == "flowing" then
if param2_testing < node.param2 then
if (node.param2 - param2_testing) > 6 then
return -direction
else
return direction
end
elseif param2_testing > node.param2 then
if (param2_testing - node.param2) > 6 then
return direction
else
return -direction
end
end
end
end
return 0
end
local function quick_flow(pos, node)
local x, z = 0, 0
if not node_is_liquid(node) then
return {x = 0, y = 0, z = 0}
end
x = x + quick_flow_logic(node, {x = pos.x - 1, y = pos.y, z = pos.z},-1)
x = x + quick_flow_logic(node, {x = pos.x + 1, y = pos.y, z = pos.z}, 1)
z = z + quick_flow_logic(node, {x = pos.x, y = pos.y, z = pos.z - 1},-1)
z = z + quick_flow_logic(node, {x = pos.x, y = pos.y, z = pos.z + 1}, 1)
return to_unit_vector({x = x, y = 0, z = z})
end
--if not in water but touching, move centre to touching block
--x has higher precedence than z -- if pos changes with x, it affects z
local function move_centre(pos, realpos, node, radius)
if is_touching(realpos.x, pos.x, radius) then
if is_liquid({x = pos.x - 1, y = pos.y, z = pos.z}) then
pos = {x = pos.x - 1, y = pos.y, z = pos.z}
node = node_ok(pos)
elseif is_liquid({x = pos.x + 1, y = pos.y, z = pos.z}) then
pos = {x = pos.x + 1, y = pos.y, z = pos.z}
node = node_ok(pos)
end
end
if is_touching(realpos.z, pos.z, radius) then
if is_liquid({x = pos.x, y = pos.y, z = pos.z - 1}) then
pos = {x = pos.x, y = pos.y, z = pos.z - 1}
node = node_ok(pos)
elseif is_liquid({x = pos.x, y = pos.y, z = pos.z + 1}) then
pos = {x = pos.x, y = pos.y, z = pos.z + 1}
node = node_ok(pos)
end
end
return pos, node
end
-- END water flow functions
function core.spawn_item(pos, item)
local obj = core.add_entity(pos, "__builtin:item")
-- Don't use obj if it couldn't be added to the map.
if obj then
obj:get_luaentity():set_item(ItemStack(item):to_string())
end
return obj
end
-- if item_entity_ttl is not set, enity will have default life time
-- setting to -1 disables the feature
local time_to_live = tonumber(core.setting_get("item_entity_ttl")) or 900
-- if destroy_item is 1 then dropped items will burn inside lava
local destroy_item = tonumber(core.setting_get("destroy_item")) or 1
-- entity gravity
local gravity = tonumber(minetest.setting_get("movement_gravity")) or 9.81
-- particle effects for when item is destroyed
local function add_effects(pos)
minetest.add_particlespawner({
amount = 1,
time = 0.25,
minpos = pos,
maxpos = pos,
minvel = {x = -1, y = 2, z = -1},
maxvel = {x = 1, y = 5, z = 1},
minacc = {x = -4, y = -4, z = -4},
maxacc = {x = 4, y = 4, z = 4},
minexptime = 1,
maxexptime = 3,
minsize = 1,
maxsize = 4,
texture = "tnt_smoke.png",
})
end
-- check if within map limits (-30911 to 30927)
local function within_limits(pos)
if pos.x > -30913
and pos.x < 30928
and pos.y > -30913
and pos.y < 30928
and pos.z > -30913
and pos.z < 30928 then
return true -- within limits
end
return false -- beyond limits
end
core.register_entity(":__builtin:item", {
initial_properties = {
hp_max = 1,
physical = true,
collide_with_objects = false,
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
visual = "wielditem",
visual_size = {x = 0.4, y = 0.4},
textures = {""},
spritediv = {x = 1, y = 1},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = false,
infotext = "",
},
itemstring = "",
physical_state = true,
age = 0,
set_item = function(self, itemstring)
self.itemstring = itemstring
local stack = ItemStack(itemstring)
local itemname = stack:get_name()
local max_count = stack:get_stack_max()
local count = math.min(stack:get_count(), max_count)
local size = 0.2 + 0.1 * (count / max_count)
if not core.registered_items[itemname] then
itemname = "unknown"
end
self.object:set_properties({
is_visible = true,
visual = "wielditem",
textures = {itemname},
visual_size = {x = size, y = size},
collisionbox = {-size, -size, -size, size, size, size},
automatic_rotate = math.pi * 0.5,
infotext = core.registered_items[itemname].description
})
end,
update_gravity = function(self)
if not self.physical_state then
self.object:setacceleration({x = 0, y = 0, z = 0})
return
end
self.object:setacceleration({x = 0, y = -gravity, z = 0})
end,
get_staticdata = function(self)
return core.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
age = self.age,
dropped_by = self.dropped_by
})
end,
on_activate = function(self, staticdata, dtime_s)
--[[
-- special function to fast remove entities (xanadu only)
if (mobs and mobs.entity and mobs.entity == false)
or not self then
self.object:remove()
return
end
]]
if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = core.deserialize(staticdata)
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
self.age = data.age or 0
self.age = self.age + dtime_s
self.dropped_by = data.dropped_by
end
else
self.itemstring = staticdata
end
self.object:set_armor_groups({immortal = 1})
self.object:setvelocity({x = 0, y = 2, z = 0})
self:update_gravity()
self:set_item(self.itemstring)
end,
try_merge_with = function(self, own_stack, object, entity)
if self.age == entity.age then
-- Can not merge with itself
return false
end
local stack = ItemStack(entity.itemstring)
local name = stack:get_name()
if own_stack:get_name() ~= name or own_stack:get_free_space() == 0 then
-- Can not merge different or full stack
return false
end
local count = own_stack:get_count()
local total_count = stack:get_count() + count
local max_count = stack:get_stack_max()
-- Merge the remote stack into this one
if total_count > max_count then
return false
end
local pos = object:getpos()
pos.y = pos.y + ((total_count - count) / max_count) * 0.15
self:set_item(name .. " " .. total_count)
entity.itemstring = ""
object:remove()
return true
end,
on_step = function(self, dtime)
self.age = self.age + dtime
if time_to_live > 0 and self.age > time_to_live then
self.itemstring = ""
self.object:remove()
return
end
local pos = self.object:getpos()
local node = node_ok({
x = pos.x,
y = pos.y - 0.5,
z = pos.z
})
local def = core.registered_nodes[node.name]
-- destroy item when dropped into lava (if enabled)
if destroy_item > 0 and def.groups.lava then
minetest.sound_play("builtin_item_lava", {
pos = pos,
max_hear_distance = 6,
gain = 0.5
})
add_effects(pos)
self.object:remove()
return
end
-- flowing water pushes item along (by QwertyMine3)
local nod = node_ok({x = pos.x, y = pos.y + 0.5, z = pos.z})
if minetest.registered_nodes[nod.name].liquidtype == "flowing" then
local vec = quick_flow(self.object:getpos(),
node_ok(self.object:getpos()))
if vec then
local v = self.object:getvelocity()
self.object:setvelocity(
{x = vec.x, y = v.y, z = vec.z})
end
return
end
-- Ignore is walkable -> stop until the block loaded
local entity_fall = (def and not def.walkable)
if self.physical_state == entity_fall then
return
end
self.object:setvelocity({x = 0, y = 0, z = 0})
self.physical_state = entity_fall
self.object:set_properties({
physical = entity_fall
})
self:update_gravity()
-- Collect the items around to merge with
local own_stack = ItemStack(self.itemstring)
if own_stack:get_free_space() == 0 then
return
end
local objects = core.get_objects_inside_radius(pos, 0.8)
for k, object in pairs(objects) do
local entity = object:get_luaentity()
if entity and entity.name == "__builtin:item" then
if self:try_merge_with(own_stack, object, entity) then
own_stack = ItemStack(self.itemstring)
if own_stack:get_free_space() == 0 then
return
end
end
end
end
end,
on_punch = function(self, puncher)
local inv = puncher:get_inventory()
if inv and self.itemstring ~= "" then
local left = inv:add_item("main", self.itemstring)
if left and not left:is_empty() then
self:set_item(left:to_string())
return
end
end
self.itemstring = ""
self.object:remove()
end,
})

View File

@ -49,7 +49,7 @@ function crushingfurnace_get_craft_result(input)
return {item = ItemStack(""), time=0}, {items = ItemStack("")}
end
minetest.register_node("es:cfurnace", {
minetest.register_node("es:crushing_furnace", {
description = "Crushing Furnace",
tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png", "crushingfurnace_front.png"},
@ -120,12 +120,12 @@ minetest.register_node("es:cfurnace", {
end,
})
minetest.register_node("es:cfurnace_active", {
minetest.register_node("es:crushing_furnace_active", {
tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png", "crushingfurnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "es:cfurnace",
drop = "es:crushing_furnace",
groups = {cracky=2, not_in_creative_inventory=1,hot=1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
@ -203,7 +203,7 @@ function hacky_swap_node(pos,name)
end
minetest.register_abm({
nodenames = {"es:cfurnace","es:cfurnace_active"},
nodenames = {"es:crushing_furnace","es:crushing_furnace_active"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
@ -253,7 +253,7 @@ minetest.register_abm({
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Crushing Furnace active: "..percent.."%")
hacky_swap_node(pos,"es:cfurnace_active")
hacky_swap_node(pos,"es:crushing_furnace_active")
meta:set_string("formspec", get_furnace_active_formspec(pos, percent))
return
end
@ -273,7 +273,7 @@ minetest.register_abm({
if fuel.time <= 0 then
meta:set_string("infotext", "Crushing Furnace out of fuel")
hacky_swap_node(pos, "es:cfurnace")
hacky_swap_node(pos, "es:crushing_furnace")
meta:set_string("formspec", furnace_inactive_formspec)
return
end
@ -281,7 +281,7 @@ minetest.register_abm({
if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext", "Crushing Furnace is empty")
hacky_swap_node(pos, "es:cfurnace")
hacky_swap_node(pos, "es:crushing_furnace")
meta:set_string("formspec", furnace_inactive_formspec)
end
return
@ -295,7 +295,7 @@ minetest.register_abm({
})
minetest.register_craft({
output = 'es:cfurnace',
output = 'es:crushing_furnace',
recipe = {
{'default:cobble', 'default:steelblock', 'default:cobble'},
{'', 'default:diamondblock', ''},

View File

@ -58,4 +58,32 @@ minetest.after(0,function()
disable_placing_above_ground("es:mud");
-- add here all other sources: toxic water, mud ,....
end)
]]
]]
--Killme
minetest.register_chatcommand("killme", {
description = "Kill yourself to respawn",
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
if minetest.settings:get_bool("enable_damage") then
player:set_hp(0)
return true
else
for _, callback in pairs(core.registered_on_respawnplayers) do
if callback(player) then
return true
end
end
-- There doesn't seem to be a way to get a default spawn pos from the lua API
return false, "No static_spawnpoint defined"
end
else
-- Show error message if used when not logged in, eg: from IRC mod
return false, "You need to be online to be killed!"
end
end
})

160
mods/es/flowlib.lua Normal file
View File

@ -0,0 +1,160 @@
--default = {}
--sum of direction vectors must match an array index
local function to_unit_vector(dir_vector)
--(sum,root)
-- (0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8)
local inv_roots = {[0] = 1, [1] = 1, [2] = 0.70710678118655, [4] = 0.5
, [5] = 0.44721359549996, [8] = 0.35355339059327}
local sum = dir_vector.x*dir_vector.x + dir_vector.z*dir_vector.z
return {x=dir_vector.x*inv_roots[sum],y=dir_vector.y
,z=dir_vector.z*inv_roots[sum]}
end
local is_touching = function(realpos,nodepos,radius)
local boarder = 0.5 - radius
return (math.abs(realpos - nodepos) > (boarder))
end
default.is_touching = is_touching
local is_water = function(pos)
return (minetest.get_item_group(minetest.get_node(
{x=pos.x,y=pos.y,z=pos.z}).name
, "water") ~= 0)
end
default.is_water = is_water
local node_is_water = function(node)
return (minetest.get_item_group(node.name, "water") ~= 0)
end
default.node_is_water = node_is_water
local is_lava = function(pos)
return (minetest.get_item_group(minetest.get_node(
{x=pos.x,y=pos.y,z=pos.z}).name
, "lava") ~= 0)
end
default.is_lava = is_lava
local node_is_lava = function(node)
return (minetest.get_item_group(node.name, "lava") ~= 0)
end
default.node_is_lava = node_is_lava
local is_liquid = function(pos)
return (minetest.get_item_group(minetest.get_node(
{x=pos.x,y=pos.y,z=pos.z}).name
, "liquid") ~= 0)
end
default.is_liquid = is_liquid
local node_is_liquid = function(node)
return (minetest.get_item_group(node.name, "liquid") ~= 0)
end
default.node_is_liquid = node_is_liquid
--This code is more efficient
local function quick_flow_logic(node,pos_testing,direction)
local name = node.name
if minetest.registered_nodes[name].liquidtype == "source" then
local node_testing = minetest.get_node(pos_testing)
local param2_testing = node_testing.param2
if minetest.registered_nodes[node_testing.name].liquidtype
~= "flowing" then
return 0
else
return direction
end
elseif minetest.registered_nodes[name].liquidtype == "flowing" then
local node_testing = minetest.get_node(pos_testing)
local param2_testing = node_testing.param2
if minetest.registered_nodes[node_testing.name].liquidtype
== "source" then
return -direction
elseif minetest.registered_nodes[node_testing.name].liquidtype
== "flowing" then
if param2_testing < node.param2 then
if (node.param2 - param2_testing) > 6 then
return -direction
else
return direction
end
elseif param2_testing > node.param2 then
if (param2_testing - node.param2) > 6 then
return direction
else
return -direction
end
end
end
end
return 0
end
local quick_flow = function(pos,node)
local x = 0
local z = 0
if not node_is_liquid(node) then
return {x=0,y=0,z=0}
end
x = x + quick_flow_logic(node,{x=pos.x-1,y=pos.y,z=pos.z},-1)
x = x + quick_flow_logic(node,{x=pos.x+1,y=pos.y,z=pos.z}, 1)
z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z-1},-1)
z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z+1}, 1)
return to_unit_vector({x=x,y=0,z=z})
end
default.quick_flow = quick_flow
--if not in water but touching, move centre to touching block
--x has higher precedence than z
--if pos changes with x, it affects z
local move_centre = function(pos,realpos,node,radius)
if is_touching(realpos.x,pos.x,radius) then
if is_liquid({x=pos.x-1,y=pos.y,z=pos.z}) then
node = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})
pos = {x=pos.x-1,y=pos.y,z=pos.z}
elseif is_liquid({x=pos.x+1,y=pos.y,z=pos.z}) then
node = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})
pos = {x=pos.x+1,y=pos.y,z=pos.z}
end
end
if is_touching(realpos.z,pos.z,radius) then
if is_liquid({x=pos.x,y=pos.y,z=pos.z-1}) then
node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})
pos = {x=pos.x,y=pos.y,z=pos.z-1}
elseif is_liquid({x=pos.x,y=pos.y,z=pos.z+1}) then
node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})
pos = {x=pos.x,y=pos.y,z=pos.z+1}
end
end
return pos,node
end
default.move_centre = move_centre
--[[
Waterlib
================
Simple flow functions for use in Minetest mods by Qwertymine3
License of source code:
-----------------------
WTFPL
]]

75
mods/es/hudclock.lua Normal file
View File

@ -0,0 +1,75 @@
local player_hud = { };
local timer = 0;
--local positionx = 0.97;
--local positiony = 0.02;
local positionx = 0.30; --horz
local positiony = 0.90; --vert
local last_time = os.time()
local function floormod ( x, y )
return (math.floor(x) % y);
end
local function get_time ( )
local secs = (60*60*24*minetest.get_timeofday());
local s = floormod(secs, 60);
local m = floormod(secs/60, 60);
local h = floormod(secs/3600, 60);
return ("%02d:%02d"):format(h, m);
end
minetest.register_globalstep(function ( dtime )
timer = timer + dtime;
if os.time() >= last_time then
last_time = os.time() + 1
if (timer >= 1.0) then
timer = 0;
for _,p in ipairs(minetest.get_connected_players()) do
local name = p:get_player_name();
local h = p:hud_add({
hud_elem_type = "text";
position = {x=positionx, y=positiony};
text = get_time();
number = 0xFFFFFF;
});
local g = p:hud_add({
hud_elem_type = "image",
position = {x=positionx, y=positiony},
offset = {x=-30, y=0},
scale = {x=1, y=1},
text = "mthudclock.png",
});
if (player_hud[name]) then
p:hud_remove(player_hud[name]);
end
player_hud[name] = h;
--player_hud[name] = g;
end
end
end
end);
-- minetest.register_chatcommand("hcr", {
-- params = "",
-- description = "This should reset your hudclock.",
-- func = function(name, param)
-- local player = minetest.get_player_by_name(name)
-- if not player then
-- return
-- end
-- player:hud_remove(player_hud[name]);
-- player_hud[name] = nil
-- end,
-- })
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
if player_hud[name] ~= nil then
player:hud_remove(player_hud[name]);
player_hud[name] = nil
end
return true
end)

View File

@ -27,9 +27,9 @@ dofile(modpath.."/antigrief.lua")
dofile(modpath.."/armor.lua")
dofile(modpath.."/kill.lua")
dofile(modpath.."/shields.lua")
dofile(modpath.."/shutdown.lua")
--dofile(modpath.."/shutdown.lua")
dofile(modpath.."/spawn.lua")
--dofile(modpath.."/crushingfurnace.lua")
dofile(modpath.."/crushingfurnace.lua")
dofile(modpath.."/tools.lua")
dofile(modpath.."/biome.lua")
--[[
@ -42,6 +42,10 @@ if flowers then
end
dofile(modpath.."/extra.lua")
dofile(modpath.."/item_entity.lua")
dofile(modpath.."/builtin_flowlib.lua")
dofile(modpath.."/flowlib.lua")
dofile(modpath.."/hudclock.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/oregen.lua")
dofile(modpath.."/cavespace.lua")

74
mods/es/item_entity.lua Normal file
View File

@ -0,0 +1,74 @@
-- mods/default/item_entity.lua
local builtin_item = minetest.registered_entities["__builtin:item"]
local item = {
set_item = function(self, itemstring)
builtin_item.set_item(self, itemstring)
local stack = ItemStack(itemstring)
local itemdef = minetest.registered_items[stack:get_name()]
if itemdef and itemdef.groups.flammable ~= 0 then
self.flammable = itemdef.groups.flammable
end
end,
burn_up = function(self)
-- disappear in a smoke puff
self.object:remove()
local p = self.object:getpos()
minetest.sound_play("default_item_smoke", {
pos = p,
max_hear_distance = 8,
})
minetest.add_particlespawner({
amount = 3,
time = 0.1,
minpos = {x = p.x - 0.1, y = p.y + 0.1, z = p.z - 0.1 },
maxpos = {x = p.x + 0.1, y = p.y + 0.2, z = p.z + 0.1 },
minvel = {x = 0, y = 2.5, z = 0},
maxvel = {x = 0, y = 2.5, z = 0},
minacc = {x = -0.15, y = -0.02, z = -0.15},
maxacc = {x = 0.15, y = -0.01, z = 0.15},
minexptime = 4,
maxexptime = 6,
minsize = 5,
maxsize = 5,
collisiondetection = true,
texture = "default_item_smoke.png"
})
end,
on_step = function(self, dtime)
builtin_item.on_step(self, dtime)
if self.flammable then
-- flammable, check for igniters
self.ignite_timer = (self.ignite_timer or 0) + dtime
if self.ignite_timer > 10 then
self.ignite_timer = 0
local node = minetest.get_node_or_nil(self.object:getpos())
if not node then
return
end
-- Immediately burn up flammable items in lava
if minetest.get_item_group(node.name, "lava") > 0 then
self:burn_up()
else
-- otherwise there'll be a chance based on its igniter value
local burn_chance = self.flammable
* minetest.get_item_group(node.name, "igniter")
if burn_chance > 0 and math.random(0, burn_chance) ~= 0 then
self:burn_up()
end
end
end
end
end,
}
-- set defined item as new __builtin:item, with the old one as fallback table
setmetatable(item, builtin_item)
minetest.register_entity(":__builtin:item", item)

View File

@ -4,7 +4,7 @@ local spawn_limit_max = 180; -- how much time must elapse to be able to use spaw
spawn_prison = {}
spawn_prison.pos = {x=0, y=10006, z=0}
spawn_prison.pos = {x=-15, y=4, z=0}
if minetest.setting_get_pos("static_spawnpoint") then
spawn_prison.pos = minetest.setting_get_pos("static_spawnpoint")

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

View File

@ -1,21 +0,0 @@
Lightning mod for minetest
Copyright (C) 2016 - Auke Kok <sofar@foo-projects.org>
"lightning" is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1
of the license, or (at your option) any later version.
Textures: CC-BY-SA-4.0 by sofar
lightning_1.png
lightning_2.png
lightning_3.png
Sounds:
thunder.1.ogg - CC-BY-SA - hantorio - http://www.freesound.org/people/hantorio/sounds/121945/
thunder.2.ogg - CC-BY-SA - juskiddink - http://www.freesound.org/people/juskiddink/sounds/101948/
thunder.3.ogg - CC-BY-SA - IllusiaProductions - http://www.freesound.org/people/IllusiaProductions/sounds/249950/

View File

@ -1,2 +0,0 @@
default?
fire?

View File

@ -1 +0,0 @@
A mod that adds thunder and lightning effects.

View File

@ -1,225 +0,0 @@
--[[
Copyright (C) 2016 - Auke Kok <sofar@foo-projects.org>
"lightning" is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1
of the license, or (at your option) any later version.
--]]
lightning = {}
lightning.interval_low = 17
lightning.interval_high = 503
lightning.range_h = 100
lightning.range_v = 50
lightning.size = 100
-- disable this to stop lightning mod from striking
lightning.auto = true
local rng = PcgRandom(32321123312123)
local ps = {}
local ttl = 1
local revertsky = function()
if ttl == 0 then
return
end
ttl = ttl - 1
if ttl > 0 then
return
end
for key, entry in pairs(ps) do
local sky = entry.sky
entry.p:set_sky(sky.bgcolor, sky.type, sky.textures)
end
ps = {}
end
minetest.register_globalstep(revertsky)
-- select a random strike point, midpoint
local function choose_pos(pos)
if not pos then
local playerlist = minetest.get_connected_players()
local playercount = table.getn(playerlist)
-- nobody on
if playercount == 0 then
return nil, nil
end
local r = rng:next(1, playercount)
local randomplayer = playerlist[r]
pos = randomplayer:getpos()
-- avoid striking underground
if pos.y < -20 then
return nil, nil
end
pos.x = math.floor(pos.x - (lightning.range_h / 2) + rng:next(1, lightning.range_h))
pos.y = pos.y + (lightning.range_v / 2)
pos.z = math.floor(pos.z - (lightning.range_h / 2) + rng:next(1, lightning.range_h))
end
local b, pos2 = minetest.line_of_sight(pos, {x = pos.x, y = pos.y - lightning.range_v, z = pos.z}, 1)
-- nothing but air found
if b then
return nil, nil
end
local n = minetest.get_node({x = pos2.x, y = pos2.y - 1/2, z = pos2.z})
if n.name == "air" or n.name == "ignore" then
return nil, nil
end
return pos, pos2
end
-- lightning strike API
-- * pos: optional, if not given a random pos will be chosen
-- * returns: bool - success if a strike happened
lightning.strike = function(pos)
if lightning.auto then
minetest.after(rng:next(lightning.interval_low, lightning.interval_high), lightning.strike)
end
local pos2
pos, pos2 = choose_pos(pos)
if not pos then
return false
end
minetest.add_particlespawner({
amount = 1,
time = 0.2,
-- make it hit the top of a block exactly with the bottom
minpos = {x = pos2.x, y = pos2.y + (lightning.size / 2) + 1/2, z = pos2.z },
maxpos = {x = pos2.x, y = pos2.y + (lightning.size / 2) + 1/2, z = pos2.z },
minvel = {x = 0, y = 0, z = 0},
maxvel = {x = 0, y = 0, z = 0},
minacc = {x = 0, y = 0, z = 0},
maxacc = {x = 0, y = 0, z = 0},
minexptime = 0.2,
maxexptime = 0.2,
minsize = lightning.size * 10,
maxsize = lightning.size * 10,
collisiondetection = true,
vertical = true,
-- to make it appear hitting the node that will get set on fire, make sure
-- to make the texture lightning bolt hit exactly in the middle of the
-- texture (e.g. 127/128 on a 256x wide texture)
texture = "lightning_lightning_" .. rng:next(1,3) .. ".png",
-- 0.4.15+
glow = 14,
})
minetest.sound_play({ pos = pos, name = "lightning_thunder", gain = 10, max_hear_distance = 500 })
-- damage nearby objects, player or not
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 5)) do
-- nil as param#1 is supposed to work, but core can't handle it.
obj:punch(obj, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy=8}}, nil)
end
local playerlist = minetest.get_connected_players()
for i = 1, #playerlist do
local player = playerlist[i]
local sky = {}
sky.bgcolor, sky.type, sky.textures = player:get_sky()
local name = player:get_player_name()
if ps[name] == nil then
ps[name] = {p = player, sky = sky}
player:set_sky(0xffffff, "plain", {})
end
end
-- trigger revert of skybox
ttl = 5
-- set the air node above it on fire
pos2.y = pos2.y + 1/2
if minetest.get_item_group(minetest.get_node({x = pos2.x, y = pos2.y - 1, z = pos2.z}).name, "liquid") < 1 then
if minetest.get_node(pos2).name == "air" then
-- only 1/4 of the time, something is changed
if rng:next(1,4) > 1 then
return
end
-- very rarely, potentially cause a fire
if fire and rng:next(1,1000) == 1 then
minetest.set_node(pos2, {name = "fire:basic_flame"})
else
minetest.set_node(pos2, {name = "lightning:dying_flame"})
end
end
end
-- perform block modifications
if not default or rng:next(1,10) > 1 then
return
end
pos2.y = pos2.y - 1
local n = minetest.get_node(pos2)
if minetest.get_item_group(n.name, "tree") > 0 then
minetest.set_node(pos2, { name = "default:coalblock"})
elseif minetest.get_item_group(n.name, "sand") > 0 then
minetest.set_node(pos2, { name = "default:glass"})
elseif minetest.get_item_group(n.name, "soil") > 0 then
minetest.set_node(pos2, { name = "default:gravel"})
end
end
-- a special fire node that doesn't burn anything, and automatically disappears
minetest.register_node("lightning:dying_flame", {
description = "Dying Flame",
drawtype = "firelike",
tiles = {
{
name = "fire_basic_flame_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1
},
},
},
inventory_image = "fire_basic_flame.png",
paramtype = "light",
light_source = 14,
walkable = false,
buildable_to = true,
sunlight_propagates = true,
damage_per_second = 4,
groups = {dig_immediate = 3, not_in_creative_inventory=1},
on_timer = function(pos)
minetest.remove_node(pos)
end,
drop = "",
on_construct = function(pos)
minetest.get_node_timer(pos):start(rng:next(20, 40))
if fire and fire.on_flame_add_at then
minetest.after(0.5, fire.on_flame_add_at, pos)
end
end,
})
-- if other mods disable auto lightning during initialization, don't trigger the first lightning.
minetest.after(5, function(dtime)
if lightning.auto then
minetest.after(rng:next(lightning.interval_low,
lightning.interval_high), lightning.strike)
end
end)

View File

@ -1 +0,0 @@
name = lightning

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -24,13 +24,13 @@ mg_villages.VILLAGE_DETECT_RANGE = 400;
-- if set to true, only players which have the mg_villages priv can use the "/visit <village nr>"
-- command which allows teleporting to the village with the given number
mg_villages.REQUIRE_PRIV_FOR_TELEPORT = false;
mg_villages.REQUIRE_PRIV_FOR_TELEPORT = true;
-- if set to true, players cannot modify spawned villages without buying the house from the village first
mg_villages.ENABLE_PROTECTION = true;
mg_villages.ENABLE_PROTECTION = false;
-- the first village - the one the player spawns in - will be of this type
mg_villages.FIRST_VILLAGE_TYPE = 'medieval';
mg_villages.FIRST_VILLAGE_TYPE = 'ruins';
-- the mapgen will disregard mapchunks where min.y > mg_villages.MAX_HEIGHT_TREATED;
-- you can set this value to 64 if you have a slow machine and a mapgen which does not create extreme mountains

View File

@ -24,7 +24,7 @@ local village_type_data_list = {
taoki = { min = 30, max = 70, space_between_buildings=1, mods={}, texture = 'default_brick.png' ,
sapling_divisor = 5, plant_type = 'farming:cotton_8', plant_frequency = 1,
replacement_function = mg_villages.replacements_taoki },
medieval = { min = 25, max = 60, space_between_buildings=2, mods={'cottages'}, texture = 'cottages_darkage_straw.png', -- they often have straw roofs
medieval = { min = 25, max = 60, space_between_buildings=2, mods={'cottages'}, texture = 'darkage_straw.png', -- they often have straw roofs
sapling_divisor = 10, plant_type = 'farming:wheat_8', plant_frequency = 1,
replacement_function = mg_villages.replacements_medieval,
roadsize_list = {2,3,4,5,6},

8
mods/moresnow/README.md Normal file
View File

@ -0,0 +1,8 @@
Experimental snow for stairs, slabs and nodeboxes (to a degree).
Due to the very nature of nodes in Minetest, the snow cannot
handle all situations. Moresnow is made for roofs (which do look
better with a snow cover in winter), slabs, fences etc.
The texture for the winter leaves (the snowy ones) is taken from Moontest,
which can be found at https://github.com/Amaz1/moontest/tree/master/mods/moontest

54
mods/moresnow/init.lua Normal file
View File

@ -0,0 +1,54 @@
moresnow = {}
--------------------------------------------------------------------------------
-- Configuration
--------------------------------------------------------------------------------
-- if set to true, fallen autum leaves will be supported just like snow
-- The txture and idea for them came from LazyJ.
moresnow.enable_autumnleaves = true
-- wool is useful for covering stairs; turns them into benches;
-- change this if you want the wool functionality only for a few nodes (i.e. only white - or none at all)
moresnow.wool_dyes = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue",
"magenta", "orange", "violet", "brown", "pink", "dark_grey", "dark_green"};
-- the snow cannon allows to create snow
moresnow.enable_snow_cannon = false
-- with this set, the snow cannon can *shoot* snowballs - which will fly a long way;
-- on servers, set this to false
moresnow.crazy_mode = false
-- end of configuration
--------------------------------------------------------------------------------
-- defines the on_construct function for falling/placed snow(balls)
dofile(minetest.get_modpath("moresnow")..'/snow_on_construct.lua');
-- which snow node equivals which leaves node?
moresnow.nodetypes = {'snow','autumnleaves'};
-- devines the 8 types of snow covers: general nodebox snow cover, stairs, slabs,
-- outer edge stair, inner edge stair, 3x homedecor shingles/technic cnc shapes
dofile(minetest.get_modpath("moresnow")..'/snow_cover_nodes.lua');
moresnow.build_translation_table();
-- some defines which fascilitate identification of nodes
moresnow.c_ignore = minetest.get_content_id( 'ignore' );
moresnow.c_air = minetest.get_content_id( 'air' );
moresnow.c_snow = minetest.get_content_id( 'default:snow' );
moresnow.c_snow_top = minetest.get_content_id( 'moresnow:snow_top' );
moresnow.c_snow_fence = minetest.get_content_id( 'moresnow:snow_fence_top' );
moresnow.c_snow_stair = minetest.get_content_id( 'moresnow:snow_stair_top' );
moresnow.c_snow_slab = minetest.get_content_id( 'moresnow:snow_slab_top' );
moresnow.c_snow_panel = minetest.get_content_id( 'moresnow:snow_panel_top' );
moresnow.c_snow_micro = minetest.get_content_id( 'moresnow:snow_micro_top' );
moresnow.c_snow_outer_stair = minetest.get_content_id( 'moresnow:snow_outer_stair_top' );
moresnow.c_snow_inner_stair = minetest.get_content_id( 'moresnow:snow_inner_stair_top' );
moresnow.c_snow_ramp_top = minetest.get_content_id( 'moresnow:snow_ramp_top' );
moresnow.c_snow_ramp_outer = minetest.get_content_id( 'moresnow:snow_ramp_outer_top' );
moresnow.c_snow_ramp_inner = minetest.get_content_id( 'moresnow:snow_ramp_inner_top' );
-- takes a look at all defined nodes after startup and stores which shape they are;
-- this is important for finding the right snow cover to put on the shape below
dofile(minetest.get_modpath("moresnow")..'/snow_analyze_shapes.lua');
-- a snow cannon that shoots snow around
if( moresnow.enable_snow_cannon ) then
dofile(minetest.get_modpath("moresnow")..'/snow_cannon.lua');
end

View File

@ -0,0 +1,189 @@
-- find out which nodes are stairs and which are slabs (those are handled diffrently by our snow here);
-- this is necessary in order to determine which shape the snow on top of the node will take
-- (of course this only works for a few shapes and does not even take rotation into consideration)
moresnow.snow_cover = {};
-- homedecor and technic did not settle on common param2 interpretation :-(
moresnow.snow_param2_offset = {};
-- homedecor 3d shingles and technic cnc items are handled here
moresnow.identify_special_slopes = function( new_name, homedecor_prefix, technic_postfix, param2_offset )
-- these nodes are only supported if homedecor and/or technic are installed
local c_new_snow_node = minetest.get_content_id( new_name );
if( not( c_new_snow_node )) then
return;
end
local homedecor_materials = {'terracotta','wood','asphalt'};
local technic_materials = {'dirt','wood','stone','cobble','brick','sandstone','leaves',
'tree','steelblock','bronzeblock','stainless_steel','marble','granite'};
for _,v in ipairs( homedecor_materials ) do
local id = minetest.get_content_id( homedecor_prefix..v );
-- the node has to be registered at this point; thus, the soft-dependency on homedecor and technic
if( id and id ~= moresnow.c_ignore ) then
moresnow.snow_cover[ id ] = c_new_snow_node;
end
end
for _,v in ipairs( technic_materials ) do
local prefix = 'default:';
if( v=='stainless_steel' or v=='marble' or v=='granite' ) then
prefix = 'technic:';
end
local id = minetest.get_content_id( prefix..v..technic_postfix );
-- the node has to be registered at this point; thus, the soft-dependency on homedecor and technic
if( id and id ~= moresnow.c_ignore ) then
moresnow.snow_cover[ id ] = c_new_snow_node;
-- homedecor and technic use diffrent param2 for the same shape
if( param2_offset ) then
moresnow.snow_param2_offset[ id ] = param2_offset;
end
end
end
end
-- identify stairs and slabs (roughly!) by their nodeboxes
moresnow.identify_stairs_and_slabs = function()
moresnow.identify_special_slopes( 'moresnow:snow_ramp_top', 'homedecor:shingle_side_', '_technic_cnc_slope', 0 );
moresnow.identify_special_slopes( 'moresnow:snow_ramp_outer_top', 'homedecor:shingle_outer_corner_', '_technic_cnc_slope_edge', 1 );
moresnow.identify_special_slopes( 'moresnow:snow_ramp_inner_top', 'homedecor:shingle_inner_corner_', '_technic_cnc_slope_inner_edge', 1 );
for n,v in pairs( minetest.registered_nodes ) do
local id = minetest.get_content_id( n );
if( not( id ) or moresnow.snow_cover[ id ] ) then
-- do nothing; the node has been dealt with
elseif( v.drawtype and v.drawtype == 'fencelike' ) then
moresnow.snow_cover[ id ] = moresnow.c_snow_fence;
elseif( n and minetest.registered_nodes[ n ]
and minetest.registered_nodes[ n ].drop
and minetest.registered_nodes[ n ].drop == 'default:snow' ) then
-- no snow on snow
elseif( v and v.drawtype and v.drawtype == 'nodebox' and v.node_box
and v.node_box.type and v.node_box.type=='fixed'
and v.node_box.fixed ) then
local nb = v.node_box.fixed;
-- might be a slab (or something which has a sufficiently similar surface compared to a slab)
if( ( #nb == 1
and math.max( nb[1][2], nb[1][5])==0
and math.abs( nb[1][4] - nb[1][1] ) >= 0.9
and math.abs( nb[1][6] - nb[1][3] ) >= 0.9 )
or ( type( nb[1] )~='table'
and #nb == 6
and math.max( nb[2], nb[5] )==0
and math.abs( nb[4]-nb[1] ) >= 0.9
and math.abs( nb[6]-nb[3] ) >= 0.9 )) then
moresnow.snow_cover[ id ] = moresnow.c_snow_slab;
-- panels (=half slabs)
elseif((#nb == 1
and math.max( nb[1][2], nb[1][5])==0
and math.abs( nb[1][4] - nb[1][1] ) >= 0.9
and math.abs( nb[1][6] - nb[1][3] ) <= 0.5 )
or ( type( nb[1] )~='table'
and #nb == 6
and math.max( nb[2], nb[5] )==0
and math.abs( nb[4]-nb[1] ) >= 0.9
and math.abs( nb[6]-nb[3] ) <= 0.5 )) then
moresnow.snow_cover[ id ] = moresnow.c_snow_panel;
-- micro(blocks)
elseif((#nb == 1
and math.max( nb[1][2], nb[1][5])==0
and math.abs( nb[1][4] - nb[1][1] ) >= 0.5
and math.abs( nb[1][6] - nb[1][3] ) <= 0.5 )
or ( type( nb[1] )~='table'
and #nb == 6
and math.max( nb[2], nb[5] )==0
and math.abs( nb[4]-nb[1] ) >= 0.5
and math.abs( nb[6]-nb[3] ) <= 0.5 )) then
moresnow.snow_cover[ id ] = moresnow.c_snow_micro;
-- might be a stair
elseif( #nb == 2 ) then
local c = { math.min( nb[1][1], nb[1][4] ), math.min( nb[1][2], nb[1][5] ), math.min( nb[1][3], nb[1][4] ),
math.max( nb[1][1], nb[1][4] ), math.max( nb[1][2], nb[1][5] ), math.max( nb[1][3], nb[1][4] ),
math.min( nb[2][1], nb[2][4] ), math.min( nb[2][2], nb[2][5] ), math.min( nb[2][3], nb[2][4] ),
math.max( nb[2][1], nb[2][4] ), math.max( nb[2][2], nb[2][5] ), math.max( nb[2][3], nb[2][4] ) };
if( (( c[ 5]==0 and c[11]==0.5)
or ( c[ 5]==0.5 and c[11]==0 ))
and math.abs( c[ 4]-c[1]) >= 0.9
and math.abs( c[10]-c[7]) >= 0.9 ) then
moresnow.snow_cover[ id ] = moresnow.c_snow_stair;
-- moreblocks _outer:
elseif( nb[1][1]==-0.5 and nb[1][2]==-0.5 and nb[1][3]==-0.5
and nb[1][4]== 0.5 and nb[1][5]== 0 and nb[1][6]== 0.5
and nb[2][1]==-0.5 and nb[2][2]== 0 and nb[2][3]== 0
and nb[2][4]== 0 and nb[2][5]== 0.5 and nb[2][6]== 0.5 ) then
moresnow.snow_cover[ id ] = moresnow.c_snow_outer_stair;
else
moresnow.snow_cover[ id ] = moresnow.c_snow_top;
end
-- moreblocks _inner:
elseif( #nb==3
and nb[1][1]==-0.5 and nb[1][2]==-0.5 and nb[1][3]==-0.5
and nb[1][4]== 0.5 and nb[1][5]== 0 and nb[1][6]== 0.5
and nb[2][1]==-0.5 and nb[2][2]== 0 and nb[2][3]== 0
and nb[2][4]== 0.5 and nb[2][5]== 0.5 and nb[2][6]== 0.5
and nb[3][1]==-0.5 and nb[3][2]== 0 and nb[3][3]==-0.5
and nb[3][4]== 0 and nb[3][5]== 0.5 and nb[3][6]== 0 ) then
moresnow.snow_cover[ id ] = moresnow.c_snow_inner_stair;
else
moresnow.snow_cover[ id ] = moresnow.c_snow_top;
end
-- add snow to the bottom of the node below; it will look acceptable, provided there is a solid node below
elseif( v and v.drawtype
and ( v.drawtype == 'fencelike' or v.drawtype=='plantlike'
or v.drawtype == 'signlike' or v.drawtype=='torchlike' )) then
moresnow.snow_cover[ id ] = moresnow.c_snow_top;
-- nodes where a snow cover would not fit (rails for example would get invisible)
elseif( v and v.drawtype
and ( v.drawtype == 'airlike' or v.drawtype=='liquid'
or v.drawtype == 'raillike' or v.drawtype=='flowingliquid' )) then
moresnow.snow_cover[ id ] = moresnow.c_air;
else
moresnow.snow_cover[ id ] = moresnow.c_snow;
end
end
end
-- search for stairs and slabs after all nodes have been generated
minetest.after( 0, moresnow.identify_stairs_and_slabs );
-- no snow on lava or flowing water
moresnow.snow_cover[ minetest.get_content_id( 'default:lava_source') ] = moresnow.c_air;
moresnow.snow_cover[ minetest.get_content_id( 'default:lava_flowing') ] = moresnow.c_air;
moresnow.snow_cover[ minetest.get_content_id( 'default:water_flowing') ] = moresnow.c_air;
moresnow.snow_cover[ minetest.get_content_id( 'default:river_water_flowing')] = moresnow.c_air;

View File

@ -0,0 +1,398 @@
--[[
moresnow.throw_snowball = function( pos, dir, player )
local snowball_GRAVITY=9
local snowball_VELOCITY=19
if( player ) then
pos = player:getpos();
dir = player:get_look_dir();
pos.y = pos.y + 1.5;
elseif( not( dir )) then
dir = {};
dir.x = math.random( 1, 20000 )*0.0001 - 1.0001;
dir.z = math.random( 1, 20000 )*0.0001 - 1.0001;
dir.y = math.random( 2, 10000 )*0.0001 - 0.0001; -- always upwards
pos.y = pos.y + 1.0;
snowball_VELOCITY = 31;
end
local obj = core.add_entity( pos, "__builtin:falling_node")
obj:get_luaentity():set_node( { name = 'default:snow'});
obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
end
]]
-- let a row of snow fall
moresnow.snow_at_one_place = function( pos )
local n = minetest.get_node( pos );
if( not(n) or not( n.name ) or n.name=='air' ) then
spawn_falling_node( pos, {name="default:snow"})
end
end
moresnow.snow_cannon_stop = function( pos )
local node = minetest.get_node( pos );
minetest.swap_node( pos, { name = 'moresnow:snow_cannon', param2 = node.param2 });
moresnow.snow_cannon_update_formspec( minetest.get_meta( pos ), false );
local meta = minetest.get_meta( pos );
meta:set_string("infotext", "Snow cannon (inactive)");
end
moresnow.snow_cannon_fire = function( pos )
local meta = minetest.get_meta( pos );
-- if there is a node above the machine, abort (no way of firing)
local node = minetest.get_node( {x=pos.x, y=pos.y+1, z=pos.z} );
if( not( node) or not( node.name ) or (node.name ~= 'air' and node.name ~= 'moresnow:snow_top')) then
-- deactivate the machine by turning back to the inactive state
meta:set_int( 'mode', -1 );
moresnow.snow_cannon_stop( pos );
return;
end
local water = meta:get_int( 'water' );
if( not( water ) or water<1 ) then
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory();
if( inv:contains_item( 'buckets', 'bucket:bucket_water')) then
inv:remove_item( 'buckets', 'bucket:bucket_water' );
-- return an empty button
inv:add_item( 'buckets', 'bucket:bucket_empty' );
elseif( inv:contains_item( 'buckets', 'default:ice' )) then
inv:remove_item( 'buckets', 'default:ice' );
else
meta:set_int( 'mode', -2 );
moresnow.snow_cannon_stop( pos );
return;
end
water = 9;
end
-- consume one water
meta:set_int( 'water', water-1 );
local mode = meta:get_int( 'mode' );
if( not( mode )) then
mode = 1;
end
-- ordered mode - make sure every node in the vicinity gets one snow (9x9 area)
if( mode==1 ) then
local i = meta:get_int( 'pcount' );
-- each node in the vicinity has been covered with snow
if( not( i ) or i >= 81 or i<0) then
meta:set_int( 'pcount', 0 );
moresnow.snow_cannon_stop( pos );
return;
end
local p = {x = pos.x-4+( i%9 ), y=pos.y+20, z=pos.z-4+(math.floor(i/9))};
moresnow.snow_at_one_place( p );
meta:set_int( 'pcount', i+1 );
-- randomly drop snow on nodes in the vicnity (9x9 area)
elseif( mode==2 ) then
local k = math.random( 1, 9 );
local j = math.random( 1, 9 );
local p = {x = pos.x-5+k, y=pos.y+20, z=pos.z-5+j};
moresnow.snow_at_one_place( p );
-- really shoot the snowballs; drawback: this may cover a HUGE area
elseif( mode==3 ) then
moresnow.throw_snowball( pos, nil, nil );
end
end
moresnow.snow_cannon_update_formspec = function( meta, is_active )
local mode = meta:get_string( 'mode' );
local program = 'none';
mode = meta:get_int( 'mode' );
if( not( mode ) or mode<-2 or mode>3) then
mode = 0;
meta:set_int( 'mode', mode );
end
if( mode==0 ) then
program = 'paused';
elseif( mode==-1 ) then
program = 'Error: Top covered.';
elseif( mode==-2 ) then
program = 'Error: Out of water!';
elseif( mode==1 ) then
program = 'ordered mode';
elseif( mode==2 ) then
program = 'random mode';
elseif( mode==3 ) then
program = 'crazy shooting';
else
program = 'unknown';
end
local hotbar_bg = '';
if( default.get_hotbar_bg ) then
hotbar_bg = default.get_hotbar_bg(0,4.25)
end
local start = 'start';
if( is_active ) then
start = 'stop';
elseif( mode<0 ) then
start = 'resume';
else
start = 'start';
end
local button_crazy = '';
if( moresnow.crazy_mode ) then
button_crazy = "button_exit[6.5,1.5;2,0.5;crazy;crazy]";
end
meta:set_string( 'formspec',
"size[10.5,8]"..
( default.gui_bg or '')..
( default.gui_bg_img or '')..
( default.gui_slots or '')..
"label[0,0;Current program:]"..
"label[2,0;"..program.."]"..
"label[4,0;Start/resume Program:]"..
"button_exit[6.5,0;2,0.5;"..start..";"..start.."]"..
"button_exit[6.5,0.5;2,0.5;ordered;ordered]"..
"button_exit[6.5,1.0;2,0.5;random;random]"..
button_crazy..
"label[0,2;Water reservoir:]"..
"label[2,2;Fill up with water buckets or ice blocks.]"..
"list[current_name;buckets;0,2.5;10,1;]"..
"list[current_player;main;1,4.25;8,1;]"..
"list[current_player;main;1,5.5;8,3;8]"..
hotbar_bg );
end
moresnow.snow_cannon_on_receive_fields = function(pos, formname, fields, sender)
local node = minetest.get_node( pos );
local meta = minetest.get_meta( pos );
if( not( fields )) then
return;
end
local mode = meta:get_int( 'mode' );
if( fields.ordered ) then
mode = 1;
meta:set_int('pcount', 0 );
elseif( fields.random ) then
mode = 2;
elseif( fields.crazy ) then
mode = 3;
elseif( fields.stop ) then
moresnow.snow_cannon_stop( pos );
return;
elseif( not(fields.start) and not(fields.resume )) then
return;
end
meta:set_int('mode', mode);
if( node.name == 'moresnow:snow_cannon' ) then
minetest.swap_node( pos, { name = 'moresnow:snow_cannon_active', param2 = node.param2 });
meta:set_string("infotext", "Snow cannon (active)");
end
moresnow.snow_cannon_update_formspec( meta, true );
end
moresnow.snow_cannon_on_construct = function( pos )
local meta = minetest.get_meta(pos);
meta:set_string("infotext", "Snow cannon (inactive)");
meta:set_int( "mode", 0 );
local inv = meta:get_inventory();
inv:set_size("buckets", 10);
moresnow.snow_cannon_update_formspec( meta );
end
moresnow.snow_cannon_can_dig = function( pos, player )
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory();
if not( inv:is_empty("buckets")) then
return false;
end
return true;
end
moresnow.snow_cannon_allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0;
end
if( stack:get_name() ~= 'bucket:bucket_water' and stack:get_name() ~= 'default:ice' ) then
return 0;
end
return stack:get_count();
end
moresnow.snow_cannon_allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0;
end
moresnow.snow_cannon_allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0;
end
return stack:get_count();
end
local moresnow_snow_cannon_nodebox_inactive = {
{ -0.3, 0.5, -0.2, 0.3, 0.6, 0.2},
{ -0.3, 0.1, -0.2, -0.2, 0.5, 0.2},
{ 0.2, 0.1, -0.2, 0.3, 0.5, 0.2},
{ -0.3, 0, -0.2, 0.3, 0.1, 0.2},
{ -0.35,-0.05, -0.4, 0.35, 0.65,-0.2 }};
local moresnow_snow_cannon_nodebox_active = {
-- walls of the actual cannon (which is pointing upward)
{ -0.3, 0.1, -0.3, -0.2, 0.5, 0.3},
{ 0.2, 0.1, -0.3, 0.3, 0.5, 0.3},
{ -0.2, 0.1, -0.3, 0.2, 0.5, -0.2},
{ -0.2, 0.1, 0.2, 0.2, 0.5, 0.3},
-- fan case
{ -0.35, -0.1, -0.35, 0.35, 0.1, 0.35}, };
local moresnow_snow_cannon_nodebox_common = {
-- horizontal supporting (allowing the cannon to rotate)
{ -0.4, 0.26, -0.01, -0.3, 0.28, 0.01},
{ 0.3, 0.26, -0.01, 0.4, 0.28, 0.01},
-- vertical supporting
{ -0.45, -0.5, -0.05, -0.4, 0.3, 0.05},
{ 0.4, -0.5, -0.05, 0.45, 0.3, 0.05},
-- connection vertical supporting - case
{ -0.4, -0.4, -0.05, -0.15,-0.3, 0.05},
{ 0.15, -0.4, -0.05, 0.4, -0.3, 0.05},
-- horizontal supporting - connection to the legs
{ -0.45, -0.25, 0.05, -0.4, -0.15, 0.4},
{ 0.4, -0.25, 0.05, 0.45,-0.15, 0.4},
-- front legs
{ -0.45, -0.5, 0.4, -0.4, -0.15, 0.5},
{ 0.4, -0.5, 0.4, 0.45,-0.15, 0.5},
--case
{ -0.15, -0.5, -0.5, 0.15, -0.3, 0.15},
-- motor
{ -0.20, -0.4, -0.4, 0.20, -0.14, -0.1},
-- connection between cannon and case
{ -0.1, -0.3, -0.1, 0.1, 0.1, 0.1},
};
for _,v in ipairs( moresnow_snow_cannon_nodebox_common ) do
table.insert( moresnow_snow_cannon_nodebox_inactive, v );
end
minetest.register_node("moresnow:snow_cannon", {
description = "snow cannon (inactive)",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = moresnow_snow_cannon_nodebox_inactive,
},
selection_box = {
type = "regular",
},
tiles = {"default_mese_block.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
on_construct = moresnow.snow_cannon_on_construct,
can_dig = moresnow.snow_cannon_can_dig,
allow_metadata_inventory_put = moresnow.snow_cannon_allow_metadata_inventory_put,
allow_metadata_inventory_move = moresnow.snow_cannon_allow_metadata_inventory_move,
allow_metadata_inventory_take = moresnow.snow_cannon_allow_metadata_inventory_take,
on_receive_fields = moresnow.snow_cannon_on_receive_fields,
})
for _,v in ipairs( moresnow_snow_cannon_nodebox_common ) do
table.insert( moresnow_snow_cannon_nodebox_active, v );
end
minetest.register_node("moresnow:snow_cannon_active", {
description = "snow cannon (active)",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = moresnow_snow_cannon_nodebox_active,
},
selection_box = {
type = "regular",
},
tiles = {"default_mese_block.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
on_construct = moresnow.snow_cannon_on_construct,
can_dig = moresnow.snow_cannon_can_dig,
allow_metadata_inventory_put = moresnow.snow_cannon_allow_metadata_inventory_put,
allow_metadata_inventory_move = moresnow.snow_cannon_allow_metadata_inventory_move,
allow_metadata_inventory_take = moresnow.snow_cannon_allow_metadata_inventory_take,
on_receive_fields = moresnow.snow_cannon_on_receive_fields,
})
minetest.register_abm({
nodenames = {"moresnow:snow_cannon_active"},
interval = 1,
chance = 1,
action = function(pos, node)
moresnow.snow_cannon_fire( pos );
end
})
minetest.register_craft({
output = 'moresnow:snow_cannon',
recipe = {
{ 'default:steel_ingot', '', 'default:steel_ingot' },
{ 'default:steel_ingot', 'default:mese', 'default:steel_ingot' },
{ 'default:copper_ingot','default:steelblock', 'default:copper_ingot' },
}
})
-- the snow mod does this already
if( not( minetest.get_modpath( 'snow' ))) then
minetest.override_item("default:snow", {
on_use = function(itemstack, user, pointed_thing)
moresnow.throw_snowball( nil, nil, user );
itemstack:take_item();
return itemstack;
end
})
end

View File

@ -0,0 +1,337 @@
-- the general node definition for all these snow tops (only name and nodebox vary)
moresnow.register_snow_top = function( node_name, fixed_nodebox, wool_nodebox )
minetest.register_node( 'moresnow:snow_'..node_name, {
description = "Snow",
tiles = {"default_snow.png"},
inventory_image = "default_snowball.png",
wield_image = "default_snowball.png",
is_ground_content = true,
paramtype = "light",
paramtype2 = "facedir",
buildable_to = true,
drawtype = "nodebox",
freezemelt = "default:water_flowing",
node_box = {
-- leveled would not work well in this situation
type = "fixed",
fixed = fixed_nodebox,
},
drop = "default:snow",
groups = {crumbly=3,falling_node=1, float=1, melt=1, not_in_creative_inventory=1},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_snow_footstep", gain=0.25},
dug = {name="default_snow_footstep", gain=0.75},
}),
on_construct = function( pos )
return moresnow.on_construct_snow( pos, 'moresnow:snow_'..node_name );
end,
})
if( moresnow.enable_autumnleaves ) then
minetest.register_node( 'moresnow:autumnleaves_'..node_name, {
description = "fallen leaves",
tiles = {"moresnow_autumnleaves.png"},
inventory_image = "moresnow_autumnleaves.png",
wield_image = "moresnow_autumnleaves.png",
is_ground_content = true,
paramtype = "light",
paramtype2 = "facedir",
buildable_to = true,
drawtype = "nodebox",
node_box = {
-- leveled would not work well in this situation
type = "fixed",
fixed = fixed_nodebox,
},
drop = "moresnow:autumnleaves",
groups = {falling_node=1, float=1, not_in_creative_inventory=1, snappy=3, flammable=2, leaves=1, not_in_creative_inventory=1},
sounds = default.node_sound_leaves_defaults(),
on_construct = function( pos )
return moresnow.on_construct_leaves( pos, 'moresnow:autumnleaves_'..node_name );
end,
})
end
if( wool_nodebox and moresnow.wool_dyes and minetest.get_modpath( 'wool' )) then
for _,v in ipairs( moresnow.wool_dyes ) do
minetest.register_node( "moresnow:wool_"..v.."_"..node_name, {
description = "layers of wool ("..v..")",
tiles = {"wool_"..v..".png"},
-- inventory_image = "moresnow_autumnleaves.png",
-- wield_image = "moresnow_autumnleaves.png",
is_ground_content = true,
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = wool_nodebox,
},
drop = "moresnow:wool_"..v,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3,wool=1, float=1, not_in_creative_inventory=1},
sounds = default.node_sound_defaults(),
on_construct = function( pos )
return moresnow.on_construct_wool( pos, "moresnow:wool_"..v.."_"..node_name, v );
end,
});
end
end
end
-- define the leaves
if( moresnow.enable_autumnleaves ) then
minetest.register_node( "moresnow:autumnleaves", {
description = "fallen leaves",
tiles = {"moresnow_autumnleaves.png"},
inventory_image = "moresnow_autumnleaves.png",
wield_image = "moresnow_autumnleaves.png",
is_ground_content = true,
paramtype = "light",
-- drawtype = "allfaces_optional",
waving = 1,
buildable_to = true,
leveled = 7, -- can pile up as well
drawtype = "nodebox",
node_box = {
type = "leveled",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
},
},
groups = {falling_node=1, float=1, snappy=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(),
on_construct = function( pos )
return moresnow.on_construct_leaves( pos, 'moresnow:autumnleaves' );
end,
})
-- craft one leaves block into 9 layers
minetest.register_craft({
output = 'moresnow:autumnleaves 9',
recipe = { {'default:leaves'}
}});
-- there is no inverse craft receipe for them as leaves are not particulary rare
end
if( moresnow.wool_dyes and minetest.get_modpath( 'wool' )) then
for _,v in ipairs( moresnow.wool_dyes ) do
table.insert( moresnow.nodetypes, 'wool_'..v );
minetest.register_node( "moresnow:wool_"..v, {
description = "layers of wool ("..v..")",
tiles = {"wool_"..v..".png"},
is_ground_content = true,
paramtype = "light",
leveled = 7, -- can pile up as well
drawtype = "nodebox",
node_box = {
type = "leveled",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3,wool=1, float=1},
sounds = default.node_sound_defaults(),
on_construct = function( pos )
return moresnow.on_construct_wool( pos, 'moresnow:wool_'..v, v );
end,
});
-- craft one wool block into 9 layers
minetest.register_craft({
output = 'moresnow:wool_'..v..' 9',
recipe = { {'wool:'..v}
}});
-- craft the wool layers back to a full wool block
minetest.register_craft({
output = 'wool:'..v,
recipe = {
{ 'moresnow:wool_'..v, 'moresnow:wool_'..v, 'moresnow:wool_'..v },
{ 'moresnow:wool_'..v, 'moresnow:wool_'..v, 'moresnow:wool_'..v },
{ 'moresnow:wool_'..v, 'moresnow:wool_'..v, 'moresnow:wool_'..v },
}});
end
end
-- now that on_construct has been defined, we can start creating the actual nodes
minetest.registered_nodes[ 'default:snow' ].on_construct = function( pos )
return moresnow.on_construct_snow( pos, 'default:snow' );
end
-- the nodebox for this snow node lies one node DEEPER than the node the snow is in;
-- thus, nodebox-like nodes covered by snow may look less strange
moresnow.register_snow_top( "top", {{-0.5, -1.5, -0.5, 0.5, -1.5+2/16, 0.5}},
{{-0.5, -1.5, -0.5, 0.5, -1.5+2/16, 0.5}} ); -- same for wool
moresnow.register_snow_top( "fence_top", {{-0.5, -1.5, -0.5, 0.5, -1.5+2/16, 0.5},
{-0.12, -0.5, -0.12, 0.12, -0.5+2/16, 0.12}}, -- on top of the fence post
{{-0.5, -1.5, -0.5, 0.5, -1.5+2/16, 0.5}} ); -- same for wool
moresnow.register_snow_top( "stair_top", {
{-0.5, -1.0, -0.5, 0.5, -1.0+2/16, 0},
{-0.5, -0.5, 0, 0.5, -0.5+2/16, 0.5},
{-0.5, -1.0+2/16, 0-1/32, 0.5, -0.5, 0 },
{-0.5, -1.5, -0.5-1/32, 0.5, -1.0, -0.5},
},{ -- the wool version does not have the wool covering the legs
{-0.5, -1.0, -0.5, 0.5, -1.0+2/16, 0},
{-0.5, -0.5, 0, 0.5, -0.5+2/16, 0.5},
{-0.5, -1.0+2/16, 0-1/32, 0.5, -0.5, 0 },
});
moresnow.register_snow_top( "slab_top", { {-0.5, -1.0, -0.5, 0.5, -1.0+2/16, 0.5}},
{ {-0.5, -1.0, -0.5, 0.5, -1.0+2/16, 0.5}}); -- same for wool
-- these shapes exist in moreblocks only
if( minetest.get_modpath( 'moreblocks' )) then
moresnow.register_snow_top( "panel_top", {
{-0.5, -1.5, -0.5, 0.5, -1.5+2/16, 0},
{-0.5, -1.0, 0, 0.5, -1.0+2/16, 0.5},
{-0.5, -1.5+2/16, 0-1/32, 0.5, -1.0, 0 },
},{ -- the wool version does not have the wool covering the legs
{-0.5, -1.0, 0, 0.5, -1.0+2/16, 0.5},
});
moresnow.register_snow_top( "micro_top", {
{-0.5, -1.5, -0.5, 0, -1.5+2/16, 0 },
{-0.5, -1.0, 0, 0, -1.0+2/16, 0.5},
{ 0, -1.5, -0.5, 0.5, -1.5+2/16, 0.5},
{-0.5, -1.5+2/16, 0-1/32, 0, -1.0, 0 },
{0, -1.5+2/16, 0, 0+1/32, -1.0, 0.5},
},{ -- the wool version does not have the wool covering the legs
{-0.5, -1.0, 0, 0, -1.0+2/16, 0.5},
});
moresnow.register_snow_top( "outer_stair_top", {
{-0.5, -1.0, -0.5, 0, -1.0+2/16, 0 },
{-0.5, -0.5, 0, 0, -0.5+2/16, 0.5},
{ 0, -1.0, -0.5, 0.5, -1.0+2/16, 0.5},
{-0.5, -1.0+2/16, 0-1/32, 0, -0.5, 0 },
{-0.5, -1.5, -0.5-1/32, 0.5, -1.0, -0.5},
{0, -1.0+2/16, 0, 0+1/32, -0.5, 0.5},
{0.5, -1.5, -0.5, 0.5+1/32, -1.0, 0.5},
}, { -- the wool version does not cover the lower legs
{-0.5, -1.0, -0.5, 0, -1.0+2/16, 0 },
{-0.5, -0.5, 0, 0, -0.5+2/16, 0.5},
{ 0, -1.0, -0.5, 0.5, -1.0+2/16, 0.5},
{-0.5, -1.0+2/16, 0-1/32, 0, -0.5, 0 },
{0, -1.0+2/16, 0, 0+1/32, -0.5, 0.5},
});
moresnow.register_snow_top( "inner_stair_top", {
{ 0, -1.0, -0.5, 0.5, -1.0+2/16, 0 },
{ 0, -0.5, 0, 0.5, -0.5+2/16, 0.5},
{-0.5, -0.5, -0.5, 0, -0.5+2/16, 0.5},
{ 0, -1.0+2/16, 0-1/32, 0.5, -0.5, 0 },
{ 0, -1.0+2/16, -0.5, 0+1/32, -0.5, 0},
}, { -- the wool version does not cover the lower legs
{ 0, -1.0, -0.5, 0.5, -1.0+2/16, 0 },
{ 0, -0.5, 0, 0.5, -0.5+2/16, 0.5},
{-0.5, -0.5, -0.5, 0, -0.5+2/16, 0.5},
{ 0, -1.0+2/16, 0-1/32, 0.5, -0.5, 0 },
{ 0, -1.0+2/16, -0.5, 0+1/32, -0.5, 0},
});
end
moresnow.register_shape = function( shape, new_name )
local detail = 16;
local slopeboxedge = {};
for i = 0, detail-1 do
if( shape==1 ) then -- slope; normal roof shingles
slopeboxedge[i+1]={ -0.5, (i/detail)-1.5+(1.25/detail), (i/detail)-0.5,
0.5, (i/detail)-1.5+(1.25/detail)+(1/detail), (i/detail)-0.5+(1/detail)};
elseif( shape==2 ) then -- outer corner
slopeboxedge[i+1]={ -0.5, (i/detail)-1.5+(1.25/detail), (i/detail)-0.5,
0.5-(i/detail), (i/detail)-1.5+(1.25/detail)+(1/detail), (i/detail)-0.5+(1/detail)};
slopeboxedge[i+detail*1]={ 0.5-(i/detail), (i/detail)-1.5+(1.25/detail)-(1/detail), 0.5,
0.5-(i/detail)+(1/detail), (i/detail)-1.5+(1.25/detail), -0.5+(i/detail) };
elseif( shape==3 ) then -- inner corner
local v = detail-i;
slopeboxedge[i+1]={ (i/detail)-0.5, (v/detail)-1.5+(1.25/detail)-(1/detail), -0.5+(1/detail-(1/detail)),
(i/detail)-0.5+(1/detail), (v/detail)-1.5+(1.25/detail), 0.5-(i/detail) };
slopeboxedge[i+detail*1]={ 0.5, (v/detail)-1.5+(1.25/detail), 0.5-(i/detail),
-0.5+(i/detail), (v/detail)-1.5+(1.25/detail)+(1/detail), 0.5-(i/detail)+(1/detail) };
end
end
moresnow.register_snow_top( new_name, slopeboxedge, nil ); -- no wool version for these
end
-- only add these if either technic (with its cnc machine) or homedecor (with shingles) are installed
if( minetest.get_modpath( 'homedecor' )
or minetest.get_modpath( 'technic' )) then
moresnow.register_shape( 1, 'ramp_top' );
moresnow.register_shape( 2, 'ramp_outer_top');
moresnow.register_shape( 3, 'ramp_inner_top');
end
minetest.register_node( 'moresnow:autumnleaves_tree', {
description = "autumn leaves",
tiles = {"moresnow_autumnleaves.png"},
drawtype = "allfaces_optional",
waving = 1,
visual_scale = 1.3,
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node( 'moresnow:winterleaves_tree', {
description = "winter leaves",
tiles = {"moresnow_winterleaves.png"},
drawtype = "allfaces_optional",
waving = 1,
visual_scale = 1.3,
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("moresnow:snow_soil", {
description = "Snow on soil",
tiles = {"default_snow.png^farming_soil_wet.png"},
is_ground_content = true,
paramtype = "light",
buildable_to = true,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
},
},
groups = {crumbly=3,falling_node=1},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_snow_footstep", gain=0.25},
dug = {name="default_snow_footstep", gain=0.75},
}),
on_construct = function(pos)
pos.y = pos.y - 1
if minetest.get_node(pos).name == "default:dirt_with_grass" then
minetest.set_node(pos, {name="default:dirt_with_snow"})
end
end,
})

View File

@ -0,0 +1,250 @@
moresnow.translation_table = {}
moresnow.build_translation_table = function()
local shapes = {'top', 'fence_top', 'stair_top', 'slab_top',
'panel_top', 'micro_top', 'outer_stair_top', 'inner_stair_top',
'ramp_top', 'ramp_outer_top', 'ramp_inner_top' };
for _,t in ipairs(moresnow.nodetypes) do
moresnow.translation_table[ t ] = {};
for _,v in ipairs( shapes ) do
local id1 = minetest.get_content_id( 'moresnow:snow_'..v );
local id2 = minetest.get_content_id( 'moresnow:'..t..'_'..v );
if( id1 ) then
moresnow.translation_table[ t ][ id1 ] = id2;
end
end
local id1 = minetest.get_content_id( 'default:snow' );
local id2 = minetest.get_content_id( 'moresnow:'..t );
if( id1 ) then
moresnow.translation_table[ t ][ id1 ] = id2;
end
end
end
moresnow.on_construct_snow = function( pos, falling_node_name )
if( not( falling_node_name )) then
falling_node_name = 'default:snow';
end
local res = moresnow.on_construct( pos, falling_node_name, 'default:snow', 'snow' );
if( res ) then
minetest.swap_node( pos, res );
end
end
moresnow.on_construct_leaves = function( pos, falling_node_name )
if( not( falling_node_name )) then
falling_node_name = 'moresnow:autumnleaves';
end
local res = moresnow.on_construct( pos, falling_node_name, 'moresnow:autumnleaves', 'autumnleaves' );
if( res ) then
minetest.swap_node( pos, res );
end
end
moresnow.on_construct_wool = function( pos, falling_node_name, color )
if( not( falling_node_name )) then
falling_node_name = 'moresnow:wool_'..color;
end
local res = moresnow.on_construct( pos, falling_node_name, 'moresnow:wool_'..color, 'wool_'..color );
if( res ) then
minetest.swap_node( pos, res );
end
end
-- this function works with content ids because we want it to call for falling
-- snow nodes AND from mapgen (where content ids are at hand)
moresnow.suggest_snow_type = function( node_content_id, p2 )
local suggested = moresnow.snow_cover[ node_content_id ];
-- if it is some solid node, keep the snow cover
if( node_content_id == moresnow.c_snow or not( suggested ) or suggested == moresnow.c_ignore or suggested == moresnow.c_air) then
return { new_id = moresnow.c_snow, param2 = 0 };
end
if( not( p2 )) then
p2 = 0;
end
-- homedecor and technic have diffrent ideas about param2...
local p2o = moresnow.snow_param2_offset[ node_content_id ];
if( p2o ) then
p2 = (p2 + p2o ) % 4;
end
-- if this is a stair or a roof node from homedecor or technics cnc machine;
-- those nodes are all comparable regarding rotation
if( suggested == moresnow.c_snow_stair
or suggested == moresnow.c_snow_ramp_top ) then
if( p2==5 or p2==7 or p2==9 or p2==11 or p2==12 or p2==14 or p2==16 or p2==18 ) then
suggested = moresnow.c_snow_top;
-- stair turned upside down
elseif( p2==6 or p2==8 or p2==15 or p2==17 or p2==20 or p2==21 or p2==22 or p2==23) then
suggested = moresnow.c_snow;
-- all these transform into stairs; however, adding the offset (our snow node lies lower than a normal node) would cause chaos
elseif( p2 ==19) then
p2 = 1;
elseif( p2 ==4 ) then
p2 = 2;
elseif( p2 ==13) then
p2 = 3;
elseif( p2 ==10) then
p2 = 0;
-- else it really is a stiar
end
elseif( suggested == moresnow.c_snow_slab ) then
-- vertical slab; tread as a nodebox
if( p2 >= 4 and p2 <= 19 ) then
suggested = moresnow.c_snow_top;
-- slab turned upside down
elseif( p2 >= 20 and p2 <= 24 ) then
suggested = moresnow.c_snow;
-- else it's a slab
end
elseif( suggested == moresnow.c_snow_panel ) then
-- vertical panel (mostly); can't be handled well; therefore, treat as a nodebox
if( p2 >= 4 and p2 <= 24 ) then
suggested = moresnow.c_snow_top;
end
elseif( suggested == moresnow.c_snow_micro ) then
-- microblocks in diffrent positions from the normal ones are too difficult
if( p2 >= 4 and p2 <= 24 ) then
suggested = moresnow.c_snow_top;
end
elseif( suggested == moresnow.c_snow_ramp_outer ) then
-- treat like a nodebox
if( p2>=4 and p2 <= 19 ) then
suggested = moresnow.c_snow_top;
-- upside-down
elseif( p2 >= 20 and p2 <= 24 ) then
suggested = moresnow.c_snow;
end
elseif( suggested == moresnow.c_snow_ramp_inner ) then
-- treat like a nodebox
if( p2>=4 and p2 <= 19 ) then
suggested = moresnow.c_snow_top;
-- upside-down
elseif( p2 >= 20 and p2 <= 24 ) then
suggested = moresnow.c_snow;
end
end
-- c_snow_top does not have facedir
if( suggested == moresnow.c_snow_top ) then
p2 = 1;
end
return { new_id = suggested, param2 = p2 };
end
-- default_name is the name of the node that would be placed in case of a solid underground
-- (usually default:snow)
moresnow.on_construct_select_shape = function( pos, falling_node_name, default_name )
-- get the node one below
local node1 = minetest.get_node( {x=pos.x, y=pos.y-1, z=pos.z});
-- no information about that node available; give up
if( not(node1) or not(node1.name) or not(minetest.registered_nodes[ node1.name ] )) then
return;
end
local res = moresnow.suggest_snow_type( minetest.get_content_id( node1.name ), node1.param2 );
-- snow_top is a special node suitable for nodeboxes; BUT: it only looks acceptable if the
-- node below that nodebox/torch/fence/etc is a solid one
if( res.new_id == moresnow.c_snow_top ) then
-- get the node below the node below
local node2 = minetest.get_node( {x=pos.x, y=pos.y-2, z=pos.z});
if( node2 and node2.name and node2.name == default_name ) then
return;
end
-- no information about the node below available - we don't know what to do
if( not( node2 ) or node2.name == 'air' or node2.name == 'ignore' ) then
-- in such a case it helps to drop the snow and let it fall until it hits something
if( node2 and node2.name == 'air' ) then
-- let the snow continue to fall
spawn_falling_node( {x=pos.x, y=pos.y-2, z=pos.z}, {name= default_name})
end
return { remove_node = true};
end
local new_id2 = moresnow.snow_cover[ minetest.get_content_id( node2.name )];
-- if the node below this one can't handle a normal snow cover, we can't put a snow top on our node either
if( not( new_id2 ) or new_id2 ~= moresnow.c_snow) then
return { remove_node = true};
end
-- else continue with c_snow_top
end
return res;
end
-- we need to make sure not to replace the node with the same content
moresnow.on_construct = function( pos, falling_node_name, default_name, node_type )
-- get the node we're talking about
local node0 = minetest.get_node( pos );
local res = moresnow.on_construct_select_shape( pos, falling_node_name, default_name );
if( res and res.remove_node ) then
-- check if we're removing the right node
if( node0 and node0.name and node0.name == falling_node_name) then
minetest.remove_node( pos );
end
return; -- we're finished
end
if( not( res ) ) then
-- will be handled by the engine
if( falling_node_name == default_name ) then
return;
-- the falling node was not default:snow (or an aequivalent); but we need default:snow here
elseif( node0 and node0.name and node0.name ~= default_name) then
if( not( minetest.registered_nodes[ default_name ] ) or default_name=='ignore') then
return;
end
return { name = default_name, param2 = 0 };
-- fallback
else
return;
end
end
if( node_type and moresnow.translation_table[ node_type ] ) then
res.new_id = moresnow.translation_table[ node_type ][ res.new_id ];
if( not( res.new_id )) then
return;
end
end
local suggested = minetest.get_name_from_content_id( res.new_id );
if( node0 and node0.name and (node0.name ~= suggested or ( suggested ~= default_name and node0.param2 and node0.param2 ~= res.param2))) then
if( not( minetest.registered_nodes[ suggested ] ) or suggested=='ignore') then
return;
end
return { name = suggested, param2 = res.param2};
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

View File

@ -1,26 +0,0 @@
PlayerPlus mod for minetest
This mod lets the player move faster when walking on ice, slows down the player
when walking on snow or in water, and makes touching a cactus hurt... enjoy!
https://forum.minetest.net/viewtopic.php?t=10090&p=153667
- 0.1 - Initial release
- 0.2 - 3d_armor mod compatibility
- 0.3 - Optimized code
- 0.4 - Added suffocation when inside nodes
- 0.5 - Slow down when walking in water
- 0.6 - Code tidy and tweak, increased damage by cactus and suffocation
- 0.7 - Added global 'playerplus' table to hold node names around player
Released under WTFPL
API:
Every second the mod checks which node the player is standing on, which node is
at foot and head level and stores inside a global table to be used by mods:
- playerplus[name].nod_stand
- playerplus[name].nod_foot
- playerplus[name].nod_head

View File

@ -1,2 +0,0 @@
default
3d_armor?

View File

@ -1,141 +0,0 @@
--[[
walking on ice makes player walk faster,
stepping through snow or water slows player down,
touching a cactus hurts player,
and if head stuck inside a solid node suffocates player.
PlayerPlus by TenPlus1
]]
playerplus = {}
-- get node but use fallback for nil or unknown
local function node_ok(pos, fallback)
fallback = fallback or "air"
local node = minetest.get_node_or_nil(pos)
if not node then
return fallback
end
if minetest.registered_nodes[node.name] then
return node.name
end
return fallback
end
local armor_mod = minetest.get_modpath("3d_armor")
local def = {}
local time = 0
minetest.register_globalstep(function(dtime)
time = time + dtime
-- every 1 second
if time < 1 then
return
end
-- reset time for next check
time = 0
-- check players
for _,player in pairs(minetest.get_connected_players()) do
-- who am I?
local name = player:get_player_name()
-- where am I?
local pos = player:getpos()
-- what is around me?
pos.y = pos.y - 0.1 -- standing on
playerplus[name].nod_stand = node_ok(pos)
pos.y = pos.y + 1.5 -- head level
playerplus[name].nod_head = node_ok(pos)
pos.y = pos.y - 1.2 -- feet level
playerplus[name].nod_feet = node_ok(pos)
pos.y = pos.y - 0.2 -- reset pos
-- set defaults
def.speed = 1
def.jump = 1
def.gravity = 1
-- is 3d_armor mod active? if so make armor physics default
if armor_mod and armor and armor.def then
-- get player physics from armor
def.speed = armor.def[name].speed or 1
def.jump = armor.def[name].jump or 1
def.gravity = armor.def[name].gravity or 1
end
-- standing on ice? if so walk faster
if playerplus[name].nod_stand == "default:ice" then
def.speed = def.speed + 0.4
end
-- standing on snow? if so walk slower
if playerplus[name].nod_stand == "default:snow"
or playerplus[name].nod_stand == "default:snowblock"
-- wading in water? if so walk slower
or minetest.registered_nodes[ playerplus[name].nod_feet ].groups.water then
def.speed = def.speed - 0.4
end
-- set player physics
player:set_physics_override(def.speed, def.jump, def.gravity)
--print ("Speed:", def.speed, "Jump:", def.jump, "Gravity:", def.gravity)
-- is player suffocating inside node? (only solid "normal" type nodes)
if minetest.registered_nodes[ playerplus[name].nod_head ].walkable
and minetest.registered_nodes[ playerplus[name].nod_head ].drawtype == "normal"
and not minetest.check_player_privs(name, {noclip = true}) then
if player:get_hp() > 0 then
player:set_hp(player:get_hp() - 2)
end
end
-- am I near a cactus?
local near = minetest.find_node_near(pos, 1, "default:cactus")
if near then
-- am I touching the cactus? if so it hurts
for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do
if object:get_hp() > 0 then
object:set_hp(object:get_hp() - 2)
end
end
end
end
end)
-- set to blank on join (for 3rd party mods)
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
playerplus[name] = {}
playerplus[name].nod_head = ""
playerplus[name].nod_feet = ""
playerplus[name].nod_stand = ""
end)
-- clear when player leaves
minetest.register_on_leaveplayer(function(player)
playerplus[ player:get_player_name() ] = nil
end)

View File

@ -1,14 +0,0 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@ -39,7 +39,7 @@ minetest.register_ore({
clust_num_ores = 6,
clust_size = 5,
y_min = -31000,
y_max = -5,
y_max = -500,
})
-- Quartz Block

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

View File

@ -1,4 +0,0 @@
vendor
======
Minetest mod: Vending machines

73
mods/vendor/init.lua vendored
View File

@ -1,73 +0,0 @@
---
--vendor 1.01
--Copyright (C) 2012 Bad_Command
--
--This library is free software; you can redistribute it and/or
--modify it under the terms of the GNU Lesser General Public
--License as published by the Free Software Foundation; either
--version 2.1 of the License, or (at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public
--License along with this library; if not, write to the Free Software
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
---
vendor = {}
vendor.version = 1.02
dofile(minetest.get_modpath("vendor") .. "/vendor.lua")
minetest.register_node("vendor:vendor", {
description = "Vending Machine",
tile_images ={"vendor_side.png", "vendor_side.png", "vendor_side.png",
"vendor_side.png", "vendor_side.png", "vendor_vendor_front.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
after_place_node = vendor.after_place_node,
can_dig = vendor.can_dig,
on_receive_fields = vendor.on_receive_fields,
allow_metadata_inventory_put = vendor.allow_metadata_inventory_put,
allow_metadata_inventory_take = vendor.allow_metadata_inventory_take,
allow_metadata_inventory_move = vendor.allow_metadata_inventory_move,
})
minetest.register_node("vendor:depositor", {
description = "Depositing Machine",
tile_images ={"vendor_side.png", "vendor_side.png", "vendor_side.png",
"vendor_side.png", "vendor_side.png", "vendor_depositor_front.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
after_place_node = vendor.after_place_node,
can_dig = vendor.can_dig,
on_receive_fields = vendor.on_receive_fields,
allow_metadata_inventory_put = vendor.allow_metadata_inventory_put,
allow_metadata_inventory_take = vendor.allow_metadata_inventory_take,
allow_metadata_inventory_move = vendor.allow_metadata_inventory_move,
})
minetest.register_craft({
output = 'vendor:vendor',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'group:wood', 'default:steel_ingot', 'group:wood'},
{'group:wood', 'default:steel_ingot', 'group:wood'},
}
})
minetest.register_craft({
output = 'vendor:depositor',
recipe = {
{'group:wood', 'default:steel_ingot', 'group:wood'},
{'group:wood', 'default:steel_ingot', 'group:wood'},
{'group:wood', 'group:wood', 'group:wood'},
}
})

View File

@ -1,502 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,5 +0,0 @@
Sounds effects derived from:
http://opengameart.org/content/inventory-sound-effects
Applicable licenses:
CC-BY 3.0 CC-BY-SA 3.0 GPL 3.0 GPL 2.0

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

223
mods/vendor/vendor.lua vendored
View File

@ -1,223 +0,0 @@
---
--vendor
--Copyright (C) 2012 Bad_Command
--Rewrited by Andrej
--
--This library is free software; you can redistribute it and/or
--modify it under the terms of the GNU Lesser General Public
--License as published by the Free Software Foundation; either
--version 2.1 of the License, or (at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public
--License along with this library; if not, write to the Free Software
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
---
vendor.set_formspec = function(pos, player)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local description = minetest.registered_nodes[node.name].description;
local number = meta:get_int("number")
local cost = meta:get_int("cost")
meta:set_string("formspec", "size[8,7;]"
.."label[0,0;" .. description .. "]"
.."list[current_name;item;0,1;1,1;]"
.."field[1.3,1.3;1,1;number;Count:;" .. number .. "]"
.."list[current_name;gold;0,2;1,1;]"
.."field[1.3,2.3;1,1;cost;Price:;" .. cost .. "]"
.."button[3,2;2,0.5;save;OK]"
.."list[current_player;main;0,3;8,4;]")
end
vendor.on_receive_fields_owner = function(pos, formname, fields, sender)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local number = tonumber(fields.number)
local cost = tonumber(fields.cost)
local inv_self = meta:get_inventory()
local itemstack = inv_self:get_stack("item",1)
local itemname=""
if not( number == nil or number < 1 or number > 99) then
meta:set_int("number", number)
end
if not( cost == nil or cost < 1 or cost > 99) then
meta:set_int("cost", cost)
end
if( itemstack and itemstack:get_name() ) then
itemname=itemstack:get_name()
end
meta:set_string("itemname", itemname)
vendor.set_formspec(pos, sender)
end
vendor.on_receive_fields_customer = function(pos, formname, fields, sender)
if not fields.save then
return
end
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local number = meta:get_int("number")
local cost = meta:get_int("cost")
local itemname=meta:get_string("itemname")
local buysell = "sell"
if ( node.name == "vendor:depositor" ) then
buysell = "buy"
end
if ( number == nil or number < 1 or number > 99) then
return
end
if ( cost == nil or cost < 1 or cost > 99) then
return
end
if ( itemname == nil or itemname=="") then
return
end
local chest = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
if chest.name=="default:chest_locked" and sender and sender:is_player() then
local chest_meta = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
local chest_inv = chest_meta:get_inventory()
local player_inv = sender:get_inventory()
if ( chest_meta:get_string("owner") == meta:get_string("owner") and chest_inv ~= nil and player_inv ~= nil ) then
local stack = {name=itemname, count=number, wear=0, metadata=""}
local price = {name="default:gold_ingot", count=cost, wear=0, metadata=""}
if buysell == "sell" then
if chest_inv:contains_item("main", stack) and player_inv:contains_item("main", price) and
chest_inv:room_for_item("main", price) and player_inv:room_for_item("main", stack) then
player_inv:remove_item("main", price)
stack = chest_inv:remove_item("main", stack)
chest_inv:add_item("main", price)
player_inv:add_item("main", stack)
minetest.chat_send_player(sender:get_player_name(), "You bought item.")
vendor.sound_vend(pos)
elseif chest_inv:contains_item("main", stack) and player_inv:contains_item("main", price) then
minetest.chat_send_player(sender:get_player_name(), "No room in inventory!")
else
minetest.chat_send_player(sender:get_player_name(), "Not enough materials!")
end
else
if chest_inv:contains_item("main", price) and player_inv:contains_item("main", stack) and
chest_inv:room_for_item("main", stack) and player_inv:room_for_item("main", price) then
stack = player_inv:remove_item("main", stack)
chest_inv:remove_item("main", price)
chest_inv:add_item("main", stack)
player_inv:add_item("main", price)
minetest.chat_send_player(sender:get_player_name(), "You sold item.")
vendor.sound_vend(pos)
elseif chest_inv:contains_item("main", price) and player_inv:contains_item("main", stack) then
minetest.chat_send_player(sender:get_player_name(), "No room in inventory!")
else
minetest.chat_send_player(sender:get_player_name(), "Not enough materials!")
end
end
else
minetest.chat_send_player(sender:get_player_name(), "Wrong chest!")
end
else
if sender and sender:is_player() then
minetest.chat_send_player(sender:get_player_name(), "Place chest under machine!")
end
end
--do transaction here
end
vendor.after_place_node = function(pos, placer)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local description = minetest.registered_nodes[node.name].description;
local player_name = placer:get_player_name()
inv:set_size("item", 1)
inv:set_size("gold", 1)
inv:set_stack( "gold", 1, "default:gold_ingot" )
meta:set_string("infotext", player_name.." - "..description)
meta:set_int("number", 1)
meta:set_int("cost", 1)
meta:set_string("itemname", "")
meta:set_string("owner", placer:get_player_name() or "")
vendor.set_formspec(pos, placer)
end
vendor.can_dig = function(pos, player)
local chest = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
local meta_chest = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z});
if chest.name=="default:chest_locked" then
if player and player:is_player() then
local owner_chest = meta_chest:get_string("owner")
local name = player:get_player_name()
if name == owner_chest then
return true --chest owner can dig shop
end
end
return false
else
return true --if no chest, enyone can dig this shop
end
end
vendor.on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if sender:get_player_name() == owner then
vendor.on_receive_fields_owner(pos, formname, fields, sender)
else
vendor.on_receive_fields_customer(pos, formname, fields, sender)
end
end
vendor.sound_vend = function(pos)
minetest.sound_play("vendor_vend", {pos = pos, gain = 1.0, max_hear_distance = 5,})
end
vendor.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname=="item" then
local meta = minetest.get_meta(pos);
local owner = meta:get_string("owner")
local name = player:get_player_name()
if name == owner then
local inv = meta:get_inventory()
if stack==nil then
inv:set_stack( "item", 1, nil )
else
inv:set_stack( "item", 1, stack:get_name() )
end
end
end
return 0
end
vendor.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
return 0
end
vendor.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0
end

View File

@ -1,4 +0,0 @@
vendorgoldblock
======
Minetest mod: Goldblock Vending machines

View File

@ -1 +0,0 @@
default

View File

@ -1,73 +0,0 @@
---
--vendorgoldblock 1.01
--Copyright (C) 2012 Bad_Command
--
--This library is free software; you can redistribute it and/or
--modify it under the terms of the GNU Lesser General Public
--License as published by the Free Software Foundation; either
--version 2.1 of the License, or (at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public
--License along with this library; if not, write to the Free Software
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
---vendorgoldblock machines made by maikerumine
vendorgoldblock = {}
vendorgoldblock.version = 1.02
dofile(minetest.get_modpath("vendorgoldblock") .. "/vendor.lua")
minetest.register_node("vendorgoldblock:vendor", {
description = "Goldblock Vending Machine",
tile_images ={"vendorg_side.png", "vendorg_side.png", "vendorg_side.png",
"vendorg_side.png", "vendorg_side.png", "vendorg_vendor_front.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
after_place_node = vendorgoldblock.after_place_node,
can_dig = vendorgoldblock.can_dig,
on_receive_fields = vendorgoldblock.on_receive_fields,
allow_metadata_inventory_put = vendorgoldblock.allow_metadata_inventory_put,
allow_metadata_inventory_take = vendorgoldblock.allow_metadata_inventory_take,
allow_metadata_inventory_move = vendorgoldblock.allow_metadata_inventory_move,
})
minetest.register_node("vendorgoldblock:depositor", {
description = "Goldblock Depositing Machine",
tile_images ={"vendorg_side.png", "vendorg_side.png", "vendorg_side.png",
"vendorg_side.png", "vendorg_side.png", "vendorg_depositor_front.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
after_place_node = vendorgoldblock.after_place_node,
can_dig = vendorgoldblock.can_dig,
on_receive_fields = vendorgoldblock.on_receive_fields,
allow_metadata_inventory_put = vendorgoldblock.allow_metadata_inventory_put,
allow_metadata_inventory_take = vendorgoldblock.allow_metadata_inventory_take,
allow_metadata_inventory_move = vendorgoldblock.allow_metadata_inventory_move,
})
minetest.register_craft({
output = 'vendorgoldblock:vendor',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'group:wood', 'default:gold_ingot', 'group:wood'},
{'group:wood', 'default:gold_ingot', 'group:wood'},
}
})
minetest.register_craft({
output = 'vendorgoldblock:depositor',
recipe = {
{'group:wood', 'default:gold_ingot', 'group:wood'},
{'group:wood', 'default:gold_ingot', 'group:wood'},
{'group:wood', 'group:wood', 'group:wood'},
}
})

View File

@ -1,502 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,5 +0,0 @@
Sounds effects derived from:
http://opengameart.org/content/inventory-sound-effects
Applicable licenses:
CC-BY 3.0 CC-BY-SA 3.0 GPL 3.0 GPL 2.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 830 B

View File

@ -1,223 +0,0 @@
---
--vendorgoldblock
--Copyright (C) 2012 Bad_Command
--Rewrited by Andrej
--
--This library is free software; you can redistribute it and/or
--modify it under the terms of the GNU Lesser General Public
--License as published by the Free Software Foundation; either
--version 2.1 of the License, or (at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public
--License along with this library; if not, write to the Free Software
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--vendorgoldblock machines made by maikerumine
vendorgoldblock.set_formspec = function(pos, player)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local description = minetest.registered_nodes[node.name].description;
local number = meta:get_int("number")
local cost = meta:get_int("cost")
meta:set_string("formspec", "size[8,7;]"
.."label[0,0;" .. description .. "]"
.."list[current_name;item;0,1;1,1;]"
.."field[1.3,1.3;1,1;number;Count:;" .. number .. "]"
.."list[current_name;goldblock;0,2;1,1;]"
.."field[1.3,2.3;1,1;cost;Price:;" .. cost .. "]"
.."button[3,2;2,0.5;save;OK]"
.."list[current_player;main;0,3;8,4;]")
end
vendorgoldblock.on_receive_fields_owner = function(pos, formname, fields, sender)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local number = tonumber(fields.number)
local cost = tonumber(fields.cost)
local inv_self = meta:get_inventory()
local itemstack = inv_self:get_stack("item",1)
local itemname=""
if not( number == nil or number < 1 or number > 99) then
meta:set_int("number", number)
end
if not( cost == nil or cost < 1 or cost > 99) then
meta:set_int("cost", cost)
end
if( itemstack and itemstack:get_name() ) then
itemname=itemstack:get_name()
end
meta:set_string("itemname", itemname)
vendorgoldblock.set_formspec(pos, sender)
end
vendorgoldblock.on_receive_fields_customer = function(pos, formname, fields, sender)
if not fields.save then
return
end
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local number = meta:get_int("number")
local cost = meta:get_int("cost")
local itemname=meta:get_string("itemname")
local buysell = "sell"
if ( node.name == "vendorgoldblock:depositor" ) then
buysell = "buy"
end
if ( number == nil or number < 1 or number > 99) then
return
end
if ( cost == nil or cost < 1 or cost > 99) then
return
end
if ( itemname == nil or itemname=="") then
return
end
local chest = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
if chest.name=="default:chest_locked" and sender and sender:is_player() then
local chest_meta = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
local chest_inv = chest_meta:get_inventory()
local player_inv = sender:get_inventory()
if ( chest_meta:get_string("owner") == meta:get_string("owner") and chest_inv ~= nil and player_inv ~= nil ) then
local stack = {name=itemname, count=number, wear=0, metadata=""}
local price = {name="default:goldblock", count=cost, wear=0, metadata=""}
if buysell == "sell" then
if chest_inv:contains_item("main", stack) and player_inv:contains_item("main", price) and
chest_inv:room_for_item("main", price) and player_inv:room_for_item("main", stack) then
player_inv:remove_item("main", price)
stack = chest_inv:remove_item("main", stack)
chest_inv:add_item("main", price)
player_inv:add_item("main", stack)
minetest.chat_send_player(sender:get_player_name(), "You bought item.")
vendorgoldblock.sound_vend(pos)
elseif chest_inv:contains_item("main", stack) and player_inv:contains_item("main", price) then
minetest.chat_send_player(sender:get_player_name(), "No room in inventory!")
else
minetest.chat_send_player(sender:get_player_name(), "Not enough materials!")
end
else
if chest_inv:contains_item("main", price) and player_inv:contains_item("main", stack) and
chest_inv:room_for_item("main", stack) and player_inv:room_for_item("main", price) then
stack = player_inv:remove_item("main", stack)
chest_inv:remove_item("main", price)
chest_inv:add_item("main", stack)
player_inv:add_item("main", price)
minetest.chat_send_player(sender:get_player_name(), "You sold item.")
vendorgoldblock.sound_vend(pos)
elseif chest_inv:contains_item("main", price) and player_inv:contains_item("main", stack) then
minetest.chat_send_player(sender:get_player_name(), "No room in inventory!")
else
minetest.chat_send_player(sender:get_player_name(), "Not enough materials!")
end
end
else
minetest.chat_send_player(sender:get_player_name(), "Wrong chest!")
end
else
if sender and sender:is_player() then
minetest.chat_send_player(sender:get_player_name(), "Place chest under machine!")
end
end
--do transaction here
end
vendorgoldblock.after_place_node = function(pos, placer)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local description = minetest.registered_nodes[node.name].description;
local player_name = placer:get_player_name()
inv:set_size("item", 1)
inv:set_size("goldblock", 1)
inv:set_stack( "goldblock", 1, "default:goldblock" )
meta:set_string("infotext", player_name.." - "..description)
meta:set_int("number", 1)
meta:set_int("cost", 1)
meta:set_string("itemname", "")
meta:set_string("owner", placer:get_player_name() or "")
vendorgoldblock.set_formspec(pos, placer)
end
vendorgoldblock.can_dig = function(pos, player)
local chest = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
local meta_chest = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z});
if chest.name=="default:chest_locked" then
if player and player:is_player() then
local owner_chest = meta_chest:get_string("owner")
local name = player:get_player_name()
if name == owner_chest then
return true --chest owner can dig shop
end
end
return false
else
return true --if no chest, enyone can dig this shop
end
end
vendorgoldblock.on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if sender:get_player_name() == owner then
vendorgoldblock.on_receive_fields_owner(pos, formname, fields, sender)
else
vendorgoldblock.on_receive_fields_customer(pos, formname, fields, sender)
end
end
vendorgoldblock.sound_vend = function(pos)
minetest.sound_play("vendor_vend", {pos = pos, gain = 1.0, max_hear_distance = 5,})
end
vendorgoldblock.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname=="item" then
local meta = minetest.get_meta(pos);
local owner = meta:get_string("owner")
local name = player:get_player_name()
if name == owner then
local inv = meta:get_inventory()
if stack==nil then
inv:set_stack( "item", 1, nil )
else
inv:set_stack( "item", 1, stack:get_name() )
end
end
end
return 0
end
vendorgoldblock.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
return 0
end
vendorgoldblock.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0
end

View File

@ -1,4 +0,0 @@
*~
.settings/*
.project
.buildpath

View File

@ -1,47 +0,0 @@
weather-pack
=======================
Weather mod for Minetest (http://minetest.net/)
Weathers included
-----------------------
* rain
* snow
* thunder
Commands
-----------------------
`set_weather <weather>` requires `weather_manager` privilege.
Dependencies
-----------------------
Thunder weather requres [lightning](https://github.com/minetest-mods/lightning) mod.
Configuration properties
-----------------------
Weather mod for indoor check depends on sunlight propogation check. Some nodes (e.g. glass block) propogates sunlight and thus weather particles will go through it. To change that set `weather_allow_override_nodes=true` in `minetest.conf` file. Be aware that just few nodes will be override and these blocks needs to be re-builded to take effect. Maybe in future other 'cheap' way to check indoor will be available.
Weather mod mostly relies on particles generation however for some small things ABM may be used. Users which do not want it can disable ABM with property `weather_allow_abm=false`.
License of source code:
-----------------------
LGPL 2.1+
Authors of media files:
-----------------------
TeddyDesTodes:
Snowflakes licensed under CC-BY-SA 3.0 by from weather branch at https://github.com/TeddyDesTodes/minetest/tree/weather
* `weather_pack_snow_snowflake1.png` - CC-BY-SA 3.0
* `weather_pack_snow_snowflake2.png` - CC-BY-SA 3.0
xeranas:
* `weather_pack_rain_raindrop_1.png` - CC-0
* `weather_pack_rain_raindrop_2.png` - CC-0
* `weather_pack_rain_raindrop_3.png` - CC-0
inchadney (http://freesound.org/people/inchadney/):
* `weather_rain.ogg` - CC-BY-SA 3.0 (cut from http://freesound.org/people/inchadney/sounds/58835/)

View File

@ -1 +0,0 @@
lightning?

View File

@ -1 +0,0 @@
Set of weathers for minetest.

View File

@ -1,13 +0,0 @@
local modpath = minetest.get_modpath("weather_pack");
dofile(modpath.."/weather_core.lua")
dofile(modpath.."/snow.lua")
dofile(modpath.."/rain.lua")
if minetest.get_modpath("lightning") ~= nil then
dofile(modpath.."/thunder.lua")
end
-- If not located then embeded skycolor mod version will be loaded.
if minetest.get_modpath("skycolor") == nil then
dofile(modpath.."/skycolor.lua")
end

View File

@ -1 +0,0 @@
name = weather_pack

View File

@ -1,186 +0,0 @@
rain = {
-- max rain particles created at time
particles_count = 35,
-- flag to turn on/off extinguish fire for rain
extinguish_fire = true,
-- flag useful when mixing weathers
raining = false,
-- keeping last timeofday value (rounded).
-- Defaulted to non-existing value for initial comparing.
sky_last_update = -1,
init_done = false,
}
rain.sound_handler = function(player)
return minetest.sound_play("weather_rain", {
object = player,
max_hear_distance = 2,
loop = true,
})
end
-- set skybox based on time (uses skycolor api)
rain.set_sky_box = function()
skycolor.add_layer(
"weather-pack-rain-sky",
{{r=0, g=0, b=0},
{r=85, g=86, b=98},
{r=152, g=150, b=159},
{r=85, g=86, b=98},
{r=0, g=0, b=0}})
skycolor.active = true
end
-- creating manually parctiles instead of particles spawner because of easier to control
-- spawn position.
rain.add_rain_particles = function(player)
rain.last_rp_count = 0
for i=rain.particles_count, 1,-1 do
local random_pos_x, random_pos_y, random_pos_z = weather.get_random_pos_by_player_look_dir(player)
if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then
rain.last_rp_count = rain.last_rp_count + 1
minetest.add_particle({
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
velocity = {x=0, y=-10, z=0},
acceleration = {x=0, y=-30, z=0},
expirationtime = 0.2,
size = math.random(0.5, 3),
collisiondetection = true,
collision_removal = true,
vertical = true,
texture = rain.get_texture(),
playername = player:get_player_name()
})
end
end
end
-- Simple random texture getter
rain.get_texture = function()
local texture_name
local random_number = math.random()
if random_number > 0.33 then
texture_name = "weather_pack_rain_raindrop_1.png"
elseif random_number > 0.66 then
texture_name = "weather_pack_rain_raindrop_2.png"
else
texture_name = "weather_pack_rain_raindrop_3.png"
end
return texture_name;
end
-- register player for rain weather.
-- basically needs for origin sky reference and rain sound controls.
rain.add_player = function(player)
if weather.players[player:get_player_name()] == nil then
local player_meta = {}
player_meta.origin_sky = {player:get_sky()}
weather.players[player:get_player_name()] = player_meta
end
end
-- remove player from player list effected by rain.
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
rain.remove_player = function(player)
local player_meta = weather.players[player:get_player_name()]
if player_meta ~= nil and player_meta.origin_sky ~= nil then
player:set_sky(player_meta.origin_sky[1], player_meta.origin_sky[2], player_meta.origin_sky[3])
weather.players[player:get_player_name()] = nil
end
end
-- adds and removes rain sound depending how much rain particles around player currently exist.
-- have few seconds delay before each check to avoid on/off sound too often
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
rain.update_sound = function(player)
local player_meta = weather.players[player:get_player_name()]
if player_meta ~= nil then
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > os.time() then
return false
end
if player_meta.sound_handler ~= nil then
if rain.last_rp_count == 0 then
minetest.sound_stop(player_meta.sound_handler)
player_meta.sound_handler = nil
end
elseif rain.last_rp_count > 0 then
player_meta.sound_handler = rain.sound_handler(player)
end
player_meta.sound_updated = os.time()
end
end
-- rain sound removed from player.
rain.remove_sound = function(player)
local player_meta = weather.players[player:get_player_name()]
if player_meta ~= nil and player_meta.sound_handler ~= nil then
minetest.sound_stop(player_meta.sound_handler)
player_meta.sound_handler = nil
end
end
-- callback function for removing rain
rain.clear = function()
rain.raining = false
rain.sky_last_update = -1
rain.init_done = false
skycolor.remove_layer("weather-pack-rain-sky")
for _, player in ipairs(minetest.get_connected_players()) do
rain.remove_sound(player)
rain.remove_player(player)
end
end
minetest.register_globalstep(function(dtime)
if weather.state ~= "rain" then
return false
end
rain.make_weather()
end)
rain.make_weather = function()
if rain.init_done == false then
rain.raining = true
rain.set_sky_box()
end
for _, player in ipairs(minetest.get_connected_players()) do
if (weather.is_underwater(player)) then
return false
end
rain.add_player(player)
rain.add_rain_particles(player)
rain.update_sound(player)
end
end
if weather.reg_weathers.rain == nil then
weather.reg_weathers.rain = {
chance = 15,
clear = rain.clear
}
end
-- ABM for extinguish fire
if weather.allow_abm then
minetest.register_abm({
nodenames = {"fire:basic_flame"},
interval = 4.0,
chance = 2,
action = function(pos, node, active_object_count, active_object_count_wider)
if rain.raining and rain.extinguish_fire then
if weather.is_outdoor(pos) then
minetest.remove_node(pos)
end
end
end
})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1,215 +0,0 @@
skycolor = {
-- Should be activated before do any effect.
active = false,
-- To skip update interval
force_update = true,
-- Update interval.
update_interval = 15,
-- Main sky colors: starts from midnight to midnight.
-- Please do not set directly. Use add_layer instead.
colors = {},
-- min value which will be used in color gradient, usualy its first user given color in 'pure' color.
min_val = 0,
-- number of colors while constructing gradient of user given colors
max_val = 1000,
-- Enables smooth transition between existing sky color and target.
smooth_transitions = true,
-- Transition between current sky color and new user given.
transition_in_progress = false,
-- Transition colors are generated automaticly during initialization.
transition_colors = {},
-- Time where transition between current color and user given will be done
transition_time = 15,
-- Tracks how much time passed during transition
transition_timer = 0,
-- Table for tracking layer order
layer_names = {},
-- To layer to colors table
add_layer = function(layer_name, layer_color, instant_update)
skycolor.colors[layer_name] = layer_color
table.insert(skycolor.layer_names, layer_name)
if (instant_update ~= true) then
skycolor.init_transition()
end
skycolor.force_update = true
end,
-- Retrieve layer from colors table
retrieve_layer = function()
local last_layer = skycolor.layer_names[#skycolor.layer_names]
return skycolor.colors[last_layer]
end,
-- Remove layer from colors table
remove_layer = function(layer_name)
for k, name in ipairs(skycolor.layer_names) do
if name == layer_name then
table.remove(skycolor.layer_names, k)
skycolor.force_update = true
return
end
end
end,
-- Update sky color. If players not specified update sky for all players.
update_sky_color = function(players)
local color = skycolor.current_sky_layer_color()
if (color == nil) then
skycolor.active = false
skycolor.set_default_sky()
return
end
players = skycolor.utils.get_players(players)
for _, player in ipairs(players) do
player:set_sky(color, "plain", nil)
end
end,
-- Returns current layer color in {r, g, b} format
current_sky_layer_color = function()
if #skycolor.layer_names == 0 then
return nil
end
-- min timeofday value 0; max timeofday value 1. So sky color gradient range will be between 0 and 1 * skycolor.max_value.
local timeofday = minetest.get_timeofday()
local rounded_time = math.floor(timeofday * skycolor.max_val)
local color = skycolor.utils.convert_to_rgb(skycolor.min_val, skycolor.max_val, rounded_time, skycolor.retrieve_layer())
return color
end,
-- Initialy used only on
update_transition_sky_color = function()
if #skycolor.layer_names == 0 then
skycolor.active = false
skycolor.set_default_sky()
return
end
local multiplier = 100
local rounded_time = math.floor(skycolor.transition_timer * multiplier)
if rounded_time >= skycolor.transition_time * multiplier then
skycolor.stop_transition()
return
end
local color = skycolor.utils.convert_to_rgb(0, skycolor.transition_time * multiplier, rounded_time, skycolor.transition_colors)
local players = skycolor.utils.get_players(nil)
for _, player in ipairs(players) do
player:set_sky(color, "plain", nil)
end
end,
-- Reset sky color to game default. If players not specified update sky for all players.
-- Could be sometimes useful but not recomended to use in general case as there may be other color layers
-- which needs to preserve.
set_default_sky = function(players)
local players = skycolor.utils.get_players(players)
for _, player in ipairs(players) do
player:set_sky(nil, "regular", nil)
end
end,
init_transition = function()
-- sadly default sky returns unpredictible colors so transition mode becomes usable only for user defined color layers
-- Here '2' means that one color layer existed before new added and transition is posible.
if #skycolor.layer_names < 2 then
return
end
local transition_start_color = skycolor.utils.get_current_bg_color()
if (transition_start_color == nil) then
return
end
local transition_end_color = skycolor.current_sky_layer_color()
skycolor.transition_colors = {transition_start_color, transition_end_color}
skycolor.transition_in_progress = true
end,
stop_transition = function()
skycolor.transition_in_progress = false
skycolor.transition_colors = {}
skycolor.transition_timer = 0
end,
utils = {
convert_to_rgb = function(minval, maxval, current_val, colors)
local max_index = #colors - 1
local val = (current_val-minval) / (maxval-minval) * max_index + 1.0
local index1 = math.floor(val)
local index2 = math.min(math.floor(val)+1, max_index + 1)
local f = val - index1
local c1 = colors[index1]
local c2 = colors[index2]
return {r=math.floor(c1.r + f*(c2.r - c1.r)), g=math.floor(c1.g + f*(c2.g-c1.g)), b=math.floor(c1.b + f*(c2.b - c1.b))}
end,
-- Simply getter. Ether returns user given players list or get all connected players if none provided
get_players = function(players)
if players == nil or #players == 0 then
players = minetest.get_connected_players()
end
return players
end,
-- Returns first player sky color. I assume that all players are in same color layout.
get_current_bg_color = function()
local players = skycolor.utils.get_players(nil)
for _, player in ipairs(players) do
return player:get_sky()
end
return nil
end
},
}
--maikerumine turned this off to use skybox instead
--[[
local timer = 0
minetest.register_globalstep(function(dtime)
if skycolor.active ~= true or #minetest.get_connected_players() == 0 then
return
end
if skycolor.smooth_transitions and skycolor.transition_in_progress then
skycolor.transition_timer = skycolor.transition_timer + dtime
skycolor.update_transition_sky_color()
return
end
if skycolor.force_update then
skycolor.update_sky_color()
skycolor.force_update = false
return
end
-- regular updates based on iterval
timer = timer + dtime;
if timer >= skycolor.update_interval then
skycolor.update_sky_color()
timer = 0
end
end)
minetest.register_on_joinplayer(function(player)
if (skycolor.active) then
skycolor.update_sky_color({player})
end
end)
]]

View File

@ -1,90 +0,0 @@
snow = {}
snow.particles_count = 15
snow.init_done = false
-- calculates coordinates and draw particles for snow weather
snow.add_rain_particles = function(player)
rain.last_rp_count = 0
for i=snow.particles_count, 1,-1 do
local random_pos_x, random_pos_y, random_pos_z = weather.get_random_pos_by_player_look_dir(player)
random_pos_y = math.random() + math.random(player:getpos().y - 1, player:getpos().y + 7)
if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then
rain.last_rp_count = rain.last_rp_count + 1
minetest.add_particle({
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
velocity = {x = math.random(-1,-0.5), y = math.random(-2,-1), z = math.random(-1,-0.5)},
acceleration = {x = math.random(-1,-0.5), y=-0.5, z = math.random(-1,-0.5)},
expirationtime = 2.0,
size = math.random(0.5, 2),
collisiondetection = true,
collision_removal = true,
vertical = true,
texture = snow.get_texture(),
playername = player:get_player_name()
})
end
end
end
snow.set_sky_box = function()
skycolor.add_layer(
"weather-pack-snow-sky",
{{r=0, g=0, b=0},
{r=241, g=244, b=249},
{r=0, g=0, b=0}}
)
skycolor.active = true
end
snow.clear = function()
skycolor.remove_layer("weather-pack-snow-sky")
snow.init_done = false
end
-- Simple random texture getter
snow.get_texture = function()
local texture_name
local random_number = math.random()
if random_number > 0.5 then
texture_name = "weather_pack_snow_snowflake1.png"
else
texture_name = "weather_pack_snow_snowflake2.png"
end
return texture_name;
end
local timer = 0
minetest.register_globalstep(function(dtime)
if weather.state ~= "snow" then
return false
end
timer = timer + dtime;
if timer >= 0.5 then
timer = 0
else
return
end
if snow.init_done == false then
snow.set_sky_box()
snow.init_done = true
end
for _, player in ipairs(minetest.get_connected_players()) do
if (weather.is_underwater(player)) then
return false
end
snow.add_rain_particles(player)
end
end)
-- register snow weather
if weather.reg_weathers.snow == nil then
weather.reg_weathers.snow = {
chance = 10,
clear = snow.clear
}
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

View File

@ -1,37 +0,0 @@
-- turn off lightning mod 'auto mode'
lightning.auto = false
thunder = {
next_strike = 0,
min_delay = 3,
max_delay = 12,
}
minetest.register_globalstep(function(dtime)
if weather.state ~= "thunder" then
return false
end
rain.make_weather()
if (thunder.next_strike <= os.time()) then
lightning.strike()
local delay = math.random(thunder.min_delay, thunder.max_delay)
thunder.next_strike = os.time() + delay
end
end)
thunder.clear = function()
rain.clear()
end
-- register thunderstorm weather
if weather.reg_weathers.thunder == nil then
weather.reg_weathers.thunder = {
chance = 5,
clear = thunder.clear,
min_duration = 120,
max_duration = 600,
}
end

View File

@ -1,175 +0,0 @@
weather = {
-- weather states, 'none' is default, other states depends from active mods
state = "none",
-- player list for saving player meta info
players = {},
-- time when weather should be re-calculated
next_check = 0,
-- default weather recalculation interval
check_interval = 300,
-- weather min duration
min_duration = 240,
-- weather max duration
max_duration = 3600,
-- weather calculated end time
end_time = nil,
-- registered weathers
reg_weathers = {},
-- automaticly calculates intervals and swap weathers
auto_mode = true,
-- global flag to disable/enable ABM logic.
allow_abm = true,
}
weather.get_rand_end_time = function(min_duration, max_duration)
if min_duration ~= nil and max_duration ~= nil then
return os.time() + math.random(min_duration, max_duration);
else
return os.time() + math.random(weather.min_duration, weather.max_duration);
end
end
weather.is_outdoor = function(pos)
if minetest.get_node_light({x=pos.x, y=pos.y + 1, z=pos.z}, 0.5) == 15 then
return true
end
return false
end
-- checks if player is undewater. This is needed in order to
-- turn off weather particles generation.
weather.is_underwater = function(player)
local ppos = player:getpos()
local offset = player:get_eye_offset()
local player_eye_pos = {x = ppos.x + offset.x,
y = ppos.y + offset.y + 1.5,
z = ppos.z + offset.z}
local node_level = minetest.get_node_level(player_eye_pos)
if node_level == 8 or node_level == 7 then
return true
end
return false
end
-- trying to locate position for particles by player look direction for performance reason.
-- it is costly to generate many particles around player so goal is focus mainly on front view.
weather.get_random_pos_by_player_look_dir = function(player)
local look_dir = player:get_look_dir()
local player_pos = player:getpos()
local random_pos_x = 0
local random_pos_y = 0
local random_pos_z = 0
if look_dir.x > 0 then
if look_dir.z > 0 then
random_pos_x = math.random() + math.random(player_pos.x - 2.5, player_pos.x + 5)
random_pos_z = math.random() + math.random(player_pos.z - 2.5, player_pos.z + 5)
else
random_pos_x = math.random() + math.random(player_pos.x - 2.5, player_pos.x + 5)
random_pos_z = math.random() + math.random(player_pos.z - 5, player_pos.z + 2.5)
end
else
if look_dir.z > 0 then
random_pos_x = math.random() + math.random(player_pos.x - 5, player_pos.x + 2.5)
random_pos_z = math.random() + math.random(player_pos.z - 2.5, player_pos.z + 5)
else
random_pos_x = math.random() + math.random(player_pos.x - 5, player_pos.x + 2.5)
random_pos_z = math.random() + math.random(player_pos.z - 5, player_pos.z + 2.5)
end
end
random_pos_y = math.random() + math.random(player_pos.y + 1, player_pos.y + 3)
return random_pos_x, random_pos_y, random_pos_z
end
minetest.register_globalstep(function(dtime)
if weather.auto_mode == false then
return 0
end
-- recalculate weather only when there aren't currently any
if (weather.state ~= "none") then
if (weather.end_time ~= nil and weather.end_time <= os.time()) then
weather.reg_weathers[weather.state].clear()
weather.state = "none"
end
elseif (weather.next_check <= os.time()) then
for weather_name, weather_meta in pairs(weather.reg_weathers) do
weather.set_random_weather(weather_name, weather_meta)
end
-- fallback next_check set, weather 'none' will be.
weather.next_check = os.time() + weather.check_interval
end
end)
-- sets random weather (which could be 'regular' (no weather)).
weather.set_random_weather = function(weather_name, weather_meta)
if weather.next_check > os.time() then return 0 end
if (weather_meta ~= nil and weather_meta.chance ~= nil) then
local random_roll = math.random(0,100)
if (random_roll <= weather_meta.chance) then
weather.state = weather_name
weather.end_time = weather.get_rand_end_time(weather_meta.min_duration, weather_meta.max_duration)
weather.next_check = os.time() + weather.check_interval
end
end
end
minetest.register_privilege("weather_manager", {
description = "Gives ability to control weather",
give_to_singleplayer = false
})
-- Weather command definition. Set
minetest.register_chatcommand("set_weather", {
params = "<weather>",
description = "Changes weather by given param, parameter none will remove weather.",
privs = {weather_manager = true},
func = function(name, param)
if (param == "none") then
if (weather.state ~= nil and weather.reg_weathers[weather.state] ~= nil) then
weather.reg_weathers[weather.state].clear()
weather.state = param
end
weather.state = "none"
end
if (weather.reg_weathers ~= nil and weather.reg_weathers[param] ~= nil) then
if (weather.state ~= nil and weather.state ~= "none" and weather.reg_weathers[weather.state] ~= nil) then
weather.reg_weathers[weather.state].clear()
end
weather.state = param
end
end
})
-- Configuration setting which allows user to disable ABM for weathers (if they use it).
-- Weather mods expected to be use this flag before registering ABM.
local weather_allow_abm = minetest.setting_getbool("weather_allow_abm")
if weather_allow_abm ~= nil and weather_allow_abm == false then
weather.allow_abm = false
end
-- Overrides nodes 'sunlight_propagates' attribute for efficient indoor check (e.g. for glass roof).
-- Controlled from minetest.conf setting and by default it is disabled.
-- To enable set weather_allow_override_nodes to true.
-- Only new nodes will be effected (glass roof needs to be rebuilded).
if minetest.setting_getbool("weather_allow_override_nodes") then
if minetest.registered_nodes["default:glass"] then
minetest.override_item("default:glass", {sunlight_propagates = false})
end
if minetest.registered_nodes["default:meselamp"] then
minetest.override_item("default:meselamp", {sunlight_propagates = false})
end
end