Compare commits
5 Commits
7681de96c9
...
875eb90acb
Author | SHA1 | Date |
---|---|---|
mbb | 875eb90acb | |
orwell96 | e9c51dfab4 | |
orwell96 | dc67ff7226 | |
orwell96 | be8aca9fb8 | |
orwell96 | 83df46d786 |
4
Makefile
|
@ -1,4 +0,0 @@
|
|||
tarball: clean
|
||||
which zip && zip -r advtrains.zip . -x "assets*" -x "*.zip" -x "*.git*"
|
||||
clean:
|
||||
rm -f advtrains.zip
|
BIN
advtrains.zip
|
@ -57,10 +57,14 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
|
|||
open={
|
||||
[-1]={frames={x=0, y=20}, time=1}, -- open left doors
|
||||
[1]={frames={x=40, y=60}, time=1} -- open right doors
|
||||
sound = <simpleSoundSpec>
|
||||
^- The sound file of the doors opening. If none is specified, nothing is played.
|
||||
},
|
||||
close={
|
||||
[-1]={frames={x=20, y=40}, time=1}, -- close left doors
|
||||
[1]={frames={x=60, y=80}, time=1} -- close right doors
|
||||
sound = <simpleSoundSpec>
|
||||
^- The sound file of the doors closing. If none is specified, nothing is played.
|
||||
}
|
||||
},
|
||||
door_entry={ 1.5, -1.5 }
|
||||
|
@ -77,6 +81,8 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
|
|||
extent_v = 2,
|
||||
^- Determines the collision box extent in y direction. Defaults to 2 (=3).
|
||||
^- The actual bounding box size is extent_v+1, so 0 means 1, 1 means 2, 2 means 3 a.s.o.
|
||||
horn_sound = <simpleSoundSpec>,
|
||||
^- The sound file of the horn. If none is specified, this wagon can't sound a horn. The specified sound file will be looped.
|
||||
|
||||
drops = {"default:steelblock 3"}
|
||||
^- List of itemstrings what to drop when the wagon is destroyed
|
||||
|
@ -99,8 +105,9 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
|
|||
^- optional: Execute custom code on every step
|
||||
custom_on_activate = function(self, dtime_s) end
|
||||
^- optional: Execute custom code on activate. Staticdata does not need to be saved and restored since all properties written in 'self' are preserved over unloads.
|
||||
update_animation = function(self, velocity) end
|
||||
^- optional: Function that is called whenever the train's velocity changes or every 2 seconds. Used to call 'self.object:update_animation()' if needed.
|
||||
custom_on_velocity_change = function(self, velocity, old_velocity) end
|
||||
^- optional: Function that is called whenever the train's velocity changes or every 2 seconds. Used to call 'self.object:update_animation()' if needed.
|
||||
^- for compatibility reasons the name 'update_animation' for this function is still supported.
|
||||
|
||||
}
|
||||
|
||||
|
@ -164,4 +171,4 @@ minetest.register_node(nodename, {
|
|||
on_train_leave=function(pos, train_id) end
|
||||
^- called when a train leaves the rail
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -262,7 +262,7 @@ ndb.restore_all = function()
|
|||
end
|
||||
else
|
||||
ndb.clear(pos)
|
||||
atwarn("Found ghost node (former",ndbnode.name,") @",pos,"deleting")
|
||||
atwarn("Found ghost node (former",ndbnode and ndbnode.name,") @",pos,"deleting")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -225,3 +225,19 @@ minetest.register_node("advtrains:across_on", {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{
|
||||
label = "Sound for Level Crossing",
|
||||
nodenames = {"advtrains:across_on"},
|
||||
interval = 3,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.sound_play("advtrains_crossing_bell", {
|
||||
pos = pos,
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 16, -- default, uses an euclidean metric
|
||||
})
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
|
|
@ -270,6 +270,18 @@ function wagon:on_step(dtime)
|
|||
if has_driverstand then
|
||||
--regular driver stand controls
|
||||
advtrains.on_control_change(pc, self:train(), self.wagon_flipped)
|
||||
--sound horn when required
|
||||
if self.horn_sound and pc.aux1 and not pc.sneak and not self.horn_handle then
|
||||
self.horn_handle = minetest.sound_play(self.horn_sound, {
|
||||
object = self.object,
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 128, -- default, uses an euclidean metric
|
||||
loop = true,
|
||||
})
|
||||
elseif not pc.aux1 and self.horn_handle then
|
||||
minetest.sound_stop(self.horn_handle)
|
||||
self.horn_handle = nil
|
||||
end
|
||||
else
|
||||
-- If on a passenger seat and doors are open, get off when W or D pressed.
|
||||
local pass = self.seatp[seatno] and minetest.get_player_by_name(self.seatp[seatno])
|
||||
|
@ -322,10 +334,12 @@ function wagon:on_step(dtime)
|
|||
-- if changed from 0 to +-1, play open anim. if changed from +-1 to 0, play close.
|
||||
-- if changed from +-1 to -+1, first close and set 0, then it will detect state change again and run open.
|
||||
if self.door_state == 0 then
|
||||
if self.doors.open.sound then minetest.sound_play(self.doors.open.sound, {object = self.object}) end
|
||||
at=self.doors.open[dstate]
|
||||
self.object:set_animation(at.frames, at.speed or 15, at.blend or 0, false)
|
||||
self.door_state = dstate
|
||||
else
|
||||
if self.doors.close.sound then minetest.sound_play(self.doors.close.sound, {object = self.object}) end
|
||||
at=self.doors.close[self.door_state or 1]--in case it has not been set yet
|
||||
self.object:set_animation(at.frames, at.speed or 15, at.blend or 0, false)
|
||||
self.door_state = 0
|
||||
|
@ -502,12 +516,16 @@ function wagon:on_step(dtime)
|
|||
self.object:setyaw(yaw)
|
||||
self.updatepct_timer=2
|
||||
if self.update_animation then
|
||||
self:update_animation(gp.velocity)
|
||||
self:update_animation(gp.velocity, self.old_velocity)
|
||||
end
|
||||
if self.custom_on_velocity_change then
|
||||
self:custom_on_velocity_change(gp.velocity, self.old_velocity or 0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
self.old_velocity_vector=velocityvec
|
||||
self.old_velocity = gp.velocity
|
||||
self.old_acceleration_vector=accelerationvec
|
||||
self.old_yaw=yaw
|
||||
atprintbm("wagon step", t)
|
||||
|
|
|
@ -13,22 +13,23 @@ advtrains.register_wagon("engine_industrial", {
|
|||
max_speed=20,
|
||||
seats = {
|
||||
{
|
||||
name=S("Driver Stand (left)"),
|
||||
attach_offset={x=-5, y=10, z=-10},
|
||||
view_offset={x=0, y=10, z=0},
|
||||
name=S("Driver Stand (right)"),
|
||||
attach_offset={x=5, y=7, z=-8},
|
||||
view_offset={x=5.2, y=-4, z=0},
|
||||
driving_ctrl_access=true,
|
||||
group = "dstand",
|
||||
},
|
||||
{
|
||||
name=S("Driver Stand (right)"),
|
||||
attach_offset={x=5, y=10, z=-10},
|
||||
view_offset={x=0, y=10, z=0},
|
||||
name=S("Driver Stand (left)"),
|
||||
attach_offset={x=5, y=7, z=-8},
|
||||
view_offset={x=-5.2, y=-4, z=0},
|
||||
driving_ctrl_access=true,
|
||||
group = "dstand",
|
||||
},
|
||||
},
|
||||
seat_groups = {
|
||||
dstand={
|
||||
|
||||
name = "Driver Stand",
|
||||
access_to = {},
|
||||
},
|
||||
|
@ -39,7 +40,45 @@ advtrains.register_wagon("engine_industrial", {
|
|||
is_locomotive=true,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
drops={"default:steelblock 4"},
|
||||
horn_sound = "advtrains_industrial_horn",
|
||||
}, S("Industrial Train Engine"), "advtrains_engine_industrial_inv.png")
|
||||
--big--
|
||||
advtrains.register_wagon("engine_industrial_big", {
|
||||
mesh="advtrains_engine_industrial_big.b3d",
|
||||
textures = {"advtrains_engine_industrial_big.png"},
|
||||
drives_on={default=true},
|
||||
max_speed=30,
|
||||
seats = {
|
||||
{
|
||||
name=S("Driver Stand (right)"),
|
||||
attach_offset={x=5, y=7, z=20},
|
||||
view_offset={x=5.2, y=-4, z=11},
|
||||
driving_ctrl_access=true,
|
||||
group = "dstand",
|
||||
},
|
||||
{
|
||||
name=S("Driver Stand (left)"),
|
||||
attach_offset={x=5, y=7, z=-8},
|
||||
view_offset={x=-5.2, y=-4, z=0},
|
||||
driving_ctrl_access=true,
|
||||
group = "dstand",
|
||||
},
|
||||
},
|
||||
seat_groups = {
|
||||
dstand={
|
||||
|
||||
name = "Driver Stand",
|
||||
access_to = {},
|
||||
},
|
||||
},
|
||||
assign_to_seat_group = {"dstand"},
|
||||
visual_size = {x=1, y=1},
|
||||
wagon_span=4,
|
||||
is_locomotive=true,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
drops={"default:steelblock 4"},
|
||||
horn_sound = "advtrains_industrial_horn",
|
||||
}, S("Big Industrial Train Engine"), "advtrains_engine_industrial_inv.png")
|
||||
advtrains.register_wagon("wagon_tank", {
|
||||
mesh="advtrains_wagon_tank.b3d",
|
||||
textures = {"advtrains_wagon_tank.png"},
|
||||
|
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 21 KiB |
|
@ -72,6 +72,7 @@ advtrains.register_wagon("engine_japan", {
|
|||
is_locomotive=true,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
drops={"default:steelblock 4"},
|
||||
horn_sound = "advtrains_japan_horn",
|
||||
}, S("Japanese Train Engine"), "advtrains_engine_japan_inv.png")
|
||||
|
||||
advtrains.register_wagon("wagon_japan", {
|
||||
|
|
|
@ -37,7 +37,7 @@ advtrains.register_wagon("newlocomotive", {
|
|||
visual_size = {x=1, y=1},
|
||||
wagon_span=2.3,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
update_animation=function(self, velocity)
|
||||
custom_on_velocity_change=function(self, velocity)
|
||||
if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then
|
||||
self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true)
|
||||
self.old_anim_velocity=advtrains.abs_ceil(velocity)
|
||||
|
@ -71,6 +71,7 @@ advtrains.register_wagon("newlocomotive", {
|
|||
})
|
||||
end,
|
||||
drops={"default:steelblock 4"},
|
||||
horn_sound = "advtrains_steam_whistle",
|
||||
}, S("Steam Engine"), "advtrains_engine_steam_inv.png")
|
||||
|
||||
advtrains.register_wagon("detailed_steam_engine", {
|
||||
|
@ -105,7 +106,7 @@ advtrains.register_wagon("detailed_steam_engine", {
|
|||
visual_size = {x=1, y=1},
|
||||
wagon_span=2.05,
|
||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
update_animation=function(self, velocity)
|
||||
custom_on_velocity_change=function(self, velocity)
|
||||
if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then
|
||||
self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true)
|
||||
self.old_anim_velocity=advtrains.abs_ceil(velocity)
|
||||
|
@ -139,6 +140,7 @@ advtrains.register_wagon("detailed_steam_engine", {
|
|||
})
|
||||
end,
|
||||
drops={"default:steelblock 4"},
|
||||
horn_sound = "advtrains_steam_whistle",
|
||||
}, S("Detailed Steam Engine"), "advtrains_detailed_engine_steam_inv.png")
|
||||
|
||||
advtrains.register_wagon("wagon_default", {
|
||||
|
|
|
@ -59,11 +59,13 @@ advtrains.register_wagon("subway_wagon", {
|
|||
doors={
|
||||
open={
|
||||
[-1]={frames={x=0, y=20}, time=1},
|
||||
[1]={frames={x=40, y=60}, time=1}
|
||||
[1]={frames={x=40, y=60}, time=1},
|
||||
sound = "advtrains_subway_dopen",
|
||||
},
|
||||
close={
|
||||
[-1]={frames={x=20, y=40}, time=1},
|
||||
[1]={frames={x=60, y=80}, time=1}
|
||||
[1]={frames={x=60, y=80}, time=1},
|
||||
sound = "advtrains_subway_dclose",
|
||||
}
|
||||
},
|
||||
door_entry={-1, 1},
|
||||
|
@ -73,10 +75,26 @@ advtrains.register_wagon("subway_wagon", {
|
|||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||
is_locomotive=true,
|
||||
drops={"default:steelblock 4"},
|
||||
--custom_on_activate = function(self, dtime_s)
|
||||
-- atprint("subway custom_on_activate")
|
||||
-- self.object:set_animation({x=1,y=80}, 15, 0, true)
|
||||
--end,
|
||||
horn_sound = "advtrains_subway_horn",
|
||||
custom_on_velocity_change = function(self, velocity, old_velocity)
|
||||
if old_velocity == 0 and velocity > 0 then
|
||||
minetest.sound_play("advtrains_subway_depart", {object = self.object})
|
||||
end
|
||||
if velocity < 2 and (old_velocity >= 2 or old_velocity == velocity) and not self.sound_arrive_handle then
|
||||
self.sound_arrive_handle = minetest.sound_play("advtrains_subway_arrive", {object = self.object})
|
||||
elseif (velocity > old_velocity) and self.sound_arrive_handle then
|
||||
minetest.sound_stop(self.sound_arrive_handle)
|
||||
self.sound_arrive_handle = nil
|
||||
end
|
||||
if velocity > 0 and not self.sound_loop_handle then
|
||||
self.sound_loop_handle = minetest.sound_play({name="advtrains_subway_loop", gain=0.3}, {object = self.object, loop=true})
|
||||
elseif velocity==0 then
|
||||
if self.sound_loop_handle then
|
||||
minetest.sound_stop(self.sound_loop_handle)
|
||||
self.sound_loop_handle = nil
|
||||
end
|
||||
end
|
||||
end,
|
||||
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")
|
||||
|
||||
--wagons
|
||||
|
|
|
@ -24,6 +24,13 @@ Inventory images : mbb
|
|||
Small code contributions : NaruTrey
|
||||
Major code contributions : gpcf
|
||||
Mod Description : hajo
|
||||
Sounds:
|
||||
advtrains_crossing_bell : Codesound
|
||||
advtrains_japan_horn : Codesound
|
||||
advtrains_steam_whistle : googol
|
||||
advtrains_subway_horn : https://freesound.org/people/Mullumbimby/sounds/385283/
|
||||
advtrains_subway_* : Gabriel (gpcf, gbl08ma)
|
||||
|
||||
If I forgot someone please punish me for that.
|
||||
|
||||
You can see this mod in action on Linuxworks Next Generation server.
|
||||
|
|