From 902a4f7a02dbaefb97afceef52876710bfa524f2 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 29 Nov 2016 17:20:06 +0100 Subject: add/update crafting recipes for bumpers and detector rails --- advtrains.zip | Bin 1576313 -> 1484754 bytes crafting.lua | 10 +++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/advtrains.zip b/advtrains.zip index d703fbe..a8d0fdc 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/crafting.lua b/crafting.lua index b0bb8bc..6b7aa11 100644 --- a/crafting.lua +++ b/crafting.lua @@ -32,13 +32,21 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'advtrains:dtrack_bumper 2', + output = 'advtrains:dtrack_bumper_placer 2', recipe = { {'default:wood', 'dye:red'}, {'default:steel_ingot', 'default:steel_ingot'}, {'advtrains:dtrack_placer', 'advtrains:dtrack_placer'}, }, }) +minetest.register_craft({ + type="shapeless", + output = 'advtrains:dtrack_detector_off_placer', + recipe = { + "advtrains:dtrack_placer", + "mesecons:wire_00000000_off" + }, +}) --signals minetest.register_craft({ output = 'advtrains:retrosignal_off 2', -- cgit v1.2.3 From e9eacee7df742916572b2f23a1091aea3fcb4ac4 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Sat, 3 Dec 2016 23:18:12 +0100 Subject: add description, screenshot and update manual also fix crafting recipe for box wagon --- advtrains.zip | Bin 1484754 -> 1484909 bytes crafting.lua | 2 +- description.txt | 8 ++++++++ manual.pdf | Bin 1083147 -> 1037362 bytes readme.txt | 19 ++----------------- screenshot.png | Bin 0 -> 445014 bytes 6 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 description.txt create mode 100644 screenshot.png diff --git a/advtrains.zip b/advtrains.zip index a8d0fdc..714bb35 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/crafting.lua b/crafting.lua index 6b7aa11..a54912c 100644 --- a/crafting.lua +++ b/crafting.lua @@ -93,7 +93,7 @@ minetest.register_craft({ }, }) minetest.register_craft({ - output = 'advtrains:wagon_default_box', + output = 'advtrains:wagon_box', recipe = { {'default:steelblock', 'default:steelblock', 'default:steelblock'}, {'default:steelblock', 'default:junglewood', 'default:steelblock'}, diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..ecc5d58 --- /dev/null +++ b/description.txt @@ -0,0 +1,8 @@ +Advanced Trains v1.3.0, by orwell and contributors. Also see readme. +Good-looking, realistic trains for minetest. + +For crafting recipes, see manual.pdf + +Website: http://advtrains.bleipb.de/ +Manual: https://github.com/orwell96/advtrains/blob/master/manual.pdf +Forum : https://forum.minetest.net/viewtopic.php?f=11&t=14726 \ No newline at end of file diff --git a/manual.pdf b/manual.pdf index 71c3b3f..e8c6380 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/readme.txt b/readme.txt index 8465de0..ad093bd 100644 --- a/readme.txt +++ b/readme.txt @@ -3,22 +3,6 @@ by orwell96 and contributors(see below) For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 - -### How to drive trains -(The non-pdf manual file got corrupted, one day I need to make a new manual. Meanwhile here) -First of all: you can always get off the train with right-click. - -While on a train: -W - faster -S - slower / change direction -Space: brake -Shift+S: set speed to 0 (train rolls out, brake to stop!) -Shift+W: Set full speed -Shift+A: Set speed to 4 (~40km/h) -Shift+D: Set speed to 8 (~100km/h) -Shift+Space: toggle brake -Shift+Use: get off - Manual: @@ -35,4 +19,5 @@ Models for signals/bumpers : mbb Steam engine / wagon texture: mbb Industrial engine/wagons : mbb Inventory images : mbb -Small code contributions : NaruTrey / gpcf \ No newline at end of file +Small code contributions : NaruTrey / gpcf +Mod Description : hajo \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..78783e1 Binary files /dev/null and b/screenshot.png differ -- cgit v1.2.3 From f155011e1a407e163f8547101973bdbd11439365 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Sat, 3 Dec 2016 23:53:12 +0100 Subject: remove the legacy replacement lbms/abms Until now, everyone should have updated at least once... --- advtrains.zip | Bin 1484909 -> 1484903 bytes tracks.lua | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index 714bb35..c5777f8 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/tracks.lua b/tracks.lua index 811cf16..546216a 100644 --- a/tracks.lua +++ b/tracks.lua @@ -5,7 +5,7 @@ --If the old non-model rails on straight tracks should be replaced by the new... --false: no --true: yes -advtrains.register_straight_rep_lbm=true +advtrains.register_replacement_lbms=false --[[TracksDefinition nodename_prefix @@ -538,6 +538,7 @@ for name,rep in pairs({swl_st="swlst", swr_st="swrst", swl_cr="swlcr", swr_cr="s }) end +if advtrains.register_replacement_lbms then minetest.register_lbm({ name = "advtrains:ramp_replacement_1", -- In the following two fields, also group:groupname will work. @@ -550,7 +551,6 @@ minetest.register_lbm({ nodenames = {"advtrains:track_vert2"}, action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst2", param2=(node.param2+2)%4}) end, }) -if advtrains.register_straight_rep_lbm then minetest.register_abm({ name = "advtrains:st_rep_1", -- In the following two fields, also group:groupname will work. -- cgit v1.2.3 From 8f5c0feb45555fc92578936a314b1d3a3422c60d Mon Sep 17 00:00:00 2001 From: orwell96 Date: Sun, 4 Dec 2016 23:18:28 +0100 Subject: fix bug about seats on wagon sometimes a single character can cause great mess... --- advtrains.zip | Bin 1484903 -> 1484902 bytes wagons.lua | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/advtrains.zip b/advtrains.zip index c5777f8..4d966b4 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/wagons.lua b/wagons.lua index 8348353..6b3780a 100644 --- a/wagons.lua +++ b/wagons.lua @@ -427,7 +427,7 @@ function wagon:get_off_plr(pname) end end function wagon:get_seatno(pname) - for no, cont in ipairs(self.seatp) do + for no, cont in pairs(self.seatp) do if cont==pname then return no end -- cgit v1.2.3 From 631636f75706659dba11afc3a9d8075d8278fe43 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 5 Dec 2016 20:53:43 +0100 Subject: try to fix damage bug --- advtrains.zip | Bin 1484902 -> 1484978 bytes damage.lua | 4 ++-- trainlogic.lua | 15 +++++++++++++-- wagons.lua | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index 4d966b4..06da9f3 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/damage.lua b/damage.lua index 3fc1d97..b39fe67 100644 --- a/damage.lua +++ b/damage.lua @@ -1,7 +1,7 @@ --damage.lua --a globalstep that damages players overrolled by trains. -advtrains.player_to_wagon_mapping={} +advtrains.player_to_train_mapping={} local tmr=0 minetest.register_globalstep(function(dtime) @@ -13,7 +13,7 @@ minetest.register_globalstep(function(dtime) for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do local le=object:get_luaentity() if le and le.is_wagon and le.initialized and le:train() then - if (not advtrains.player_to_wagon_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_wagon_mapping[player:get_player_name()].train_id) and math.abs(le:train().velocity)>2 then + if (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and math.abs(le:train().velocity)>2 then --player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}}) player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3) end diff --git a/trainlogic.lua b/trainlogic.lua index 11849fd..633024d 100644 --- a/trainlogic.lua +++ b/trainlogic.lua @@ -487,8 +487,19 @@ function advtrains.pathpredict(id, train) train.path_dist[-1]=vector.distance(train.last_pos, train.last_pos_prev) end + local pregen_front=2 + local pregen_back=2 + if train.velocity>0 then + if train.movedir>0 then + pregen_front=2+math.ceil(train.velocity*0.15) --assumes server step of 0.1 seconds, +50% tolerance + else + pregen_back=2+math.ceil(train.velocity*0.15) + end + end + + local maxn=advtrains.maxN(train.path) - while (maxn-train.index) < 2 do--pregenerate + while (maxn-train.index) < pregen_front do--pregenerate --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.traintype) if conway then @@ -505,7 +516,7 @@ function advtrains.pathpredict(id, train) end local minn=advtrains.minN(train.path) - while (train.index-minn) < (train.trainlen or 0) + 2 do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) + while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.traintype) if conway then diff --git a/wagons.lua b/wagons.lua index 6b3780a..ca31590 100644 --- a/wagons.lua +++ b/wagons.lua @@ -416,7 +416,7 @@ function wagon:get_on(clicker, seatno) self:get_off(seatno) end self.seatp[seatno] = clicker:get_player_name() - advtrains.player_to_wagon_mapping[clicker:get_player_name()]={wagon=self, seatno=seatno} + advtrains.player_to_train_mapping[clicker:get_player_name()]=self.train_id clicker:set_attach(self.object, "", self.seats[seatno].attach_offset, {x=0,y=0,z=0}) clicker:set_eye_offset(self.seats[seatno].view_offset, self.seats[seatno].view_offset) end @@ -438,7 +438,7 @@ function wagon:get_off(seatno) if not self.seatp[seatno] then return end local pname = self.seatp[seatno] local clicker = minetest.get_player_by_name(pname) - advtrains.player_to_wagon_mapping[pname]=nil + advtrains.player_to_train_mapping[pname]=nil advtrains.clear_driver_hud(pname) if clicker then clicker:set_detach() -- cgit v1.2.3 From 0e185b9fb80285a4ca9f1a0ba15897b152632a67 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 13 Dec 2016 19:27:38 +0100 Subject: increase couple validity radius --- trainlogic.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/trainlogic.lua b/trainlogic.lua index 633024d..5e3936f 100644 --- a/trainlogic.lua +++ b/trainlogic.lua @@ -675,17 +675,18 @@ function advtrains.try_connect_trains(id1, id2) if not frontpos1 or not frontpos2 or not backpos1 or not backpos2 then return end + local couple_spawnradius=0.7 --case 1 (first train is front) - if vector.distance(frontpos2, backpos1)<0.5 then + if vector.distance(frontpos2, backpos1) Date: Tue, 13 Dec 2016 19:28:10 +0100 Subject: Implement better slope placement system Only look in the desired direction and place slope node on lowest slope part. will automatically adjust slope to next higher node. --- advtrains.zip | Bin 1484978 -> 1488682 bytes crafting.lua | 12 +-- textures/advtrains_dtrack_slopeplacer.png | Bin 0 -> 2415 bytes tracks.lua | 123 +++++++++++++++++++++++++++++- 4 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 textures/advtrains_dtrack_slopeplacer.png diff --git a/advtrains.zip b/advtrains.zip index 06da9f3..318fd14 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/crafting.lua b/crafting.lua index a54912c..dd43512 100644 --- a/crafting.lua +++ b/crafting.lua @@ -13,23 +13,13 @@ minetest.register_craft({ }) minetest.register_craft({ type = "shapeless", - output = 'advtrains:dtrack_vst1 2', + output = 'advtrains:dtrack_slopeplacer 2', recipe = { "advtrains:dtrack_placer", "advtrains:dtrack_placer", "default:gravel", }, }) -minetest.register_craft({ - type = "shapeless", - output = 'advtrains:dtrack_vst2 2', - recipe = { - "advtrains:dtrack_placer", - "advtrains:dtrack_placer", - "default:gravel", - "default:gravel", - }, -}) minetest.register_craft({ output = 'advtrains:dtrack_bumper_placer 2', diff --git a/textures/advtrains_dtrack_slopeplacer.png b/textures/advtrains_dtrack_slopeplacer.png new file mode 100644 index 0000000..1d456b0 Binary files /dev/null and b/textures/advtrains_dtrack_slopeplacer.png differ diff --git a/tracks.lua b/tracks.lua index 546216a..617266a 100644 --- a/tracks.lua +++ b/tracks.lua @@ -93,8 +93,22 @@ local t_30deg={ ["swlcr"]="swrcr", ["swlst"]="swrst", }, + regsp=true, + slopenodes={ + vst1=true, vst2=true, + vst31=true, vst32=true, vst33=true, + }, + slopeplacer={ + [2]={"vst1", "vst2"}, + [3]={"vst31", "vst32", "vst33"}, + max=3,--highest entry + }, + slopeplacer_45={ + [2]={"vst1_45", "vst2_45"}, + max=2, + }, rotation={"", "_30", "_45", "_60"}, - increativeinv={vst1=true, vst2=true, vst31=true, vst32=true, vst33=true}, + increativeinv={}, } local t_30deg_straightonly={ regstep=1, @@ -117,6 +131,7 @@ local t_30deg_straightonly={ trackworker={ ["st"]="st", }, + slopenodes={}, rotation={"", "_30", "_45", "_60"}, increativeinv={st}, } @@ -141,6 +156,7 @@ local t_30deg_straightonly_noplacer={ trackworker={ ["st"]="st", }, + slopenodes={}, rotation={"", "_30", "_45", "_60"}, increativeinv={st}, } @@ -195,6 +211,7 @@ local t_45deg={ ["swlcr"]="swrcr", ["swlst"]="swrst", }, + slopenodes={}, rotation={"", "_45"}, increativeinv={vst1=true, vst2=true} } @@ -226,7 +243,7 @@ function advtrains.register_tracks(tracktype, def, preset) rules=advtrains.meseconrules }} end - local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv) + local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv, drop_slope) local img_suffix=suffix..rotation return { mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix), @@ -248,7 +265,7 @@ function advtrains.register_tracks(tracktype, def, preset) not_blocking_trains=1, }, mesecons=mesecontbl, - drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or def.nodename_prefix.."_placer", + drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"), } end local function cycle_conns(conns, rotid) @@ -291,6 +308,9 @@ function advtrains.register_tracks(tracktype, def, preset) if preset.regtp then advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) end + if preset.regsp then + advtrains.slope.register_placer(def, preset) + end for suffix, conns in pairs(preset.variant) do for rotid, rotation in ipairs(preset.rotation) do if not def.formats[suffix] or def.formats[suffix][rotid] then @@ -308,7 +328,7 @@ function advtrains.register_tracks(tracktype, def, preset) make_overdef( suffix, rotation, cycle_conns(conns, rotid), - switchfunc, mesecontbl, preset.increativeinv[suffix] + switchfunc, mesecontbl, preset.increativeinv[suffix], preset.slopenodes[suffix] ), adef ) @@ -417,6 +437,101 @@ function advtrains.detector.call_leave_callback(pos, train_id) mregnode.advtrains.on_train_leave(pos, train_id) end end + +-- slope placer. Defined in register_tracks. +--crafted with rail and gravel +local sl={} +function sl.register_placer(def, preset) + minetest.register_craftitem(def.nodename_prefix.."_slopeplacer",{ + description = def.description.." Slope", + inventory_image = def.texture_prefix.."_slopeplacer.png", + wield_image = def.texture_prefix.."_slopeplacer.png", + groups={}, + on_place = sl.create_slopeplacer_on_place(def, preset) + }) +end +--(itemstack, placer, pointed_thing) +function sl.create_slopeplacer_on_place(def, preset) + return function(istack, player, pt) + if not pt.type=="node" then + minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") + return istack + end + local pos=pt.above + if not pos then + minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") + return istack + end + local node=minetest.get_node(pos) + if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to then + minetest.chat_send_player(player:get_player_name(), "Can't place: space occupied!") + return istack + end + if minetest.is_protected(pos, player:get_player_name()) then + minetest.chat_send_player(player:get_player_name(), "Can't place: protected position!") + return istack + end + --determine player orientation (only horizontal component) + --get_look_horizontal may not be available + local yaw=player.get_look_horizontal and player:get_look_horizontal() or player:get_look_yaw() + + --rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5. + dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)} + --translate to direction to look up inside the preset table + local param2, rot45=({ + [-1]={ + [-1]=2, + [0]=3, + [1]=3, + }, + [0]={ + [-1]=2, + [1]=0, + }, + [1]={ + [-1]=1, + [0]=1, + [1]=0, + }, + })[dirvec.x][dirvec.z], dirvec.x~=0 and dirvec.z~=0 + local lookup=preset.slopeplacer + if rot45 then lookup=preset.slopeplacer_45 end + + --go unitvector forward and look how far the next node is + local step=1 + while step<=lookup.max do + local node=minetest.get_node(vector.add(pos, dirvec)) + --next node solid? + if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then + --do slopes of this distance exist? + if lookup[step] then + if istack:get_count()>=step then + --start placing + local placenodes=lookup[step] + while step>0 do + minetest.set_node(pos, {name=def.nodename_prefix.."_"..placenodes[step], param2=param2}) + istack:take_item() + step=step-1 + pos=vector.subtract(pos, dirvec) + end + else + minetest.chat_send_player(player:get_player_name(), "Can't place: Not enough slope items left ("..step.." required)") + end + else + minetest.chat_send_player(player:get_player_name(), "Can't place: There's no slope of length "..step) + end + return istack + end + step=step+1 + pos=vector.add(pos, dirvec) + end + minetest.chat_send_player(player:get_player_name(), "Can't place: no supporting node at upper end.") + return itemstack + end +end + +advtrains.slope=sl + --END code, BEGIN definition --definition format: ([] optional) --[[{ -- cgit v1.2.3 From 6eea76a2ffad58628b0d8941e8d0ed34580a8876 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 13 Dec 2016 19:40:20 +0100 Subject: Don't decrease stack itemcount of slope placer in creative --- advtrains.zip | Bin 1488682 -> 1488715 bytes tracks.lua | 6 ++++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index 318fd14..6640cfc 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/tracks.lua b/tracks.lua index 617266a..bff88d3 100644 --- a/tracks.lua +++ b/tracks.lua @@ -505,12 +505,14 @@ function sl.create_slopeplacer_on_place(def, preset) if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then --do slopes of this distance exist? if lookup[step] then - if istack:get_count()>=step then + if minetest.setting_getbool("creative_mode") or istack:get_count()>=step then --start placing local placenodes=lookup[step] while step>0 do minetest.set_node(pos, {name=def.nodename_prefix.."_"..placenodes[step], param2=param2}) - istack:take_item() + if not minetest.setting_getbool("creative_mode") then + istack:take_item() + end step=step-1 pos=vector.subtract(pos, dirvec) end -- cgit v1.2.3 From 05ce694decc0653997f45fa4f9a24b40057dbd01 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 13 Dec 2016 19:49:28 +0100 Subject: =?UTF-8?q?Fix=20behavior=20when=20using=20get=5Flook=5Fyaw()=20in?= =?UTF-8?q?stead=20of=20get=5Flook=5Fhorizontal()=20get=5Flook=5Fyaw=20ret?= =?UTF-8?q?urns=20values=20that=20are=2090=C2=B0=20rotated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- advtrains.zip | Bin 1488715 -> 1488724 bytes tracks.lua | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/advtrains.zip b/advtrains.zip index 6640cfc..a3dab82 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/tracks.lua b/tracks.lua index bff88d3..99dbb27 100644 --- a/tracks.lua +++ b/tracks.lua @@ -473,7 +473,7 @@ function sl.create_slopeplacer_on_place(def, preset) end --determine player orientation (only horizontal component) --get_look_horizontal may not be available - local yaw=player.get_look_horizontal and player:get_look_horizontal() or player:get_look_yaw() + local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2) --rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5. dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)} -- cgit v1.2.3