Use Minecraft-like treasures in mineshaft chests

This commit is contained in:
Wuzzy 2017-05-13 22:47:43 +02:00
parent fb9f98191a
commit be5547336b
4 changed files with 77 additions and 65 deletions

View file

@ -1,4 +1,5 @@
# Railway corridors for Treasurer [`tsm_railcorridors`] # Railway corridors [`tsm_railcorridors`]
MineClone 2 adaption. NO TREASURER SUPPORT!
* Current version 0.11.0 * Current version 0.11.0

View file

@ -3,4 +3,3 @@ mcl_util
mcl_core mcl_core
mcl_tnt mcl_tnt
mcl_farming mcl_farming
treasurer?

View file

@ -24,30 +24,76 @@ tsm_railcorridors.nodes = {
-- only if the Treasurer mod is not found. -- only if the Treasurer mod is not found.
-- pr: A PseudoRandom object -- pr: A PseudoRandom object
function tsm_railcorridors.get_default_treasure(pr) function tsm_railcorridors.get_default_treasure(pr)
if pr:next(0,1000) < 30 then -- UNUSED IN MINECLONE 2!
return "mcl_farming:bread "..pr:next(1,3) end
elseif pr:next(0,1000) < 50 then
if pr:next(0,1000) < 500 then -- MineClone 2's treasure function. Gets all treasures for a single chest.
return "mcl_farming:pumpkin_seeds "..pr:next(1,5) -- Based on information from Minecraft Wiki.
else function tsm_railcorridors.get_treasures(pr)
return "mcl_farming:melon_seeds "..pr:next(1,5) local r1 = pr:next(1,71)
end local r2 = pr:next(1,83)
elseif pr:next(0,1000) < 5 then local r3 = pr:next(1,50)
return "mcl_tools:pick_iron"
elseif pr:next(0,1000) < 3 then local items = {}
local r = pr:next(0, 1000) -- First roll
if r < 400 then if r1 <= 30 then
return "mcl_core:iron_ingot "..pr:next(1,5) table.insert(items, "mobs:nametag")
elseif r < 800 then elseif r1 <= 50 then
return "mcl_core:gold_ingot "..pr:next(1,3) table.insert(items, "mcl_core:apple_gold")
else elseif r1 <= 60 then
return "mcl_core:diamond "..pr:next(1,2) -- TODO: Enchanted Book
end table.insert(items, "mcl_books:book")
elseif pr:next(0,1000) < 30 then elseif r1 <= 65 then
return "mcl_torches:torch "..pr:next(1,16) -- Nothing!
elseif pr:next(0,1000) < 20 then elseif r1 <= 70 then
return "mcl_core:coal_lump "..pr:next(3,8) table.insert(items, "mcl_tools:pick_iron")
else else
return "" -- TODO: Enchanted Golden Apple
end table.insert(items, "mcl_core:apple_gold")
end
-- Second roll
local r2stacks = pr:next(2,4)
for i=1, r2stacks do
if r2 <= 15 then
table.insert(items, "mcl_farming:bread "..pr:next(1,3))
elseif r2 <= 25 then
table.insert(items, "mcl_core:coal_lump "..pr:next(3,8))
elseif r2 <= 35 then
table.insert(items, "mcl_farming:beetroot_seeds "..pr:next(2,4))
elseif r2 <= 45 then
table.insert(items, "mcl_farming:melon_seeds "..pr:next(2,4))
elseif r2 <= 55 then
table.insert(items, "mcl_farming:pumpkin_seeds "..pr:next(2,4))
elseif r2 <= 65 then
table.insert(items, "mcl_core:iron_ingot "..pr:next(1,5))
elseif r2 <= 70 then
table.insert(items, "mcl_dye:blue "..pr:next(4,9))
elseif r2 <= 75 then
table.insert(items, "mesecons:redstone "..pr:next(4,9))
elseif r2 <= 80 then
table.insert(items, "mcl_core:gold_ingot "..pr:next(1,3))
else
table.insert(items, "mcl_core:diamond "..pr:next(1,2))
end
end
-- Third roll
for i=1, 3 do
if r3 <= 20 then
table.insert(items, "mcl_minecarts:rail "..pr:next(4,8))
elseif r3 <= 35 then
table.insert(items, "mcl_torches:torch "..pr:next(1,16))
elseif r3 <= 40 then
-- TODO: Activator Rail
table.insert(items, "mcl_minecarts:rail "..pr:next(1,4))
elseif r3 <= 45 then
-- TODO: Detector Rail
table.insert(items, "mcl_minecarts:rail "..pr:next(1,4))
else
table.insert(items, "mcl_minecarts:golden_rail "..pr:next(1,4))
end
end
return items
end end

View file

@ -197,49 +197,15 @@ end
-- Random chest items -- Random chest items
-- Zufälliger Kisteninhalt -- Zufälliger Kisteninhalt
local function rci()
if(minetest.get_modpath("treasurer") ~= nil) then
local treasures
if pr:next(0,100) < 3 then
treasures = treasurer.select_random_treasures(1,2,4)
elseif pr:next(0,100) < 5 then
if pr:next(0,100) < 50 then
treasures = treasurer.select_random_treasures(1,2,4,"seed")
else
treasures = treasurer.select_random_treasures(1,2,4,"seed")
end
elseif pr:next(0,1000) < 5 then
if minetest.get_modpath("tnt") then
return "tnt:tnt "..pr:next(1,3)
end
elseif pr:next(0,1000) < 3 then
if pr:next(0,1000) < 800 then
treasures = treasurer.select_random_treasures(1,3,6,"mineral")
else
treasures = treasurer.select_random_treasures(1,5,9,"mineral")
end
end
if(treasures ~= nil) then
if(#treasures>=1) then
return treasures[1]:get_name()
else
return ""
end
else
return ""
end
else
return tsm_railcorridors.get_default_treasure(pr)
end
end
-- chests -- chests
local function Place_Chest(pos, param2) local function Place_Chest(pos, param2)
if SetNodeIfCanBuild(pos, {name=tsm_railcorridors.nodes.chest, param2=param2}) then if SetNodeIfCanBuild(pos, {name=tsm_railcorridors.nodes.chest, param2=param2}) then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for i=1, inv:get_size("main") do local items = tsm_railcorridors.get_treasures(pr)
inv:set_stack("main", i, ItemStack(rci())) for i=1, math.min(#items, inv:get_size("main")) do
inv:set_stack("main", i, ItemStack(items[i]))
end end
end end
end end