00:00:00 2001 From: orwell96 Date: Sun, 29 May 2016 20:27:30 +0200 Subject: created git repository --- debugitems.lua | 138 +++++++++ debugitems.lua~ | 138 +++++++++ helpers.lua | 215 ++++++++++++++ helpers.lua~ | 215 ++++++++++++++ init.lua | 19 ++ init.lua~ | 19 ++ models/locomotive.b3d | Bin 0 -> 181112 bytes models/locomotive.blend | Bin 0 -> 459600 bytes models/magnet_track.blend | Bin 0 -> 516836 bytes models/newlocomotive.b3d | Bin 0 -> 181112 bytes models/newlocomotive.blend | Bin 0 -> 603376 bytes models/newlocomotive.blend1 | Bin 0 -> 603376 bytes models/newlocomotive_uvs.png | Bin 0 -> 175030 bytes models/newwagon.blend | Bin 0 -> 542188 bytes models/newwagon.blend1 | Bin 0 -> 550292 bytes models/newwagon.png | Bin 0 -> 108762 bytes models/trackplane.b3d | Bin 0 -> 262 bytes models/trackplane.blend | Bin 0 -> 462200 bytes models/trackvertical1.b3d | Bin 0 -> 629 bytes models/trackvertical1.blend | Bin 0 -> 453656 bytes models/trackvertical1.blend1 | Bin 0 -> 453344 bytes models/trackvertical1.png | Bin 0 -> 59146 bytes models/trackvertical2.b3d | Bin 0 -> 869 bytes models/trackvertical2.blend | Bin 0 -> 459216 bytes models/trackvertical2.png | Bin 0 -> 66755 bytes models/wagon.b3d | Bin 0 -> 107352 bytes pseudoload.lua | 121 ++++++++ pseudoload.lua~ | 121 ++++++++ readme.txt | 27 ++ readme.txt~ | 24 ++ textures/advtrains_newlocomotive.png | Bin 0 -> 1141133 bytes textures/advtrains_newlocomotive.xcf | Bin 0 -> 7462378 bytes textures/advtrains_trackworker.png | Bin 0 -> 328 bytes textures/advtrains_wagon.png | Bin 0 -> 1276341 bytes textures/black.png | Bin 0 -> 908 bytes textures/blue.png | Bin 0 -> 1200 bytes textures/drwho_screwdriver.png | Bin 0 -> 328 bytes textures/green.png | Bin 0 -> 1200 bytes textures/nope/track_curve.png | Bin 0 -> 527 bytes textures/nope/track_curve_45.png | Bin 0 -> 552 bytes textures/nope/track_std.png | Bin 0 -> 414 bytes textures/nope/track_std_45.png | Bin 0 -> 1378 bytes textures/nope/track_switch_l.png | Bin 0 -> 526 bytes textures/nope/track_switch_l_45.png | Bin 0 -> 1133 bytes textures/nope/track_switch_r.png | Bin 0 -> 491 bytes textures/nope/track_switch_r_45.png | Bin 0 -> 1140 bytes textures/red.png | Bin 0 -> 1199 bytes textures/track_cr.png | Bin 0 -> 1933 bytes textures/track_cr_45.png | Bin 0 -> 1945 bytes textures/track_curve_45.xcf | Bin 0 -> 13824 bytes textures/track_placer.png | Bin 0 -> 621 bytes textures/track_st.png | Bin 0 -> 621 bytes textures/track_st_45.png | Bin 0 -> 2549 bytes textures/track_swl_cr.png | Bin 0 -> 1868 bytes textures/track_swl_cr_45.png | Bin 0 -> 2512 bytes textures/track_swl_st.png | Bin 0 -> 1892 bytes textures/track_swl_st_45.png | Bin 0 -> 2509 bytes textures/track_swr_cr.png | Bin 0 -> 1897 bytes textures/track_swr_cr_45.png | Bin 0 -> 2528 bytes textures/track_swr_st.png | Bin 0 -> 1912 bytes textures/track_swr_st_45.png | Bin 0 -> 2485 bytes textures/track_vert1.png | Bin 0 -> 1777 bytes textures/track_vert2.png | Bin 0 -> 2012 bytes textures/yellow.png | Bin 0 -> 1199 bytes trackplacer.lua | 200 +++++++++++++ trackplacer.lua~ | 200 +++++++++++++ tracks.lua | 152 ++++++++++ tracks.lua~ | 150 ++++++++++ trainhud.lua | 56 ++++ trainhud.lua~ | 54 ++++ trainlogic.lua | 543 +++++++++++++++++++++++++++++++++++ trainlogic.lua~ | 542 ++++++++++++++++++++++++++++++++++ wagons.lua | 338 ++++++++++++++++++++++ wagons.lua~ | 336 ++++++++++++++++++++++ 74 files changed, 3608 insertions(+) create mode 100644 debugitems.lua create mode 100644 debugitems.lua~ create mode 100644 helpers.lua create mode 100644 helpers.lua~ create mode 100644 init.lua create mode 100644 init.lua~ create mode 100644 models/locomotive.b3d create mode 100644 models/locomotive.blend create mode 100644 models/magnet_track.blend create mode 100644 models/newlocomotive.b3d create mode 100644 models/newlocomotive.blend create mode 100644 models/newlocomotive.blend1 create mode 100644 models/newlocomotive_uvs.png create mode 100644 models/newwagon.blend create mode 100644 models/newwagon.blend1 create mode 100644 models/newwagon.png create mode 100644 models/trackplane.b3d create mode 100644 models/trackplane.blend create mode 100644 models/trackvertical1.b3d create mode 100644 models/trackvertical1.blend create mode 100644 models/trackvertical1.blend1 create mode 100644 models/trackvertical1.png create mode 100644 models/trackvertical2.b3d create mode 100644 models/trackvertical2.blend create mode 100644 models/trackvertical2.png create mode 100644 models/wagon.b3d create mode 100644 pseudoload.lua create mode 100644 pseudoload.lua~ create mode 100644 readme.txt create mode 100644 readme.txt~ create mode 100644 textures/advtrains_newlocomotive.png create mode 100644 textures/advtrains_newlocomotive.xcf create mode 100644 textures/advtrains_trackworker.png create mode 100644 textures/advtrains_wagon.png create mode 100644 textures/black.png create mode 100644 textures/blue.png create mode 100644 textures/drwho_screwdriver.png create mode 100644 textures/green.png create mode 100644 textures/nope/track_curve.png create mode 100644 textures/nope/track_curve_45.png create mode 100644 textures/nope/track_std.png create mode 100644 textures/nope/track_std_45.png create mode 100644 textures/nope/track_switch_l.png create mode 100644 textures/nope/track_switch_l_45.png create mode 100644 textures/nope/track_switch_r.png create mode 100644 textures/nope/track_switch_r_45.png create mode 100644 textures/red.png create mode 100644 textures/track_cr.png create mode 100644 textures/track_cr_45.png create mode 100644 textures/track_curve_45.xcf create mode 100644 textures/track_placer.png create mode 100644 textures/track_st.png create mode 100644 textures/track_st_45.png create mode 100644 textures/track_swl_cr.png create mode 100644 textures/track_swl_cr_45.png create mode 100644 textures/track_swl_st.png create mode 100644 textures/track_swl_st_45.png create mode 100644 textures/track_swr_cr.png create mode 100644 textures/track_swr_cr_45.png create mode 100644 textures/track_swr_st.png create mode 100644 textures/track_swr_st_45.png create mode 100644 textures/track_vert1.png create mode 100644 textures/track_vert2.png create mode 100644 textures/yellow.png create mode 100644 trackplacer.lua create mode 100644 trackplacer.lua~ create mode 100644 tracks.lua create mode 100644 tracks.lua~ create mode 100644 trainhud.lua create mode 100644 trainhud.lua~ create mode 100644 trainlogic.lua create mode 100644 trainlogic.lua~ create mode 100644 wagons.lua create mode 100644 wagons.lua~ diff --git a/debugitems.lua b/debugitems.lua new file mode 100644 index 0000000..89399d2 --- /dev/null +++ b/debugitems.lua @@ -0,0 +1,138 @@ + +minetest.register_tool("advtrains:1", + { + description = "1", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos1=pointed_thing.under +end, +}) +minetest.register_tool("advtrains:2", + { + description = "2", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos2=pointed_thing.under + end, +}) +minetest.register_tool("advtrains:3", + { + description = "3", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos3=pointed_thing.under + end, +}) +minetest.register_tool("advtrains:4", + { + description = "4", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos4=pointed_thing.under + end, +}) +core.register_chatcommand("mad", { + params="", + description="", + privs={}, + func = function(name, param) + return true, advtrains.get_wagon_yaw(pos1, pos2, pos3, pos4, tonumber(param))*360/(2*math.pi) +end, +}) + +advtrains.firstobject=nil +minetest.register_tool("advtrains:connect", +{ + description = "connect wagons tool", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + + on_place = function(itemstack, placer, pointed_thing) + + end, + --[[ + ^ Shall place item and return the leftover itemstack + ^ default: minetest.item_place ]] + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type=="object" then + local luaent=pointed_thing.ref:get_luaentity() + if luaent and luaent.is_wagon then + if advtrains.firstobject then + minetest.chat_send_all("connect second object "..luaent.unique_id) + advtrains.connect_wagons(luaent, advtrains.firstobject) + minetest.chat_send_all("done") + advtrains.firstobject=nil + else + advtrains.firstobject=luaent + minetest.chat_send_all("connect first object "..luaent.unique_id) + end + end + end + end, +--[[ +^ default: nil +^ Function must return either nil if no item shall be removed from +inventory, or an itemstack to replace the original itemstack. +e.g. itemstack:take_item(); return itemstack +^ Otherwise, the function is free to do what it wants. +^ The default functions handle regular use cases. +]] +}) +minetest.register_tool("advtrains:tttool", +{ + description = "traintester tool", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + + on_place = function(itemstack, placer, pointed_thing) + + end, + --[[ + ^ Shall place item and return the leftover itemstack + ^ default: minetest.item_place ]] + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type=="object" then + local luaent=pointed_thing.ref:get_luaentity() + if luaent and luaent.is_wagon then + minetest.chat_send_all("wagon yaw is "..pointed_thing.ref:getyaw()) + minetest.chat_send_all("trains last yaw is set to "..luaent:train().last_front_yaw) + minetest.chat_send_all("end report") + end + else + minetest.chat_send_all(dump(minetest.get_node(pointed_thing.under))) + local c1, c2=advtrains.get_track_connections(minetest.get_node(pointed_thing.under).name, minetest.get_node(pointed_thing.under).param2) + minetest.chat_send_all(c1.." <-> "..c2) + end + end, +--[[ +^ default: nil +^ Function must return either nil if no item shall be removed from +inventory, or an itemstack to replace the original itemstack. +e.g. itemstack:take_item(); return itemstack +^ Otherwise, the function is free to do what it wants. +^ The default functions handle regular use cases. +]] +} +) diff --git a/debugitems.lua~ b/debugitems.lua~ new file mode 100644 index 0000000..7de1a0f --- /dev/null +++ b/debugitems.lua~ @@ -0,0 +1,138 @@ + +minetest.register_tool("advtrains:1", + { + description = "1", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos1=pointed_thing.under +end, +}) +minetest.register_tool("advtrains:2", + { + description = "2", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos2=pointed_thing.under + end, +}) +minetest.register_tool("advtrains:3", + { + description = "3", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos3=pointed_thing.under + end, +}) +minetest.register_tool("advtrains:4", + { + description = "4", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + on_use = function(itemstack, user, pointed_thing) + pos4=pointed_thing.under + end, +}) +core.register_chatcommand("mad", { + params="", + description="", + privs={}, + func = function(name, param) + return true, advtrains.get_wagon_yaw(pos1, pos2, pos3, pos4, tonumber(param))*2*math.pi/360 +end, +}) + +advtrains.firstobject=nil +minetest.register_tool("advtrains:connect", +{ + description = "connect wagons tool", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + + on_place = function(itemstack, placer, pointed_thing) + + end, + --[[ + ^ Shall place item and return the leftover itemstack + ^ default: minetest.item_place ]] + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type=="object" then + local luaent=pointed_thing.ref:get_luaentity() + if luaent and luaent.is_wagon then + if advtrains.firstobject then + minetest.chat_send_all("connect second object "..luaent.unique_id) + advtrains.connect_wagons(luaent, advtrains.firstobject) + minetest.chat_send_all("done") + advtrains.firstobject=nil + else + advtrains.firstobject=luaent + minetest.chat_send_all("connect first object "..luaent.unique_id) + end + end + end + end, +--[[ +^ default: nil +^ Function must return either nil if no item shall be removed from +inventory, or an itemstack to replace the original itemstack. +e.g. itemstack:take_item(); return itemstack +^ Otherwise, the function is free to do what it wants. +^ The default functions handle regular use cases. +]] +}) +minetest.register_tool("advtrains:tttool", +{ + description = "traintester tool", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + + on_place = function(itemstack, placer, pointed_thing) + + end, + --[[ + ^ Shall place item and return the leftover itemstack + ^ default: minetest.item_place ]] + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type=="object" then + local luaent=pointed_thing.ref:get_luaentity() + if luaent and luaent.is_wagon then + minetest.chat_send_all("wagon yaw is "..pointed_thing.ref:getyaw()) + minetest.chat_send_all("trains last yaw is set to "..luaent:train().last_front_yaw) + minetest.chat_send_all("end report") + end + else + minetest.chat_send_all(dump(minetest.get_node(pointed_thing.under))) + local c1, c2=advtrains.get_track_connections(minetest.get_node(pointed_thing.under).name, minetest.get_node(pointed_thing.under).param2) + minetest.chat_send_all(c1.." <-> "..c2) + end + end, +--[[ +^ default: nil +^ Function must return either nil if no item shall be removed from +inventory, or an itemstack to replace the original itemstack. +e.g. itemstack:take_item(); return itemstack +^ Otherwise, the function is free to do what it wants. +^ The default functions handle regular use cases. +]] +} +) diff --git a/helpers.lua b/helpers.lua new file mode 100644 index 0000000..02367d8 --- /dev/null +++ b/helpers.lua @@ -0,0 +1,215 @@ +--advtrains by orwell96, see readme.txt +local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end + +function advtrains.dirCoordSet(coord, dir) + local x=0 + local z=0 + --local dir=(dirx+2)%8 + if(dir==6) then + x=-1 + elseif (dir==7) then + x=-1 + z=1 + elseif (dir==0) then + z=1 + elseif (dir==1) then + z=1 + x=1 + elseif (dir==2) then + x=1 + elseif (dir==3) then + x=1 + z=-1 + elseif (dir==4) then + z=-1 + elseif (dir==5) then + z=-1 + x=-1 + else + error("advtrains: in helpers.lua/dirCoordSet() given dir="..(dir or "nil")) + end + + + return {x=coord.x+x, y=coord.y, z=coord.z+z} +end +function advtrains.dirToCoord(dir) + return advtrains.dirCoordSet({x=0, y=0, z=0}, dir) +end + +function advtrains.maxN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n+1 + end + return n-1 +end + +function advtrains.minN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n-1 + end + return n+1 +end + +--vertical_transmit: +--[[ +rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node + +]] + +function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return + local mid=advtrains.round_vector_floor_y(midreal) + if(not advtrains.is_track_and_drives_on(minetest.get_node(mid).name, drives_on)) then + --print("[advtrains]in conway: no rail, returning!") + return nil + end + if(not prev or not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.round_vector_floor_y(prev)).name, drives_on)) then + --print("[advtrains]in conway: no prev rail, there should be an initial path!, returning!") + return nil + end + local midnode=minetest.get_node_or_nil(mid) + if not midnode then --print("[advtrains][conway] midnode is ignore") + return nil + end + + local middir1, middir2, midrely1, midrely2=advtrains.get_track_connections(midnode.name, midnode.param2) + + local next, chkdir, chkrely, y_offset + y_offset=0 + --print("[advtrains] in order mid1,mid2",middir1,middir2) + --try if it is dir1 + local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< + if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous + next=advtrains.dirCoordSet(mid, middir1) + if midrely1>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir1 + chkrely=midrely1 + --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --dir2??? + local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< + if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then + next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. + if midrely2>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir2 + chkrely=midrely2 + --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + --is there a next + if not next then + print("[advtrains]in conway: no next rail(nil), returning!") + return nil + end + local nextnode=minetest.get_node_or_nil(advtrains.round_vector_floor_y(next)) + if not nextnode then print("[advtrains][conway] nextnode is ignore") + return nil + end + + --is it a rail? + if(not advtrains.is_track_and_drives_on(nextnode.name, drives_on)) then + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextnode=minetest.get_node_or_nil(advtrains.round_vector_floor_y(next)) + if not nextnode then --print("[advtrains][conway] nextnode is ignore") + return nil + end + if(not advtrains.is_track_and_drives_on(nextnode.name, drives_on)) then + print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + return nil + end + end + --print("[advtrains]trying to find if rail connects: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + + local nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_track_connections(nextnode.name, nextnode.param2) + + --is this next rail connecting to the mid? + if not ( (((nextdir1+4)%8)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+4)%8)==chkdir and nextrely2==chkrely-y_offset) ) then + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_track_connections(nextnode.name, nextnode.param2) + if not ( (((nextdir1+4)%8)==chkdir and nextrely1==chkrely) or (((nextdir2+4)%8)==chkdir and nextrely2==chkrely) ) then + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." rail not connecting, returning!") + --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + return nil + end + end + + --print("[advtrains]conway found rail.") + return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir +end + +function advtrains.round_vector_floor_y(vec) + return {x=math.floor(vec.x+0.5), y=math.floor(vec.y), z=math.floor(vec.z+0.5)} +end + +function advtrains.yawToDirection(yaw, conn1, conn2) + if not conn1 or not conn2 then + error("given nil to yawToDirection: conn1="..(conn1 or "nil").." conn2="..(conn1 or "nil")) + end + local yaw1=math.pi*(conn1/4) + local yaw2=math.pi*(conn2/4) + if advtrains.minAngleDiffRad(yaw, yaw1) if weird behavior + return conn2 + else + return conn1 + end +end + +function advtrains.minAngleDiffRad(r1, r2) + local try1=r2-r1 + local try2=(r2+2*math.pi)-r1 + local try3=r2-(r1+2*math.pi) + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try1) then + return try1 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try2) then + return try2 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try3) then + return try3 + end +end +function advtrains.dumppath(path) + if not path then print("dumppath: no path(nil)") return end + local min=advtrains.minN(path) + local max=advtrains.maxN(path) + for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end +end + +function advtrains.merge_tables(a, ...) + local new={} + for _,t in ipairs({a,...}) do + for k,v in pairs(t) do new[k]=v end + end + return new +end +function advtrains.yaw_from_3_positions(prev, curr, next) + local pts=minetest.pos_to_string + --print("p3 "..pts(prev)..pts(curr)..pts(next)) + local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) + local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) + --print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) + return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) +end +function advtrains.get_wagon_yaw(front, first, second, back, pct) + local pts=minetest.pos_to_string + --print("p "..pts(front)..pts(first)..pts(second)..pts(back)) + local y2=advtrains.yaw_from_3_positions(second, first, front) + local y1=advtrains.yaw_from_3_positions(back, second, first) + --print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) + return y1+advtrains.minAngleDiffRad(y1, y2)*pct +end diff --git a/helpers.lua~ b/helpers.lua~ new file mode 100644 index 0000000..aa48584 --- /dev/null +++ b/helpers.lua~ @@ -0,0 +1,215 @@ +--advtrains by orwell96, see readme.txt +local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end + +function advtrains.dirCoordSet(coord, dir) + local x=0 + local z=0 + --local dir=(dirx+2)%8 + if(dir==6) then + x=-1 + elseif (dir==7) then + x=-1 + z=1 + elseif (dir==0) then + z=1 + elseif (dir==1) then + z=1 + x=1 + elseif (dir==2) then + x=1 + elseif (dir==3) then + x=1 + z=-1 + elseif (dir==4) then + z=-1 + elseif (dir==5) then + z=-1 + x=-1 + else + error("advtrains: in helpers.lua/dirCoordSet() given dir="..(dir or "nil")) + end + + + return {x=coord.x+x, y=coord.y, z=coord.z+z} +end +function advtrains.dirToCoord(dir) + return advtrains.dirCoordSet({x=0, y=0, z=0}, dir) +end + +function advtrains.maxN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n+1 + end + return n-1 +end + +function advtrains.minN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n-1 + end + return n+1 +end + +--vertical_transmit: +--[[ +rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node + +]] + +function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return + local mid=advtrains.round_vector_floor_y(midreal) + if(not advtrains.is_track_and_drives_on(minetest.get_node(mid).name, drives_on)) then + --print("[advtrains]in conway: no rail, returning!") + return nil + end + if(not prev or not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.round_vector_floor_y(prev)).name, drives_on)) then + --print("[advtrains]in conway: no prev rail, there should be an initial path!, returning!") + return nil + end + local midnode=minetest.get_node_or_nil(mid) + if not midnode then --print("[advtrains][conway] midnode is ignore") + return nil + end + + local middir1, middir2, midrely1, midrely2=advtrains.get_track_connections(midnode.name, midnode.param2) + + local next, chkdir, chkrely, y_offset + y_offset=0 + --print("[advtrains] in order mid1,mid2",middir1,middir2) + --try if it is dir1 + local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< + if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous + next=advtrains.dirCoordSet(mid, middir1) + if midrely1>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir1 + chkrely=midrely1 + --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --dir2??? + local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< + if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then + next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. + if midrely2>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir2 + chkrely=midrely2 + --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + --is there a next + if not next then + print("[advtrains]in conway: no next rail(nil), returning!") + return nil + end + local nextnode=minetest.get_node_or_nil(advtrains.round_vector_floor_y(next)) + if not nextnode then print("[advtrains][conway] nextnode is ignore") + return nil + end + + --is it a rail? + if(not advtrains.is_track_and_drives_on(nextnode.name, drives_on)) then + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextnode=minetest.get_node_or_nil(advtrains.round_vector_floor_y(next)) + if not nextnode then --print("[advtrains][conway] nextnode is ignore") + return nil + end + if(not advtrains.is_track_and_drives_on(nextnode.name, drives_on)) then + print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + return nil + end + end + --print("[advtrains]trying to find if rail connects: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + + local nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_track_connections(nextnode.name, nextnode.param2) + + --is this next rail connecting to the mid? + if not ( (((nextdir1+4)%8)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+4)%8)==chkdir and nextrely2==chkrely-y_offset) ) then + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_track_connections(nextnode.name, nextnode.param2) + if not ( (((nextdir1+4)%8)==chkdir and nextrely1==chkrely) or (((nextdir2+4)%8)==chkdir and nextrely2==chkrely) ) then + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." rail not connecting, returning!") + --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + return nil + end + end + + --print("[advtrains]conway found rail.") + return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir +end + +function advtrains.round_vector_floor_y(vec) + return {x=math.floor(vec.x+0.5), y=math.floor(vec.y), z=math.floor(vec.z+0.5)} +end + +function advtrains.yawToDirection(yaw, conn1, conn2) + if not conn1 or not conn2 then + error("given nil to yawToDirection: conn1="..(conn1 or "nil").." conn2="..(conn1 or "nil")) + end + local yaw1=math.pi*(conn1/4) + local yaw2=math.pi*(conn2/4) + if advtrains.minAngleDiffRad(yaw, yaw1) if weird behavior + return conn2 + else + return conn1 + end +end + +function advtrains.minAngleDiffRad(r1, r2) + local try1=r2-r1 + local try2=(r2+2*math.pi)-r1 + local try3=r2-(r1+2*math.pi) + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try1) then + return try1 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try2) then + return try2 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try3) then + return try3 + end +end +function advtrains.dumppath(path) + if not path then print("dumppath: no path(nil)") return end + local min=advtrains.minN(path) + local max=advtrains.maxN(path) + for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end +end + +function advtrains.merge_tables(a, ...) + local new={} + for _,t in ipairs({a,...}) do + for k,v in pairs(t) do new[k]=v end + end + return new +end +function advtrains.yaw_from_3_positions(prev, curr, next) + local pts=minetest.pos_to_string + print("p3 "..pts(prev)..pts(curr)..pts(next)) + local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) + local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) + print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) + return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) +end +function advtrains.get_wagon_yaw(front, first, second, back, pct) + local pts=minetest.pos_to_string + print("p "..pts(front)..pts(first)..pts(second)..pts(back)) + local y2=advtrains.yaw_from_3_positions(second, first, front) + local y1=advtrains.yaw_from_3_positions(back, second, first) + print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) + return y1+advtrains.minAngleDiffRad(y1, y2)*pct +end diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..bc3b366 --- /dev/null +++ b/init.lua @@ -0,0 +1,19 @@ +--advtrains + +advtrains={} + +advtrains.modpath = minetest.get_modpath("advtrains") + +print=function(text) + minetest.log("action", tostring(text) or "") +end + + +dofile(advtrains.modpath.."/helpers.lua"); +dofile(advtrains.modpath.."/debugitems.lua"); + +dofile(advtrains.modpath.."/trainlogic.lua"); +dofile(advtrains.modpath.."/trainhud.lua") +dofile(advtrains.modpath.."/trackplacer.lua") +dofile(advtrains.modpath.."/tracks.lua") +dofile(advtrains.modpath.."/wagons.lua") diff --git a/init.lua~ b/init.lua~ new file mode 100644 index 0000000..63856a5 --- /dev/null +++ b/init.lua~ @@ -0,0 +1,19 @@ +--advtrains + +advtrains={} + +advtrains.modpath = minetest.get_modpath("advtrains") + +print=function(text) + minetest.log("action", tostring(text) or "") +end + + +dofile(advtrains.modpath.."/helpers.lua"); +dofile(advtrains.modpath.."/debugitems.lua"); + +dofile(advtrains.modpath.."/trainlogic.lua"); +dofile(advtrains.modpath.."/trainhud.lua") +dofile(advtrains.modpath.."/trackplacer.lua") +dofile(advtrains.modpath.."/tracks.lua") +dofile(advtrains.modpath.."/vehicles.lua") diff --git a/models/locomotive.b3d b/models/locomotive.b3d new file mode 100644 index 0000000..5e16be3 Binary files /dev/null and b/models/locomotive.b3d differ diff --git a/models/locomotive.blend b/models/locomotive.blend new file mode 100644 index 0000000..8fd6059 Binary files /dev/null and b/models/locomotive.blend differ diff --git a/models/magnet_track.blend b/models/magnet_track.blend new file mode 100644 index 0000000..0ab14e7 Binary files /dev/null and b/models/magnet_track.blend differ diff --git a/models/newlocomotive.b3d b/models/newlocomotive.b3d new file mode 100644 index 0000000..da36222 Binary files /dev/null and b/models/newlocomotive.b3d differ diff --git a/models/newlocomotive.blend b/models/newlocomotive.blend new file mode 100644 index 0000000..858882b Binary files /dev/null and b/models/newlocomotive.blend differ diff --git a/models/newlocomotive.blend1 b/models/newlocomotive.blend1 new file mode 100644 index 0000000..4b8b24f Binary files /dev/null and b/models/newlocomotive.blend1 differ diff --git a/models/newlocomotive_uvs.png b/models/newlocomotive_uvs.png new file mode 100644 index 0000000..879be65 Binary files /dev/null and b/models/newlocomotive_uvs.png differ diff --git a/models/newwagon.blend b/models/newwagon.blend new file mode 100644 index 0000000..1cedc55 Binary files /dev/null and b/models/newwagon.blend differ diff --git a/models/newwagon.blend1 b/models/newwagon.blend1 new file mode 100644 index 0000000..eb30fde Binary files /dev/null and b/models/newwagon.blend1 differ diff --git a/models/newwagon.png b/models/newwagon.png new file mode 100644 index 0000000..812bc32 Binary files /dev/null and b/models/newwagon.png differ diff --git a/models/trackplane.b3d b/models/trackplane.b3d new file mode 100644 index 0000000..b4728c3 Binary files /dev/null and b/models/trackplane.b3d differ diff --git a/models/trackplane.blend b/models/trackplane.blend new file mode 100644 index 0000000..79365f7 Binary files /dev/null and b/models/trackplane.blend differ diff --git a/models/trackvertical1.b3d b/models/trackvertical1.b3d new file mode 100644 index 0000000..5620f60 Binary files /dev/null and b/models/trackvertical1.b3d differ diff --git a/models/trackvertical1.blend b/models/trackvertical1.blend new file mode 100644 index 0000000..fca6742 Binary files /dev/null and b/models/trackvertical1.blend differ diff --git a/models/trackvertical1.blend1 b/models/trackvertical1.blend1 new file mode 100644 index 0000000..b146b56 Binary files /dev/null and b/models/trackvertical1.blend1 differ diff --git a/models/trackvertical1.png b/models/trackvertical1.png new file mode 100644 index 0000000..a998dcb Binary files /dev/null and b/models/trackvertical1.png differ diff --git a/models/trackvertical2.b3d b/models/trackvertical2.b3d new file mode 100644 index 0000000..22dbb20 Binary files /dev/null and b/models/trackvertical2.b3d differ diff --git a/models/trackvertical2.blend b/models/trackvertical2.blend new file mode 100644 index 0000000..a066b84 Binary files /dev/null and b/models/trackvertical2.blend differ diff --git a/models/trackvertical2.png b/models/trackvertical2.png new file mode 100644 index 0000000..43142f9 Binary files /dev/null and b/models/trackvertical2.png differ diff --git a/models/wagon.b3d b/models/wagon.b3d new file mode 100644 index 0000000..5c8214c Binary files /dev/null and b/models/wagon.b3d differ diff --git a/pseudoload.lua b/pseudoload.lua new file mode 100644 index 0000000..532b429 --- /dev/null +++ b/pseudoload.lua @@ -0,0 +1,121 @@ + +--pseudoload.lua +--responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. + +advtrains.trackdb={} +--trackdb[y][x][z]={conn1, conn2, rely1, rely2, railheight} +--serialization format: +--(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n +--[] may be missing if 0,0,0 + +--load initially +advtrains.pl_fpath=minetest.get_worldpath().."/advtrains_trackdb" +local file, err = io.open(advtrains.pl_fpath, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains trackdb save file "..er) +else + --custom format to save memory + while true do + local xbytes=file:read(2) + if not xbytes then + break --eof reached + end + local ybytes=file:read(2) + local zbytes=file:read(2) + local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) + local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) + local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) + + local conn1=string.byte(file:read(1)) + local conn1=string.byte(file:read(1)) + + if not advtrains.trackdb[y] then advtrains.trackdb[y]={} end + if not advtrains.trackdb[y][x] then advtrains.trackdb[y][x]={} end + + local rest=file.read("*l") + if rest~="" then + local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") + if rely1 and rely2 and railheight then + advtrains.trackdb[y][x][z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + else + advtrains.trackdb[y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + else + advtrains.trackdb[y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + end + file:close() +end +function advtrains.save_trackdb() + local file, err = io.open(advtrains.pl_fpath, "w") + if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed saving advtrains trackdb save file "..er) + else + --custom format to save memory + for x,txl in pairs(advtrains.trackdb) do + for y,tyl in pairs(txl) do + for z,rail in pairs(tyl) do + file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) + file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) + file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) + file:write(string.char(rail.conn1)) + file:write(string.char(rail.conn2)) + if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then + file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) + end + file:write("\n") + end + end + end + file:close() + end +end + +--get_node with pseudoload. +--returns: +--true, conn1, conn2, rely1, rely2, railheight in case everything's right. +--false if it's not a rail or the train does not drive on this rail, but it is loaded or +--nil if the node is neither loaded nor in trackdb +--the distraction between false and nil will be needed only in special cases.(train initpos) +function advtrains.get_rail_info_at(pos, traintype) + local node=minetest.get_node_or_nil(pos) + if not node then + --try raildb + local rdp=vector.round(rdp) + local dbe=advtrains.trackdb[rdp.y][rdp.x][rdp.z] + if dbe then + return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + else + return nil + end + end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then + return false + end + local conn1, conn2, rely1, rely2, railheight=advtrains.get_track_connections(node.name, node.param2) + + --already in trackdb? + local rdp=vector.round(rdp) + if not advtrains.trackdb[rdp.y][rdp.x][rdp.z] then--TODO is this write prevention here really needed? + advtrains.trackdb[rdp.y][rdp.x][rdp.z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + end + + return true, conn1, conn2, rely1, rely2, railheight +end + + diff --git a/pseudoload.lua~ b/pseudoload.lua~ new file mode 100644 index 0000000..6b04dda --- /dev/null +++ b/pseudoload.lua~ @@ -0,0 +1,121 @@ + +--pseudoload.lua +--responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. + +advtrains.trackdb={} +--trackdb[y][x][z]={conn1, conn2, rely1, rely2, railheight} +--serialization format: +--(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n +--[] may be missing if 0,0,0 + +--load initially +advtrains.pl_fpath=minetest.get_worldpath().."/advtrains_trackdb" +local file, err = io.open(advtrains.pl_fpath, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains trackdb save file "..er) +else + --custom format to save memory + while true do + local xbytes=file:read(2) + if not xbytes then + break --eof reached + end + local ybytes=file:read(2) + local zbytes=file:read(2) + local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) + local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) + local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) + + local conn1=string.byte(file:read(1)) + local conn1=string.byte(file:read(1)) + + if not advtrains.trackdb[y] then advtrains.trackdb[y]={} end + if not advtrains.trackdb[y][x] then advtrains.trackdb[y][x]={} end + + local rest=file.read("*l") + if rest~="" then + local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") + if rely1 and rely2 and railheight then + advtrains.trackdb[y][x][z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + else + advtrains.trackdb[y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + else + advtrains.trackdb[y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + end + file:close() +end +function advtrains.save_trackdb() + local file, err = io.open(advtrains.pl_fpath, "w") + if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed saving advtrains trackdb save file "..er) + else + --custom format to save memory + for x,txl in pairs(advtrains.trackdb) do + for y,tyl in pairs(txl) do + for z,rail in pairs(tyl) do + file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) + file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) + file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) + file:write(string.char(rail.conn1)) + file:write(string.char(rail.conn2)) + if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then + file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) + end + file:write("\n") + end + end + end + file:close() + end +end + +--get_node with pseudoload. +--returns: +--true, conn1, conn2, rely1, rely2, railheight in case everything's right. +--false if it's not a rail or the train does not drive on this rail, but it is loaded or +--nil if the node is neither loaded nor in trackdb +--the distraction between false and nil will be needed only in special cases.(train initpos) +function advtrains.get_rail_at(pos, traintype) + local node=minetest.get_node_or_nil(pos) + if not node then + --try raildb + local rdp=vector.round(rdp) + local dbe=advtrains.trackdb[rdp.y][rdp.x][rdp.z] + if dbe then + return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + else + return nil + end + end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then + return false + end + local conn1, conn2, rely1, rely2, railheight=advtrains.get_track_connections(node.name, node.param2) + + --already in trackdb? + local rdp=vector.round(rdp) + if not advtrains.trackdb[rdp.y][rdp.x][rdp.z] then--TODO is this write prevention here really needed? + advtrains.trackdb[rdp.y][rdp.x][rdp.z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + end + + return true, conn1, conn2, rely1, rely2, railheight +end + + diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..944fa95 --- /dev/null +++ b/readme.txt @@ -0,0 +1,27 @@ +Hi +Since there are no trains mods out there that satisfied my needs, I decided to write my own. +Until now are supported: +- tracks and switches, based on angles of 45 degrees +- wagons (atm they all look like very simple locomotives in different colors) that drive on these rails and collide with nodes in the environment(they need 3x3x3 space) +- conecting/disconnecting of wagons/trains +Planned features: +- trains will only move if a locomotive is in train +- locomotives need coal to drive (and water...) +- more types of trains and rails(electric, diesel, maglevs...) +- better controls +- cool models for trains and rails +- an API, because API's are cool. +(I will probably split trains api and actual trains into two mods, to allow for extensions to be enabled individually) + +At the moment, you can try around with the trains. There are some debug messages that shouldn't disturb you. Note that anything may change in future releases. +- Use the Track(placer) item to place tracks. In most cases it will adjust rails in the direction you need them. +- use the trackworker tool to rotate tracks(right-click) and to change normal rails into switches(left-click) +- to overcome heights you need the rails with the strange gravel texture in the background, place them and you will understand. +- place any of the wagons in different colors by picking the item and placing it on a track. +- right-click a wagon to sit onto it. +- right-click a wagon while holding W / S to accelerate/decelerate the train. This will fail if the train can't move in the desired direction. +- drive two trains together and they will connect automatically. +- right-click a wagon while holding sneak key to split a train at this wagon +- right-click a wagon while holding aux1 to print useful(TM) information to the console + +Have fun! \ No newline at end of file diff --git a/readme.txt~ b/readme.txt~ new file mode 100644 index 0000000..2f0601e --- /dev/null +++ b/readme.txt~ @@ -0,0 +1,24 @@ +Hi +Since there are no trains mods out there that satisfied my needs, I decided to write my own. +Until now are supported: +- tracks and switches, based on angles of 45 degrees +- wagons (atm they all look like very simple locomotives in different colors) that drive on these rails and collide with nodes in the environment(they need 3x3x3 space) +- conecting/disconnecting of wagons/trains +Planned features: +- trains will only move if a locomotive is in train +- locomotives need coal to drive (and water...) +- more types of trains and rails(electric, diesel, maglevs...) +- better controls +- cool models for trains and rails + +At the moment, you can try around with the trains. There are some debug messages that shouldn't disturb you. Note that anything may change in future releases. +- Use the Track(placer) item to place tracks. In most cases it will adjust rails in the direction you need them. +- use the trackworker tool to rotate tracks(right-click) and to change normal rails into switches(left-click) +- place any of the wagons in different colors by picking the item and placing it on a track. +- right-click a wagon to sit onto it. +- right-click a wagon while holding W / S to accelerate/decelerate the train. This will fail if the train can't move in the desired direction. +- drive two trains together and they will connect automatically. +- right-click a wagon while holding sneak key to split a train at this wagon +- right-click a wagon while holding aux1 to print useful(TM) information to the console + +Have fun! \ No newline at end of file diff --git a/textures/advtrains_newlocomotive.png b/textures/advtrains_newlocomotive.png new file mode 100644 index 0000000..fcc1a3d Binary files /dev/null and b/textures/advtrains_newlocomotive.png differ diff --git a/textures/advtrains_newlocomotive.xcf b/textures/advtrains_newlocomotive.xcf new file mode 100644 index 0000000..9ad5187 Binary files /dev/null and b/textures/advtrains_newlocomotive.xcf differ diff --git a/textures/advtrains_trackworker.png b/textures/advtrains_trackworker.png new file mode 100644 index 0000000..b50bcae Binary files /dev/null and b/textures/advtrains_trackworker.png differ diff --git a/textures/advtrains_wagon.png b/textures/advtrains_wagon.png new file mode 100644 index 0000000..ee836a8 Binary files /dev/null and b/textures/advtrains_wagon.png differ diff --git a/textures/black.png b/textures/black.png new file mode 100644 index 0000000..a1d3eb7 Binary files /dev/null and b/textures/black.png differ diff --git a/textures/blue.png b/textures/blue.png new file mode 100644 index 0000000..b1a03a7 Binary files /dev/null and b/textures/blue.png differ diff --git a/textures/drwho_screwdriver.png b/textures/drwho_screwdriver.png new file mode 100644 index 0000000..b50bcae Binary files /dev/null and b/textures/drwho_screwdriver.png differ diff --git a/textures/green.png b/textures/green.png new file mode 100644 index 0000000..5717393 Binary files /dev/null and b/textures/green.png differ diff --git a/textures/nope/track_curve.png b/textures/nope/track_curve.png new file mode 100644 index 0000000..02bcf5c Binary files /dev/null and b/textures/nope/track_curve.png differ diff --git a/textures/nope/track_curve_45.png b/textures/nope/track_curve_45.png new file mode 100644 index 0000000..c69be2d Binary files /dev/null and b/textures/nope/track_curve_45.png differ diff --git a/textures/nope/track_std.png b/textures/nope/track_std.png new file mode 100644 index 0000000..061949e Binary files /dev/null and b/textures/nope/track_std.png differ diff --git a/textures/nope/track_std_45.png b/textures/nope/track_std_45.png new file mode 100644 index 0000000..89a1b36 Binary files /dev/null and b/textures/nope/track_std_45.png differ diff --git a/textures/nope/track_switch_l.png b/textures/nope/track_switch_l.png new file mode 100644 index 0000000..33ac21e Binary files /dev/null and b/textures/nope/track_switch_l.png differ diff --git a/textures/nope/track_switch_l_45.png b/textures/nope/track_switch_l_45.png new file mode 100644 index 0000000..d55da42 Binary files /dev/null and b/textures/nope/track_switch_l_45.png differ diff --git a/textures/nope/track_switch_r.png b/textures/nope/track_switch_r.png new file mode 100644 index 0000000..bf2e722 Binary files /dev/null and b/textures/nope/track_switch_r.png differ diff --git a/textures/nope/track_switch_r_45.png b/textures/nope/track_switch_r_45.png new file mode 100644 index 0000000..5be48fd Binary files /dev/null and b/textures/nope/track_switch_r_45.png differ diff --git a/textures/red.png b/textures/red.png new file mode 100644 index 0000000..ccf1c78 Binary files /dev/null and b/textures/red.png differ diff --git a/textures/track_cr.png b/textures/track_cr.png new file mode 100644 index 0000000..54ddf79 Binary files /dev/null and b/textures/track_