aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
Commit message (Expand)AuthorAge
* Vector functions: Fix vector.direction() function, improve documentation (#6801)Paramat2017-12-21
* Give subgames the ability to disallow specific mapgens (#6792)Ezhh2017-12-16
* Pointed thing to face pos: Use 'eye height' object property (#6754)Paramat2017-12-09
* core.rotate_node: Run callbacks like with any regular placed node (#6648)SmallJoker2017-11-21
* Set placer to nil instead of a non-functional one in item_OnPlace (#6449)DTA72017-09-21
* Fix Rotate Node Placement (#6424)tenplus12017-09-16
* Fix core.wrap_text and make its behaviour consistent with the docssfan52017-09-12
* Add '@n' escape sequences and some documentation on translated strings.Nathanaël Courant2017-08-26
* Add clientside translations.Ekdohibs2017-08-24
* Add minetest.rgba function that returns ColorString from RGBA or RGB valuesGael-de-Sailly2017-06-22
* Improve chatcommand params consistency (#5985)Ezhh2017-06-15
* Fix sending color codes to clients that don't support them. (#5950)red-0012017-06-09
* [CSM] Add function to get player privileges (#5933)red-0012017-06-07
* Builtin: Fix subgame mod selection (#5367)SmallJoker2017-05-17
* CSM: Document forgotten functionsSmallJoker2017-05-16
* minetest.deserialize: Throw error when argument not string (#5738)SmallJoker2017-05-09
* Use a settings object for the main settingsShadowNinja2017-05-06
* Pointed thing to face pos: Fix crash if opening door with slab or stairMarkuBu2017-04-19
* [CSM] Use more gettext (#5553)red-0012017-04-10
* minetest.after(): simplify further, pause in singleplayer (#5500)Auke Kok2017-04-02
* First commit for fine pointed (#5485)MarkuBu2017-04-01
* Add functions to strip color information. (#5472)Diego Martínez2017-03-28
* Fix a type bug in colorize functionLoïc Blot2017-03-28
* Change command prefix to "." and add "help" command.red-0012017-03-26
* Typo fixLoïc Blot2017-03-24
* Add multiline support to colorize. (#5444)red-0012017-03-24
* Block access to the `io` libraryred-0012017-03-19
* Give CSM access to use `core.colorize()` (#5113)red-0012017-03-17
* [CSM] Improve security for client-sided mods (#5100)red-0012017-03-13
* [CSM] Add local formspecs. (#5094)red-0012017-03-13
* [CSM] sound_play & sound_stop support + client_lua_api doc (#5096)Loïc Blot2017-03-13
* [CSM] Add client-sided chat commands (#5092)red-0012017-03-13
* Vector: Add vector.sort(a, b): return box edgesAuke Kok2017-01-23
* Revert "Adding particle blend, glow and animation (#4705)"sfan52016-11-14
* Adding particle blend, glow and animation (#4705)Foghrye42016-11-15
* Core.rotate_and_place: Remove unused call to get_look_pitch()Auke Kok2016-10-31
* Builtin: Add vector.floor helper functionrubenwardy2016-10-17
* Only allow strings to be passed to minetest.global_exists (#4253)HybridDog2016-06-28
* Faster insertion into tableRui9142016-03-06
* Refactor loggingShadowNinja2015-10-14
* Add /emergeblocks command and core.emerge_area() Lua APIkwolekr2015-09-23
* Allow random menu images for subgamessfan52015-07-21
* Fix wrong replace from previous commitest312015-06-02
* Localize inside whole misc_helpers.luaest312015-06-01
* Add minetest.global_exists()ShadowNinja2015-04-21
* Fix serialization of floating point numbersShadowNinja2015-02-21
* Server: announce MIN/MAX protocol version supported to serverlist. Client: ch...est312015-02-18
* Fix crash on passing false as value in table to table.copy(t)est312015-02-14
* Change assignment to global in a function to warningrubenwardy2015-02-04
* Fix imprecise serialization of large numbersShadowNinja2015-01-25
pan>cycle_follows if not tp.tracks[nnprefix].twrotate[suffix] then tp.tracks[nnprefix].twrotate[suffix]={} end table.insert(tp.tracks[nnprefix].twrotate[suffix], rotation) end function tp.find_adjacent_tracks(pos)--TODO vertical calculations(check node below) local conn1=0 while conn1<16 and not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, conn1)).name, advtrains.all_tracktypes) do conn1=conn1+1 end if conn1>=16 then return nil, nil end local conn2=0 while conn2<16 and not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, conn2)).name, advtrains.all_tracktypes) or conn2==conn1 do conn2=conn2+1 end if conn2>=16 then return conn1, nil end return conn1, conn2 end function tp.find_already_connected(pos)--TODO vertical calculations(check node below) local function istrackandbc(pos, conn) local cnode=minetest.get_node(advtrains.dirCoordSet(pos, conn)) local bconn=(conn+8)%16 if advtrains.is_track_and_drives_on(cnode.name, advtrains.all_tracktypes) then local cconn1, cconn2=advtrains.get_track_connections(cnode.name, cnode.param2) return cconn1==bconn or cconn2==bconn end return false end local conn1=0 while conn1<16 and not istrackandbc(pos, conn1) do conn1=conn1+1 end if conn1>=16 then return nil, nil end local conn2=0 while conn2<16 and not istrackandbc(pos, conn2) or conn2==conn1 do conn2=conn2+1 end if conn2>=16 then return conn1, nil end return conn1, conn2 end function tp.placetrack(pos, nnpref) local conn1, conn2=tp.find_adjacent_tracks(pos) local tr=tp.tracks[nnpref] if not conn1 and not conn2 then minetest.set_node(pos, {name=nnpref.."_"..tr.default}) elseif conn1 and not conn2 then if tr.single_conn[conn1] then tp.try_adjust_rail(tr, advtrains.dirCoordSet(pos, conn1), (conn1+8)%16) minetest.set_node(pos, tr.single_conn[conn1]) else minetest.set_node(pos, {name=nnpref.."_"..tr.default}) end elseif conn1 and conn2 then if tr.double_conn[conn1.."_"..conn2] then tp.try_adjust_rail(tr, advtrains.dirCoordSet(pos, conn1), (conn1+8)%16) tp.try_adjust_rail(tr, advtrains.dirCoordSet(pos, conn2), (conn1+8)%16) minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) elseif tr.single_conn[conn1] then --try at least one side tp.try_adjust_rail(tr, advtrains.dirCoordSet(pos, conn1), (conn1+8)%16) minetest.set_node(pos, tr.single_conn[conn1]) else minetest.set_node(pos, {name=nnpref.."_"..tr.default}) end end end function tp.try_adjust_rail(tr, pos, newdir) --is rail already connected? local node=minetest.get_node(pos) local conn1, conn2=advtrains.get_track_connections(node.name, node.param2) if newdir==conn1 or newdir==conn2 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 minetest.set_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 minetest.set_node(pos, tr.single_conn[newdir]) return true end return false end end function tp.register_track_placer(nnprefix, imgprefix, dispname) minetest.register_craftitem(nnprefix.."_placer",{ description = dispname, inventory_image = imgprefix.."_placer.png", wield_image = imgprefix.."_placer.png", groups={}, on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type=="node" then local pos=pointed_thing.above if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then tp.placetrack(pos, nnprefix) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end end end return itemstack end, }) end minetest.register_craftitem("advtrains:trackworker",{ description = "Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail", 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) if pointed_thing.type=="node" then local pos=pointed_thing.under 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 if advtrains.is_train_at_pos(pos) then return end local nnprefix, suffix, rotation=string.match(node.name, "^([^_]+)_([^_]+)(_?.*)$") --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then print("[advtrains]railtype not workable by trackworker") return end local modext=tp.tracks[nnprefix].twrotate[suffix] if rotation==modext[#modext] then --increase param2 minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) return else local modpos for k,v in pairs(modext) do if v==rotation then modpos=k end end if not modpos then print("[advtrains]rail not workable by trackworker") return end minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) end advtrains.invalidate_all_paths() end end, on_use=function(itemstack, user, pointed_thing) if pointed_thing.type=="node" then local pos=pointed_thing.under 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 if advtrains.is_train_at_pos(pos) then return end local nnprefix, suffix, rotation=string.match(node.name, "^([^_]+)_([^_]+)(_?.*)$") if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then print("[advtrains]railtype not workable by trackworker") return end local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] minetest.set_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) --invalidate trains advtrains.invalidate_all_paths() end end, }) --putting into right place advtrains.trackplacer=tp