Add intllib support and German translation
[advtrains.git] / advtrains / advtrains_train_steam / init.lua
1 local S
2 if minetest.get_modpath("intllib") then
3 S = intllib.Getter()
4 else
5 S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
6 end
7
8 advtrains.register_wagon("newlocomotive", {
9 mesh="advtrains_engine_steam.b3d",
10 textures = {"advtrains_engine_steam.png"},
11 is_locomotive=true,
12 drives_on={default=true},
13 max_speed=10,
14 seats = {
15 {
16 name=S("Driver Stand (left)"),
17 attach_offset={x=-5, y=10, z=-10},
18 view_offset={x=0, y=6, z=0},
19 driving_ctrl_access=true,
20 },
21 {
22 name=S("Driver Stand (right)"),
23 attach_offset={x=5, y=10, z=-10},
24 view_offset={x=0, y=6, z=0},
25 driving_ctrl_access=true,
26 },
27 },
28 visual_size = {x=1, y=1},
29 wagon_span=1.85,
30 collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
31 update_animation=function(self, velocity)
32 if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then
33 self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true)
34 self.old_anim_velocity=advtrains.abs_ceil(velocity)
35 end
36 end,
37 custom_on_activate = function(self, staticdata_table, dtime_s)
38 minetest.add_particlespawner({
39 amount = 10,
40 time = 0,
41 -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
42 minpos = {x=0, y=2, z=1.2},
43 maxpos = {x=0, y=2, z=1.2},
44 minvel = {x=-0.2, y=1.8, z=-0.2},
45 maxvel = {x=0.2, y=2, z=0.2},
46 minacc = {x=0, y=-0.1, z=0},
47 maxacc = {x=0, y=-0.3, z=0},
48 minexptime = 2,
49 maxexptime = 4,
50 minsize = 1,
51 maxsize = 5,
52 -- ^ The particle's properties are random values in between the bounds:
53 -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
54 -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
55 collisiondetection = true,
56 -- ^ collisiondetection: if true uses collision detection
57 vertical = false,
58 -- ^ vertical: if true faces player using y axis only
59 texture = "smoke_puff.png",
60 -- ^ Uses texture (string)
61 attached = self.object,
62 })
63 end,
64 drops={"default:steelblock 4"},
65 }, S("Steam Engine"), "advtrains_engine_steam_inv.png")
66
67 advtrains.register_wagon("detailed_steam_engine", {
68 mesh="advtrains_detailed_steam_engine.b3d",
69 textures = {"advtrains_detailed_steam_engine.png"},
70 is_locomotive=true,
71 drives_on={default=true},
72 max_speed=10,
73 seats = {
74 {
75 name=S("Driver Stand (left)"),
76 attach_offset={x=-5, y=10, z=-10},
77 view_offset={x=0, y=6, z=0},
78 driving_ctrl_access=true,
79 },
80 {
81 name=S("Driver Stand (right)"),
82 attach_offset={x=5, y=10, z=-10},
83 view_offset={x=0, y=6, z=0},
84 driving_ctrl_access=true,
85 },
86 },
87 visual_size = {x=1, y=1},
88 wagon_span=2.05,
89 collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
90 update_animation=function(self, velocity)
91 if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then
92 self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true)
93 self.old_anim_velocity=advtrains.abs_ceil(velocity)
94 end
95 end,
96 custom_on_activate = function(self, staticdata_table, dtime_s)
97 minetest.add_particlespawner({
98 amount = 10,
99 time = 0,
100 -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
101 minpos = {x=0, y=2.3, z=1.45},
102 maxpos = {x=0, y=2.3, z=1.4},
103 minvel = {x=-0.2, y=1.8, z=-0.2},
104 maxvel = {x=0.2, y=2, z=0.2},
105 minacc = {x=0, y=-0.1, z=0},
106 maxacc = {x=0, y=-0.3, z=0},
107 minexptime = 2,
108 maxexptime = 4,
109 minsize = 1,
110 maxsize = 5,
111 -- ^ The particle's properties are random values in between the bounds:
112 -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
113 -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
114 collisiondetection = true,
115 -- ^ collisiondetection: if true uses collision detection
116 vertical = false,
117 -- ^ vertical: if true faces player using y axis only
118 texture = "smoke_puff.png",
119 -- ^ Uses texture (string)
120 attached = self.object,
121 })
122 end,
123 drops={"default:steelblock 4"},
124 }, S("Detailed Steam Engine"), "advtrains_engine_steam_inv.png")
125
126 advtrains.register_wagon("wagon_default", {
127 mesh="advtrains_passenger_wagon.b3d",
128 textures = {"advtrains_wagon.png"},
129 drives_on={default=true},
130 max_speed=10,
131 seats = {
132 {
133 name="1",
134 attach_offset={x=-4, y=8, z=8},
135 view_offset={x=0, y=0, z=0},
136 },
137 {
138 name="2",
139 attach_offset={x=4, y=8, z=8},
140 view_offset={x=0, y=0, z=0},
141 },
142 {
143 name="3",
144 attach_offset={x=-4, y=8, z=-8},
145 view_offset={x=0, y=0, z=0},
146 },
147 {
148 name="4",
149 attach_offset={x=4, y=8, z=-8},
150 view_offset={x=0, y=0, z=0},
151 },
152 },
153 visual_size = {x=1, y=1},
154 wagon_span=3.1,
155 collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
156 drops={"default:steelblock 4"},
157 }, S("Passenger Wagon"), "advtrains_wagon_inv.png")
158 advtrains.register_wagon("wagon_box", {
159 mesh="advtrains_wagon.b3d",
160 textures = {"advtrains_wagon_box.png"},
161 drives_on={default=true},
162 max_speed=10,
163 seats = {},
164 visual_size = {x=1, y=1},
165 wagon_span=1.8,
166 collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
167 drops={"default:steelblock 4"},
168 has_inventory = true,
169 get_inventory_formspec = function(self)
170 return "size[8,11]"..
171 "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]"..
172 "list[current_player;main;0,7;8,4;]"..
173 "listring[]"
174 end,
175 inventory_list_sizes = {
176 box=8*6,
177 },
178 }, S("Box Wagon"), "advtrains_wagon_box_inv.png")
179
180 minetest.register_craft({
181 output = 'advtrains:newlocomotive',
182 recipe = {
183 {'default:steelblock', 'default:steelblock', 'default:steelblock'},
184 {'default:steelblock', 'dye:black', 'default:steelblock'},
185 {'default:steelblock', 'default:steelblock', 'default:steelblock'},
186 },
187 })
188 minetest.register_craft({
189 output = 'advtrains:wagon_default',
190 recipe = {
191 {'default:steelblock', 'default:steelblock', 'default:steelblock'},
192 {'default:steelblock', 'dye:dark_green', 'default:steelblock'},
193 {'default:steelblock', 'default:steelblock', 'default:steelblock'},
194 },
195 })
196 minetest.register_craft({
197 output = 'advtrains:wagon_box',
198 recipe = {
199 {'default:steelblock', 'default:steelblock', 'default:steelblock'},
200 {'default:steelblock', 'default:chest', 'default:steelblock'},
201 {'default:steelblock', 'default:steelblock', 'default:steelblock'},
202 },
203 })