feat: add base:loot property (WIP)
This commit is contained in:
parent
f8c0862587
commit
773d14406c
@ -9,5 +9,6 @@
|
|||||||
"grounded": true,
|
"grounded": true,
|
||||||
"model": "X",
|
"model": "X",
|
||||||
"hitbox": [0.15, 0.0, 0.15, 0.7, 0.7, 0.7],
|
"hitbox": [0.15, 0.0, 0.15, 0.7, 0.7, 0.7],
|
||||||
"base:durability": 0.0
|
"base:durability": 0.0,
|
||||||
|
"base:drop": []
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,5 +8,8 @@
|
|||||||
"grass_side",
|
"grass_side",
|
||||||
"grass_side"
|
"grass_side"
|
||||||
],
|
],
|
||||||
"base:durability": 1.3
|
"base:durability": 1.3,
|
||||||
|
"base:loot": [
|
||||||
|
{"item": "base:dirt.item"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
"base:durability" = {}
|
"base:durability" = {}
|
||||||
|
"base:loot" = {}
|
||||||
|
|||||||
@ -11,4 +11,27 @@ function util.drop(ppos, itemid, count, pickup_delay)
|
|||||||
}})
|
}})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function calc_loot(loot_table)
|
||||||
|
local results = {}
|
||||||
|
for _, loot in ipairs(loot_table) do
|
||||||
|
local chance = loot.chance or 1
|
||||||
|
local count = loot.count or 1
|
||||||
|
|
||||||
|
local roll = math.random()
|
||||||
|
|
||||||
|
if roll < chance then
|
||||||
|
table.insert(results, {item=loot.item, count=count})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return results
|
||||||
|
end
|
||||||
|
|
||||||
|
function util.block_loot(blockid)
|
||||||
|
local lootscheme = block.properties[blockid]["base:loot"]
|
||||||
|
if lootscheme then
|
||||||
|
return calc_loot(lootscheme)
|
||||||
|
end
|
||||||
|
return {{block.get_picking_item(blockid), 1}}
|
||||||
|
end
|
||||||
|
|
||||||
return util
|
return util
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user