aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
ModeNameSize
-rw-r--r--CMakeLists.txt1476logplain
-rw-r--r--l_areastore.cpp9064logplain
-rw-r--r--l_areastore.h1764logplain
-rw-r--r--l_auth.cpp5592logplain
-rw-r--r--l_auth.h1497logplain
-rw-r--r--l_base.cpp4680logplain
-rw-r--r--l_base.h2394logplain
-rw-r--r--l_camera.cpp5460logplain
-rw-r--r--l_camera.h1730logplain
-rw-r--r--l_client.cpp9389logplain
-rw-r--r--l_client.h2557logplain
-rw-r--r--l_craft.cpp14300logplain
-rw-r--r--l_craft.h1583logplain
-rw-r--r--l_env.cpp33297logplain
-rw-r--r--l_env.h8323logplain
-rw-r--r--l_http.cpp5705logplain
-rw-r--r--l_http.h1486logplain
-rw-r--r--l_internal.h1870logplain
-rw-r--r--l_inventory.cpp13929logplain
-rw-r--r--l_inventory.h3798logplain
-rw-r--r--l_item.cpp16203logplain
-rw-r--r--l_item.h4438logplain
-rw-r--r--l_itemstackmeta.cpp3925logplain
-rw-r--r--l_itemstackmeta.h2007logplain
-rw-r--r--l_localplayer.cpp10034logplain
-rw-r--r--l_localplayer.h2666logplain
-rw-r--r--l_mainmenu.cpp29339logplain
-rw-r--r--l_mainmenu.h4044logplain
-rw-r--r--l_mapgen.cpp45669logplain
-rw-r--r--l_mapgen.h4594logplain
-rw-r--r--l_metadata.cpp6930logplain
-rw-r--r--l_metadata.h2134logplain
-rw-r--r--l_minimap.cpp5210logplain
-rw-r--r--l_minimap.h1673logplain
-rw-r--r--l_modchannels.cpp3863logplain
-rw-r--r--l_modchannels.h1749logplain
-rw-r--r--l_nodemeta.cpp7263logplain
-rw-r--r--l_nodemeta.h3083logplain
-rw-r--r--l_nodetimer.cpp4426logplain
-rw-r--r--l_nodetimer.h1729logplain
-rw-r--r--l_noise.cpp15750logplain
-rw-r--r--l_noise.h4547logplain
-rw-r--r--l_object.cpp49281logplain
-rw-r--r--l_object.h9551logplain
-rw-r--r--l_particles.cpp8704logplain
-rw-r--r--l_particles.h1084logplain
-rw-r--r--l_particles_local.cpp7224logplain
-rw-r--r--l_particles_local.h1123logplain
-rw-r--r--l_playermeta.cpp3334logplain
-rw-r--r--l_playermeta.h1735logplain
-rw-r--r--l_rollback.cpp3552logplain
-rw-r--r--l_rollback.h1219logplain
-rw-r--r--l_server.cpp13913logplain
-rw-r--r--l_server.h2974logplain
-rw-r--r--l_settings.cpp7522logplain
-rw-r--r--l_settings.h2342logplain
-rw-r--r--l_sound.cpp1434logplain
-rw-r--r--l_sound.h1086logplain
-rw-r--r--l_storage.cpp3977logplain
-rw-r--r--l_storage.h1647logplain
-rw-r--r--l_util.cpp13089logplain
-rw-r--r--l_util.h3026logplain
-rw-r--r--l_vmanip.cpp10987logplain
-rw-r--r--l_vmanip.h2239logplain
opt">.param2) return advtrains.conn_matches_to(conn, cconns) end end -- If the rail is not allowed to be modified, also only use if already in desired direction if not advtrains.can_dig_or_modify_track(pos) then local cconns=advtrains.get_track_connections(node.name, node.param2) return advtrains.conn_matches_to(conn, cconns) end --rail at other end? local adj1, adj2=tp.find_already_connected(pos) if adj1 and adj2 then return false--dont destroy existing track elseif adj1 and not adj2 then if tr.double_conn[adj1.."_"..newdir] then return true--if exists, connect new rail and old end end return false else if tr.single_conn[newdir] then--just rotate old rail to right orientation return true end return false end end function tp.bend_rail(originpos, conn) local pos=advtrains.dirCoordSet(originpos, conn) local newdir=advtrains.oppd(conn) local node=minetest.get_node(pos) local ndef=minetest.registered_nodes[node.name] local nnpref = ndef and ndef.at_nnpref if not nnpref then return false end local tr=tp.tracks[nnpref] if not tr then return false end --is rail already connected? no need to bend. local conns=advtrains.get_track_connections(node.name, node.param2) if advtrains.conn_matches_to(conn, conns) then return end --rail at other end? local adj1, adj2=tp.find_already_connected(pos) if adj1 and adj2 then return false--dont destroy existing track elseif adj1 and not adj2 then if tr.double_conn[adj1.."_"..newdir] then advtrains.ndb.swap_node(pos, tr.double_conn[adj1.."_"..newdir]) return true--if exists, connect new rail and old end end return false else if tr.single_conn[newdir] then--just rotate old rail to right orientation advtrains.ndb.swap_node(pos, tr.single_conn[newdir]) return true end return false end end function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing, yaw) --1. find all rails that are likely to be connected local tr=tp.tracks[nnpref] local p_rails={} local p_railpos={} for i=0,15 do if tp.rail_and_can_be_bent(pos, i, nnpref) then p_rails[#p_rails+1]=i p_railpos[i] = pos else local upos = {x=pos.x, y=pos.y-1, z=pos.z} if tp.rail_and_can_be_bent(upos, i, nnpref) then p_rails[#p_rails+1]=i p_railpos[i] = upos end end end -- try double_conn if #p_rails > 1 then --iterate subsets for k1, conn1 in ipairs(p_rails) do for k2, conn2 in ipairs(p_rails) do if k1~=k2 then local dconn1 = tr.double_conn_1 local dconn2 = tr.double_conn_2 if not (advtrains.yawToDirection(yaw, conn1, conn2) == conn1) then dconn1 = tr.double_conn_2 dconn2 = tr.double_conn_1 end -- Checks are made this way round so that dconn1 has priority (this will make arrows of atc rails -- point in the right direction) local using if (dconn2[conn1.."_"..conn2]) then using = dconn2[conn1.."_"..conn2] end if (dconn1[conn1.."_"..conn2]) then using = dconn1[conn1.."_"..conn2] end if using then -- has found a fitting rail in either direction -- if not, continue loop tp.bend_rail(p_railpos[conn1], conn1, nnpref) tp.bend_rail(p_railpos[conn2], conn2, nnpref) advtrains.ndb.swap_node(pos, using) local nname=using.name if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) end return end end end end end -- try single_conn if #p_rails > 0 then for ix, p_rail in ipairs(p_rails) do local sconn1 = tr.single_conn_1 local sconn2 = tr.single_conn_2 if not (advtrains.yawToDirection(yaw, p_rail, (p_rail+8)%16) == p_rail) then sconn1 = tr.single_conn_2 sconn2 = tr.single_conn_1 end if sconn1[p_rail] then local using = sconn1[p_rail] tp.bend_rail(p_railpos[p_rail], p_rail, nnpref) advtrains.ndb.swap_node(pos, using) local nname=using.name if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) end return end if sconn2[p_rail] then local using = sconn2[p_rail] tp.bend_rail(p_railpos[p_rail], p_rail, nnpref) advtrains.ndb.swap_node(pos, using) local nname=using.name if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) end return end end end --use default minetest.set_node(pos, {name=nnpref.."_"..tr.default}) if minetest.registered_nodes[nnpref.."_"..tr.default] and minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node then minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node(pos, placer, itemstack, pointed_thing) end end function tp.register_track_placer(nnprefix, imgprefix, dispname, def) minetest.register_craftitem(":"..nnprefix.."_placer",{ description = dispname, inventory_image = imgprefix.."_placer.png", wield_image = imgprefix.."_placer.png", groups={advtrains_trackplacer=1, digtron_on_place=1}, liquids_pointable = def.liquids_pointable, on_place = function(itemstack, placer, pointed_thing) local name = placer:get_player_name() if not name then return itemstack, false end if pointed_thing.type=="node" then local pos=pointed_thing.above local upos=vector.subtract(pointed_thing.above, {x=0, y=1, z=0}) if not advtrains.check_track_protection(pos, name) then return itemstack, false end if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then if def.suitable_substrate then s = def.suitable_substrate(upos) else s = minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable end if s then -- minetest.chat_send_all(nnprefix) local yaw = placer:get_look_horizontal() tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing, yaw) if not advtrains.is_creative(name) then itemstack:take_item() end end end end return itemstack, true end, }) end minetest.register_craftitem("advtrains:trackworker",{ description = attrans("Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail/bumper/signal/etc."), groups = {cracky=1}, -- key=name, value=rating; rating=1..3. inventory_image = "advtrains_trackworker.png", wield_image = "advtrains_trackworker.png", stack_max = 1, on_place = function(itemstack, placer, pointed_thing) local name = placer:get_player_name() if not name then return end local has_aux1_down = placer:get_player_control().aux1 if pointed_thing.type=="node" then local pos=pointed_thing.under if not advtrains.check_track_protection(pos, name) then return end local node=minetest.get_node(pos) --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") --atdebug(node.name.."\npattern recognizes:"..nnprefix.." / "..suffix.." / "..rotation) --atdebug("nntab: ",tp.tracks[nnprefix]) if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") rotation = "" if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then minetest.chat_send_player(placer:get_player_name(), attrans("This node can't be rotated using the trackworker!")) return end end -- check if the node is modify-protected if advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then -- is a track, we can query local can_modify, reason = advtrains.can_dig_or_modify_track(pos) if not can_modify then local str = attrans("This track can not be rotated!") if reason then str = str .. " " .. reason end minetest.chat_send_player(placer:get_player_name(), str) return end end if has_aux1_down then --feature: flip the node by 180° --i've always wanted this! advtrains.ndb.swap_node(pos, {name=node.name, param2=(node.param2+2)%4}) return end local modext=tp.tracks[nnprefix].twrotate[suffix]