Fixed train inventories. Added sound effects. Added particle effects setting. Randomized building function timers.
parent
81dddaf0b7
commit
ad7fa47541
|
@ -0,0 +1,3 @@
|
|||
train sound (CC0): https://freesound.org/people/SGAK/sounds/467839/
|
||||
factory sound (CC BY 3.0) https://freesound.org/people/The%20Baron/sounds/98444/
|
||||
collector sound (CC BY 3.0) https://freesound.org/people/The%20Baron/sounds/98435/
|
|
@ -85,27 +85,3 @@ end)
|
|||
minetest.register_globalstep(function(dtime)
|
||||
update_shared_hud()
|
||||
end)
|
||||
|
||||
--smoke
|
||||
function smoke(pos)
|
||||
local rand = math.random(1,6)
|
||||
minetest.after(rand, function()
|
||||
minetest.add_particlespawner({
|
||||
amount = 300,
|
||||
time = 3,
|
||||
minpos = {x=pos.x,y=pos.y+1,z=pos.z},
|
||||
maxpos = {x=pos.x,y=pos.y+2,z=pos.z},
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.1, y=0.2, z=0.1},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.1,y=0.2,z=0.1},
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 10,
|
||||
maxsize = 12,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "dirt.png"
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,6 +5,8 @@
|
|||
License: AGPLv3
|
||||
]]--
|
||||
|
||||
local abm_timer = 0
|
||||
|
||||
power_producers = {}
|
||||
power_consumers = {}
|
||||
|
||||
|
@ -82,51 +84,62 @@ end
|
|||
|
||||
minetest.register_abm({
|
||||
nodenames = {"minegistics:PowerPlant"},
|
||||
interval = 10,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.forceload_block(pos, false)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local has_fuel = false
|
||||
if inv:contains_item("main", "minegistics_basenodes:coal_lump") then
|
||||
inv:remove_item("main", "minegistics_basenodes:coal_lump")
|
||||
has_fuel = true
|
||||
elseif inv:contains_item("main", "minegistics_basenodes:planks") then
|
||||
inv:remove_item("main", "minegistics_basenodes:planks")
|
||||
has_fuel = true
|
||||
end
|
||||
local active = is_active(pos)
|
||||
if has_fuel then
|
||||
if active == false then
|
||||
table.insert(power_producers, pos)
|
||||
abm_timer = abm_timer + 1
|
||||
if abm_timer >= math.random(8, 16) then
|
||||
minetest.forceload_block(pos, false)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local has_fuel = false
|
||||
if inv:contains_item("main", "minegistics_basenodes:coal_lump") then
|
||||
inv:remove_item("main", "minegistics_basenodes:coal_lump")
|
||||
has_fuel = true
|
||||
elseif inv:contains_item("main", "minegistics_basenodes:planks") then
|
||||
inv:remove_item("main", "minegistics_basenodes:planks")
|
||||
has_fuel = true
|
||||
end
|
||||
minetest.add_particlespawner({
|
||||
amount = 300,
|
||||
time = 6,
|
||||
minpos = {x=pos.x,y=pos.y+1,z=pos.z},
|
||||
maxpos = {x=pos.x,y=pos.y+2,z=pos.z},
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.1, y=0.2, z=0.1},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.1,y=0.2,z=0.1},
|
||||
minexptime = 2,
|
||||
maxexptime = 4,
|
||||
minsize = 10,
|
||||
maxsize = 12,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "black_smoke.png"
|
||||
})
|
||||
else
|
||||
if active == true then
|
||||
for i,p in pairs(power_producers) do
|
||||
if p.x == pos.x and p.y == pos.y and p.z == pos.z then
|
||||
table.remove(power_producers, i)
|
||||
break
|
||||
local active = is_active(pos)
|
||||
if has_fuel then
|
||||
if active == false then
|
||||
table.insert(power_producers, pos)
|
||||
end
|
||||
minetest.sound_play('power_plant', {
|
||||
pos = pos,
|
||||
loop = false,
|
||||
max_hear_distance = 16
|
||||
})
|
||||
if minetest.settings:get_bool("minegistics_particles", true) then
|
||||
minetest.add_particlespawner({
|
||||
amount = 300,
|
||||
time = 6,
|
||||
minpos = {x=pos.x,y=pos.y+1,z=pos.z},
|
||||
maxpos = {x=pos.x,y=pos.y+2,z=pos.z},
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.1, y=0.2, z=0.1},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.1,y=0.2,z=0.1},
|
||||
minexptime = 2,
|
||||
maxexptime = 4,
|
||||
minsize = 10,
|
||||
maxsize = 12,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "black_smoke.png"
|
||||
})
|
||||
end
|
||||
else
|
||||
if active == true then
|
||||
for i,p in pairs(power_producers) do
|
||||
if p.x == pos.x and p.y == pos.y and p.z == pos.z then
|
||||
table.remove(power_producers, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
abm_timer = 0
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
License: AGPLv3
|
||||
]]--
|
||||
|
||||
local abm_timer = 0
|
||||
|
||||
minetest.register_node("minegistics:Collector", {
|
||||
description = "Collector: Gathers resources.\n" ..
|
||||
"Place on a resource node and connect to a\n" ..
|
||||
|
@ -43,32 +45,59 @@ minetest.register_node("minegistics:Collector", {
|
|||
|
||||
minetest.register_abm({
|
||||
nodenames = {"minegistics:Collector"},
|
||||
interval = 10,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
minetest.forceload_block(pos, false)
|
||||
if power_stable(pos) then
|
||||
local next_to = {
|
||||
vector.new(pos.x, pos.y - 1, pos.z),
|
||||
vector.new(pos.x + 1, pos.y, pos.z),
|
||||
vector.new(pos.x - 1, pos.y, pos.z),
|
||||
vector.new(pos.x, pos.y, pos.z + 1),
|
||||
vector.new(pos.x, pos.y, pos.z - 1)
|
||||
}
|
||||
for node,ore in pairs(base_ores) do
|
||||
for key,direction in ipairs(next_to) do
|
||||
if minetest.get_node(direction).name == node then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = ItemStack(ore)
|
||||
meta:set_string("collecting", ore)
|
||||
stack:set_count(10)
|
||||
if inv:add_item("main", stack) then
|
||||
smoke(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
abm_timer = abm_timer + 1
|
||||
if abm_timer >= math.random(8, 16) then
|
||||
minetest.forceload_block(pos, false)
|
||||
if power_stable(pos) then
|
||||
local next_to = {
|
||||
vector.new(pos.x, pos.y - 1, pos.z),
|
||||
vector.new(pos.x + 1, pos.y, pos.z),
|
||||
vector.new(pos.x - 1, pos.y, pos.z),
|
||||
vector.new(pos.x, pos.y, pos.z + 1),
|
||||
vector.new(pos.x, pos.y, pos.z - 1)
|
||||
}
|
||||
for node,ore in pairs(base_ores) do
|
||||
for key,direction in ipairs(next_to) do
|
||||
if minetest.get_node(direction).name == node then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = ItemStack(ore)
|
||||
meta:set_string("collecting", ore)
|
||||
stack:set_count(10)
|
||||
if inv:add_item("main", stack) then
|
||||
minetest.sound_play('collector', {
|
||||
pos = pos,
|
||||
loop = false,
|
||||
max_hear_distance = 16
|
||||
})
|
||||
if minetest.settings:get_bool("minegistics_particles", true) then
|
||||
minetest.add_particlespawner({
|
||||
amount = 300,
|
||||
time = 3,
|
||||
minpos = {x=pos.x,y=pos.y+1,z=pos.z},
|
||||
maxpos = {x=pos.x,y=pos.y+2,z=pos.z},
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.1, y=0.2, z=0.1},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.1,y=0.2,z=0.1},
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 10,
|
||||
maxsize = 12,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "dirt.png"
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
abm_timer = 0
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
License: AGPLv3
|
||||
]]--
|
||||
|
||||
local abm_timer = 0
|
||||
|
||||
minetest.register_node("minegistics:Factory", {
|
||||
description = "Factory: Converts resources into products.\n" ..
|
||||
"Both can be sold but products are worth more.",
|
||||
|
@ -51,52 +53,63 @@ minetest.register_node("minegistics:Factory", {
|
|||
--converts resources into products
|
||||
minetest.register_abm({
|
||||
nodenames = {"minegistics:Factory"},
|
||||
interval = 10,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
minetest.forceload_block(pos, false)
|
||||
if power_stable(pos) then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local items = {}
|
||||
local working = false
|
||||
for _,lump in pairs(resources) do
|
||||
items[lump] = ItemStack(lump)
|
||||
end
|
||||
local inventories = inv:get_lists()
|
||||
for name, list in pairs(inventories) do
|
||||
for index, item in pairs(items) do
|
||||
while inv:contains_item(name, items[index]) do
|
||||
local item_name = items[index]:get_name()
|
||||
local item_amount = items[index]:get_count()
|
||||
local product = products[item_name]
|
||||
inv:remove_item(name, items[index])
|
||||
stack = ItemStack(product)
|
||||
stack:set_count(item_amount)
|
||||
inv:add_item("main", stack)
|
||||
working = true
|
||||
abm_timer = abm_timer + 1
|
||||
if abm_timer >= math.random(8, 16) then
|
||||
minetest.forceload_block(pos, false)
|
||||
if power_stable(pos) then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local items = {}
|
||||
local working = false
|
||||
for _,lump in pairs(resources) do
|
||||
items[lump] = ItemStack(lump)
|
||||
end
|
||||
local inventories = inv:get_lists()
|
||||
for name, list in pairs(inventories) do
|
||||
for index, item in pairs(items) do
|
||||
while inv:contains_item(name, items[index]) do
|
||||
local item_name = items[index]:get_name()
|
||||
local item_amount = items[index]:get_count()
|
||||
local product = products[item_name]
|
||||
inv:remove_item(name, items[index])
|
||||
stack = ItemStack(product)
|
||||
stack:set_count(item_amount)
|
||||
inv:add_item("main", stack)
|
||||
working = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if working then
|
||||
minetest.sound_play('factory', {
|
||||
pos = pos,
|
||||
loop = false,
|
||||
max_hear_distance = 16
|
||||
})
|
||||
if minetest.settings:get_bool("minegistics_particles", true) then
|
||||
minetest.add_particlespawner({
|
||||
amount = 300,
|
||||
time = 3,
|
||||
minpos = {x=pos.x,y=pos.y+1,z=pos.z},
|
||||
maxpos = {x=pos.x,y=pos.y+2,z=pos.z},
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.2, y=0.2, z=0.2},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.2,y=0.2,z=0.2},
|
||||
minexptime = 6,
|
||||
maxexptime = 8,
|
||||
minsize = 10,
|
||||
maxsize = 12,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "smoke.png"
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
if working then
|
||||
minetest.add_particlespawner({
|
||||
amount = 300,
|
||||
time = 3,
|
||||
minpos = {x=pos.x,y=pos.y+1,z=pos.z},
|
||||
maxpos = {x=pos.x,y=pos.y+2,z=pos.z},
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.2, y=0.2, z=0.2},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.2,y=0.2,z=0.2},
|
||||
minexptime = 6,
|
||||
maxexptime = 8,
|
||||
minsize = 10,
|
||||
maxsize = 12,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "smoke.png"
|
||||
})
|
||||
end
|
||||
abm_timer = 0
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
--TODO Create demands of specific items
|
||||
|
||||
local abm_timer = 0
|
||||
|
||||
minetest.register_node("minegistics:Market", {
|
||||
description = "Market: Changes any item into money.\n" ..
|
||||
"Must be connected by rail to a factory or collector.\n" ..
|
||||
|
@ -54,57 +56,61 @@ minetest.register_node("minegistics:Market", {
|
|||
--converts resources into money
|
||||
minetest.register_abm({
|
||||
nodenames = {"minegistics:Market"},
|
||||
interval = 10,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
minetest.forceload_block(pos, false)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if power_stable(pos) and meta:get_int("has_town") == 1 then
|
||||
meta:set_int("has_town", 0)
|
||||
local inv = meta:get_inventory()
|
||||
local items = {}
|
||||
local lumps = {}
|
||||
for _,lump in pairs(resources) do
|
||||
lumps[lump] = ItemStack(lump)
|
||||
end
|
||||
for _,product in pairs(products) do
|
||||
items[product] = ItemStack(product)
|
||||
end
|
||||
local money_earned = 0
|
||||
local inventories = inv:get_lists()
|
||||
for name, list in pairs(inventories) do
|
||||
for index, item in pairs(lumps) do
|
||||
while inv:contains_item(name, lumps[index]) do
|
||||
inv:remove_item(name, lumps[index])
|
||||
money_earned = money_earned + item_worth[item:get_name()]
|
||||
abm_timer = abm_timer + 1
|
||||
if abm_timer >= math.random(8, 16) then
|
||||
minetest.forceload_block(pos, false)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if power_stable(pos) and meta:get_int("has_town") == 1 then
|
||||
meta:set_int("has_town", 0)
|
||||
local inv = meta:get_inventory()
|
||||
local items = {}
|
||||
local lumps = {}
|
||||
for _,lump in pairs(resources) do
|
||||
lumps[lump] = ItemStack(lump)
|
||||
end
|
||||
for _,product in pairs(products) do
|
||||
items[product] = ItemStack(product)
|
||||
end
|
||||
local money_earned = 0
|
||||
local inventories = inv:get_lists()
|
||||
for name, list in pairs(inventories) do
|
||||
for index, item in pairs(lumps) do
|
||||
while inv:contains_item(name, lumps[index]) do
|
||||
inv:remove_item(name, lumps[index])
|
||||
money_earned = money_earned + item_worth[item:get_name()]
|
||||
end
|
||||
end
|
||||
for index, item in pairs(items) do
|
||||
while inv:contains_item(name, items[index]) do
|
||||
inv:remove_item(name, items[index])
|
||||
money_earned = money_earned + item_worth[item:get_name()]
|
||||
end
|
||||
end
|
||||
end
|
||||
for index, item in pairs(items) do
|
||||
while inv:contains_item(name, items[index]) do
|
||||
inv:remove_item(name, items[index])
|
||||
money_earned = money_earned + item_worth[item:get_name()]
|
||||
if money_earned > 0 then
|
||||
money = math.floor(money + money_earned)
|
||||
for index,price in pairs(item_prices) do
|
||||
local increase = money_earned * 0.01
|
||||
item_prices[index] = math.floor(item_prices[index] + increase)
|
||||
end
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local spec = player:get_inventory_formspec()
|
||||
local str = string.sub(spec,48,51)
|
||||
if str == "Shop" then
|
||||
local formspec = shop_formspec(player)
|
||||
player:set_inventory_formspec(table.concat(formspec, ""))
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all(
|
||||
"Earned $" .. money_earned .. " from market at " ..
|
||||
"(" .. pos.x .. ", " .. pos.y .. ", " .. pos.z .. ")"
|
||||
)
|
||||
end
|
||||
end
|
||||
if money_earned > 0 then
|
||||
money = math.floor(money + money_earned)
|
||||
for index,price in pairs(item_prices) do
|
||||
local increase = money_earned * 0.01
|
||||
item_prices[index] = math.floor(item_prices[index] + increase)
|
||||
end
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local spec = player:get_inventory_formspec()
|
||||
local str = string.sub(spec,48,51)
|
||||
if str == "Shop" then
|
||||
local formspec = shop_formspec(player)
|
||||
player:set_inventory_formspec(table.concat(formspec, ""))
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all(
|
||||
"Earned $" .. money_earned .. " from market at " ..
|
||||
"(" .. pos.x .. ", " .. pos.y .. ", " .. pos.z .. ")"
|
||||
)
|
||||
end
|
||||
abm_timer = 0
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -11,6 +11,8 @@ trains.punch_speed_max = 4
|
|||
-- Maximal distance for the path correction (for dtime peaks)
|
||||
trains.path_distance_max = 3
|
||||
|
||||
train_cargo = {}
|
||||
|
||||
dofile(trains.modpath.."/functions.lua")
|
||||
dofile(trains.modpath.."/rails.lua")
|
||||
dofile(trains.modpath.."/train_entity.lua")
|
||||
|
|
Binary file not shown.
|
@ -23,11 +23,18 @@ local train_entity = {
|
|||
old_pos = nil,
|
||||
old_switch = 0,
|
||||
railtype = nil,
|
||||
train_inv = {},
|
||||
automation_timer = 0,
|
||||
town_train = false,
|
||||
}
|
||||
|
||||
local function get_object_id(object)
|
||||
for id, entity in pairs(minetest.luaentities) do
|
||||
if entity.object == object then
|
||||
return id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function train_entity:on_activate(staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
if string.sub(staticdata, 1, string.len("return")) ~= "return" then
|
||||
|
@ -43,13 +50,13 @@ function train_entity:on_activate(staticdata, dtime_s)
|
|||
if data.old_dir then
|
||||
self.old_dir = data.old_dir
|
||||
end
|
||||
table.insert(train_cargo, get_object_id(self.object), {})
|
||||
end
|
||||
|
||||
function train_entity:get_staticdata()
|
||||
return minetest.serialize({
|
||||
railtype = self.railtype,
|
||||
old_dir = self.old_dir,
|
||||
train_inv = self.train_inv,
|
||||
town_train = self.town_train,
|
||||
})
|
||||
end
|
||||
|
@ -314,6 +321,11 @@ end
|
|||
local function structure_check(train, dtime)
|
||||
local vel = train.object:get_velocity()
|
||||
local pos = train.object:get_pos()
|
||||
local train_inv = train_cargo[get_object_id(train.object)]
|
||||
if train_inv == nil then
|
||||
table.insert(train_cargo, get_object_id(train.object), {})
|
||||
train_inv = train_cargo[get_object_id(train.object)]
|
||||
end
|
||||
local directions = {
|
||||
vector.new(pos.x + 1, pos.y, pos.z),
|
||||
vector.new(pos.x - 1, pos.y, pos.z),
|
||||
|
@ -329,13 +341,11 @@ local function structure_check(train, dtime)
|
|||
for _, lump in ipairs(resources) do
|
||||
while (contents:contains_item("main", (lump .. " 10"))) do
|
||||
contents:remove_item("main", (lump .. " 10"))
|
||||
if train.object:get_pos() == pos then
|
||||
if train.train_inv[lump] == nil then
|
||||
train.train_inv[lump] = 0
|
||||
end
|
||||
train.train_inv[lump] = train.train_inv[lump] + 10
|
||||
found_item = true
|
||||
if train_inv[lump] == nil then
|
||||
train_inv[lump] = 0
|
||||
end
|
||||
train_inv[lump] = train_inv[lump] + 10
|
||||
found_item = true
|
||||
end
|
||||
end
|
||||
if found_item then
|
||||
|
@ -344,15 +354,15 @@ local function structure_check(train, dtime)
|
|||
elseif structure_name == "minegistics:Factory" then
|
||||
local ore_hauler = false
|
||||
for _, lump in pairs(resources) do
|
||||
if train.train_inv[lump] == nil then
|
||||
train.train_inv[lump] = 0
|
||||
if train_inv[lump] == nil then
|
||||
train_inv[lump] = 0
|
||||
end
|
||||
if train.train_inv[lump] > 0 then
|
||||
if train_inv[lump] > 0 then
|
||||
if lump == "minegistics_basenodes:planks" then
|
||||
minetest.chat_send_all("ERROR ERROR ERROR ERROR")
|
||||
end
|
||||
contents:add_item("main", lump .. " " .. train.train_inv[lump])
|
||||
train.train_inv[lump] = 0
|
||||
contents:add_item("main", lump .. " " .. train_inv[lump])
|
||||
train_inv[lump] = 0
|
||||
ore_hauler = true
|
||||
end
|
||||
end
|
||||
|
@ -362,10 +372,10 @@ local function structure_check(train, dtime)
|
|||
for _, output in pairs(products) do
|
||||
while (contents:contains_item("main", (output .. " 10"))) do
|
||||
contents:remove_item("main", (output .. " 10"))
|
||||
if train.train_inv[output] == nil then
|
||||
train.train_inv[output] = 0
|
||||
if train_inv[output] == nil then
|
||||
train_inv[output] = 0
|
||||
end
|
||||
train.train_inv[output] = train.train_inv[output] + 10
|
||||
train_inv[output] = train_inv[output] + 10
|
||||
found_item = true
|
||||
end
|
||||
end
|
||||
|
@ -380,21 +390,21 @@ local function structure_check(train, dtime)
|
|||
spawn_passengers(pos)
|
||||
else
|
||||
for _, lump in pairs(resources) do
|
||||
if train.train_inv[lump] == nil then
|
||||
train.train_inv[lump] = 0
|
||||
if train_inv[lump] == nil then
|
||||
train_inv[lump] = 0
|
||||
end
|
||||
if train.train_inv[lump] > 0 then
|
||||
contents:add_item("main", lump .. " " .. train.train_inv[lump])
|
||||
train.train_inv[lump] = 0
|
||||
if train_inv[lump] > 0 then
|
||||
contents:add_item("main", lump .. " " .. train_oninv[lump])
|
||||
train_inv[lump] = 0
|
||||
end
|
||||
end
|
||||
for input, output in pairs(products) do
|
||||
if train.train_inv[output] == nil then
|
||||
train.train_inv[output] = 0
|
||||
if train_inv[output] == nil then
|
||||
train_inv[output] = 0
|
||||
end
|
||||
if train.train_inv[output] > 0 then
|
||||
contents:add_item("main", output .. " " .. train.train_inv[output])
|
||||
train.train_inv[output] = 0
|
||||
if train_inv[output] > 0 then
|
||||
contents:add_item("main", output .. " " .. train_inv[output])
|
||||
train_inv[output] = 0
|
||||
end
|
||||
end
|
||||
set_train_empty(train)
|
||||
|
@ -402,12 +412,12 @@ local function structure_check(train, dtime)
|
|||
end
|
||||
elseif structure_name == "minegistics:PowerPlant" then
|
||||
for _, fuel in pairs(fuels) do
|
||||
if train.train_inv[fuel] == nil then
|
||||
train.train_inv[fuel] = 0
|
||||
if train_inv[fuel] == nil then
|
||||
train_inv[fuel] = 0
|
||||
end
|
||||
if train.train_inv[fuel] > 0 then
|
||||
contents:add_item("main", fuel .. " " .. train.train_inv[fuel])
|
||||
train.train_inv[fuel] = 0
|
||||
if train_inv[fuel] > 0 then
|
||||
contents:add_item("main", fuel .. " " .. train_inv[fuel])
|
||||
train_inv[fuel] = 0
|
||||
end
|
||||
end
|
||||
set_train_empty(train)
|
||||
|
@ -433,23 +443,25 @@ function train_entity:on_step(dtime)
|
|||
end
|
||||
|
||||
function spawn_passengers(pos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 1,
|
||||
time = 1,
|
||||
minpos = {x=pos.x-0.1,y=pos.y,z=pos.z-0.1},
|
||||
maxpos = {x=pos.x+0.1,y=pos.y+1,z=pos.z+0.1},
|
||||
minvel = {x=0.1, y=0.01, z=0.1},
|
||||
maxvel = {x=0.1, y=0.05, z=0.1},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.1,y=0.2,z=0.1},
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "people.png"
|
||||
})
|
||||
if minetest.settings:get_bool("minegistics_particles", true) then
|
||||
minetest.add_particlespawner({
|
||||
amount = 1,
|
||||
time = 1,
|
||||
minpos = {x=pos.x-0.1,y=pos.y,z=pos.z-0.1},
|
||||
maxpos = {x=pos.x+0.1,y=pos.y+1,z=pos.z+0.1},
|
||||
minvel = {x=0.1, y=0.01, z=0.1},
|
||||
maxvel = {x=0.1, y=0.05, z=0.1},
|
||||
minacc = {x=-0.1,y=0.1,z=-0.1},
|
||||
maxacc = {x=0.1,y=0.2,z=0.1},
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "people.png"
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("minegistics_trains:train", train_entity)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#Enables or disables particle effects.
|
||||
minegistics_particles (Particle Effects) bool true
|
Loading…
Reference in New Issue