Several Bugfixes
parent
c27dea59b0
commit
b53329b452
|
@ -446,44 +446,3 @@ function mcl_util.rand_bool(probability, pr)
|
|||
return mcl_util.rand(pr, 0, 32767) < probability * 32768
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_util.switch_type(value, funcs, name)
|
||||
local t = type(value)
|
||||
local func = funcs[func] or funcs["default"]
|
||||
if func then
|
||||
return func(value, ...)
|
||||
else
|
||||
error("invalid " .. (name and name .. " " or "") .. "type: " .. t)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
function mcl_util.assert_type(value, expected_type, allow_nil)
|
||||
local actual_type = type(value)
|
||||
local errmsg = value .. " is not a " .. expected_type
|
||||
|
||||
if expected_type == "itemstack" then
|
||||
return mcl_util.switch_type(value, {
|
||||
["nil"] = function()
|
||||
assert(allow_nil, errmsg)
|
||||
end,
|
||||
["string"] = ItemStack,
|
||||
["table"] = ItemStack,
|
||||
["userdata"] = function()
|
||||
assert(value.get_name, errmsg)
|
||||
return value
|
||||
end,
|
||||
}, "ItemStack")
|
||||
end
|
||||
|
||||
if expected_type == "vector" then
|
||||
assert(actual_type == "table", errmsg)
|
||||
assert(value.x, errmsg)
|
||||
assert(value.y, errmsg)
|
||||
assert(value.z, errmsg)
|
||||
else
|
||||
assert((allow_nil and value == nil) or (actual_type == expected_type), errmsg)
|
||||
end
|
||||
return value
|
||||
end
|
||||
]]--
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = mcl_loot
|
||||
name = mcl_loottables
|
||||
author = Fleckenstein
|
||||
description = Provides Minecraft-like loot table definitions
|
||||
depends = mcl_util, mcl_predicates, mcl_item_modifiers, mcl_groupcache
|
||||
|
|
|
@ -2,6 +2,8 @@ mcl_numbers = {
|
|||
providers = {},
|
||||
}
|
||||
|
||||
dofile(minetest.get_modpath("mcl_numbers") .. "/api.lua")
|
||||
|
||||
mcl_numbers.register_provider("mcl_numbers:constant", function(provider)
|
||||
return provider.value
|
||||
end)
|
||||
|
|
|
@ -48,7 +48,7 @@ mcl_predicates.register_predicate("killed_by_player", function(predicate, data)
|
|||
end)
|
||||
|
||||
mcl_predicates.register_predicate("location_check", function(predicate, data)
|
||||
local pos = vector.add(data.pos), vector.new(predicate.offset_x or 0, predicate.offset_y or 0, predicate.offset_z or 0))
|
||||
local pos = vector.add(data.pos, vector.new(predicate.offset_x or 0, predicate.offset_y or 0, predicate.offset_z or 0))
|
||||
return mcl_location(pos, data.nodemeta):match(predicate.predicate)
|
||||
end)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ function mcl_types.match_enchantments(actual, expected)
|
|||
return true
|
||||
end
|
||||
|
||||
function mcl_util.match_item(actual, expected)
|
||||
function mcl_types.match_item(actual, expected)
|
||||
actual = actual or ItemStack()
|
||||
|
||||
if expected.item and actual:get_name() ~= expected.item then
|
||||
|
@ -55,7 +55,7 @@ function mcl_util.match_item(actual, expected)
|
|||
end
|
||||
end
|
||||
|
||||
function mcl_util.match_node(actual, expected, pos, meta)
|
||||
function mcl_types.match_node(actual, expected, pos, meta)
|
||||
if expected.node and actual.name ~= expected.node then
|
||||
return false
|
||||
elseif expected.group and minetest.get_item_group(actual.name, expected.group) == 0 then
|
||||
|
@ -78,7 +78,7 @@ function mcl_types.match_pos(actual, expected, meta)
|
|||
return false
|
||||
elseif expected.biome and minetest.get_biome_name(minetest.get_biome_data(actual).biome) ~= expected.biome then
|
||||
return false
|
||||
elseif expected.node and not mcl_types.match_node(minetest.get_node(actual), expected.node, actual, meta)
|
||||
elseif expected.node and not mcl_types.match_node(minetest.get_node(actual), expected.node, actual, meta) then
|
||||
return false
|
||||
elseif expected.light and not mcl_types.match_bounds(minetest.get_node_light(actual), expected.light) then
|
||||
return false
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
name = mcl_types
|
||||
author = Fleckenstein
|
||||
description = Offers compare functions for many types, used for MineClone2 datapacks
|
||||
depends =
|
||||
|
|
Loading…
Reference in New Issue