Add a subway train (and fix spelling mistake resulting in collision not working
parent
30dd71ea5a
commit
d0e1588399
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 955 B |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
After Width: | Height: | Size: 900 B |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -168,7 +168,7 @@ function advtrains.train_step(id, train, dtime)
|
|||
if train.couple_eid_back and (not minetest.luaentities[train.couple_eid_back] or not minetest.luaentities[train.couple_eid_back].is_couple) then train.couple_eid_back=nil end
|
||||
|
||||
--skip certain things (esp. collision) when not moving
|
||||
local train_moves=train.velocity~=0
|
||||
local train_moves=(train.velocity~=0)
|
||||
|
||||
--if not train.last_pos then advtrains.trains[id]=nil return end
|
||||
|
||||
|
@ -202,7 +202,7 @@ function advtrains.train_step(id, train, dtime)
|
|||
if train.tarvelocity<0 then train.tarvelocity=0 end
|
||||
end
|
||||
|
||||
if train_moving then
|
||||
if train_moves then
|
||||
--check for collisions by finding objects
|
||||
--front
|
||||
local search_radius=4
|
||||
|
@ -294,7 +294,7 @@ function advtrains.train_step(id, train, dtime)
|
|||
--handle collided_with_env
|
||||
if train.recently_collided_with_env then
|
||||
train.tarvelocity=0
|
||||
if not train_moving then
|
||||
if not train_moves then
|
||||
train.recently_collided_with_env=false--reset status when stopped
|
||||
end
|
||||
end
|
||||
|
|
26
wagons.lua
26
wagons.lua
|
@ -312,14 +312,14 @@ function advtrains.get_real_path_index(train, pit)
|
|||
end
|
||||
|
||||
|
||||
function advtrains.register_wagon(sysname, traintype, prototype)
|
||||
function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img)
|
||||
setmetatable(prototype, {__index=wagon})
|
||||
minetest.register_entity("advtrains:"..sysname,prototype)
|
||||
|
||||
minetest.register_craftitem("advtrains:"..sysname, {
|
||||
description = sysname,
|
||||
inventory_image = prototype.textures[1],
|
||||
wield_image = prototype.textures[1],
|
||||
description = desc,
|
||||
inventory_image = inv_img,
|
||||
wield_image = inv_img,
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
@ -347,7 +347,7 @@ function advtrains.register_wagon(sysname, traintype, prototype)
|
|||
end,
|
||||
})
|
||||
end
|
||||
advtrains.register_train_type("steam", {"regular", "fineturns", "default"})
|
||||
advtrains.register_train_type("steam", {"regular", "default"})
|
||||
|
||||
--[[advtrains.register_wagon("blackwagon", "steam",{textures = {"black.png"}})
|
||||
advtrains.register_wagon("bluewagon", "steam",{textures = {"blue.png"}})
|
||||
|
@ -375,7 +375,7 @@ advtrains.register_wagon("newlocomotive", "steam",{
|
|||
self.old_anim_velocity=advtrains.abs_ceil(velocity)
|
||||
end
|
||||
end
|
||||
})
|
||||
}, "Steam Engine", "advtrains_newlocomotive_inv.png")
|
||||
advtrains.register_wagon("wagon_default", "steam",{
|
||||
mesh="wagon.b3d",
|
||||
textures = {"advtrains_wagon.png"},
|
||||
|
@ -384,8 +384,20 @@ advtrains.register_wagon("wagon_default", "steam",{
|
|||
visual_size = {x=1, y=1},
|
||||
wagon_span=1.8,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
})
|
||||
}, "Passenger Wagon", "advtrains_wagon_inv.png")
|
||||
|
||||
advtrains.register_train_type("subway", {"regular", "default"})
|
||||
|
||||
advtrains.register_wagon("subway_wagon", "subway",{
|
||||
mesh="advtrains_subway_train.b3d",
|
||||
textures = {"advtrains_subway_train.png"},
|
||||
attach_offset={x=0, y=10, z=0},
|
||||
view_offset={x=0, y=6, z=0},
|
||||
visual_size = {x=1, y=1},
|
||||
wagon_span=1.8,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
is_locomotive=true,
|
||||
}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png")
|
||||
--[[
|
||||
advtrains.register_wagon("wagontype1",{on_rightclick=function(self, clicker)
|
||||
if clicker:get_player_control().sneak then
|
||||
|
|
Loading…
Reference in New Issue