[Mod] Teleporter Mod [1.07] [teleporter]

Bad_Command_
Member
Posts: 30
Joined: Sat Jun 23, 2012 01:17

[Mod] Teleporter Mod [1.07] [teleporter]

by Bad_Command_ » Post

Hi, announcing the teleporter mod. The mod is on github.

The teleporter mod adds teleporter pads to minetest. The pads allow players to teleport around a minetest world in a controllable manner.

mt1.gameboom.net port 30000 makes extensive use of teleporters: it has a teleportation network. Check it out if you want to see these in action. (Go to 0,0,0 if you are near the spawn.)

Downloads:
Version 1.07
Version 1.06

License:
LGPL 2.1 for code
CC0 for media (textures and sounds)

Creating a teleporter pad
A teleporter pad can be crafted using the following recipe:
Image
The recipe uses copper ingots and a gold block from moreores, a power plant from mesecons, and a glass block. If you don't have moreores and mesecons, this recipe works too:
Image
Once a teleporter pad has been made, it can be placed and configured much like a wall sign.

Configuring a teleporter pad
To configure a teleporter pad, right click on the pad and then enter destination coordinates. You can enter a description after the coordinates as well. The coordinates are entered as text in the following format: X,Y,Z,Description. X,Y,Z are the coordinates of the destination.
Image

Using a teleporter pad
In order to use a teleporter, just step on it. If it is properly configured and enabled, you will teleport to the destination.

Configuration options
The teleporter mod has a few options that can be used to restrict the use of teleporters. These options are specified as settings (variables) in config.lua. The options are as follows:
  • teleport_perms_to_build
    When true, a player has to have the teleport permission to build a teleporter. When false, anyone can build a new teleporter.
  • teleport_perms_to_configure
    When true, a player has to have the teleport permission to configure a teleporter. Players can still build teleporters without this, however the teleporter will be locked to the default location.
  • teleport_requires_pairing
    When true, a teleporter can only be configured to teleport to a location near an existing teleporter. This prevents players from pointing teleporters in to unexplored terrain.
  • teleport_pairing_check_radius
    Specifies the size of the volume to scan when looking for a paired teleporter. Do not set this to a large value; the number of nodes scanned increases by a power of 3.
  • teleport_default_coordinates
    Allows for the default coordinates for new a teleporter to be specified. This is useful when players can build new teleporters, but can't configure them.
Last edited by Bad_Command_ on Thu Jul 05, 2012 06:00, edited 1 time in total.

User avatar
SegFault22
Member
Posts: 872
Joined: Mon May 21, 2012 03:17
Location: NaN

by SegFault22 » Post

Can you release a version that doesn't require the privs stuff? I need to test something, but the code here is too long :P
Last edited by SegFault22 on Sat Jun 23, 2012 03:16, edited 1 time in total.
"All we need it the right major crisis and the nations will accept the new world order."

User avatar
Calinou
Moderator
Posts: 3169
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

by Calinou » Post

Try to stick to 16x16 textures. :P
Also, use vanilla items in the recipes... not everyone wants to install mesecons and moreores to have this mod.

User avatar
LolManKuba
Member
Posts: 939
Joined: Fri Feb 10, 2012 22:36
Location: Ontario, Canada
Contact:

by LolManKuba » Post

Calinou wrote:Try to stick to 16x16 textures. :P
Also, use vanilla items in the recipes... not everyone wants to install mesecons and moreores to have this mod.
Now that is true,

Bad_Command_
Member
Posts: 30
Joined: Sat Jun 23, 2012 01:17

by Bad_Command_ » Post

Calinou wrote:Try to stick to 16x16 textures. :P
Also, use vanilla items in the recipes... not everyone wants to install mesecons and moreores to have this mod.
Ok Calinou, 16x16 texture and default item recipe added.

User avatar
SegFault22
Member
Posts: 872
Joined: Mon May 21, 2012 03:17
Location: NaN

by SegFault22 » Post

I don't get how you go about teleporting someone when they are standing on the teleporter pad - what is your ''secret''? (lol)
"All we need it the right major crisis and the nations will accept the new world order."

Bad_Command_
Member
Posts: 30
Joined: Sat Jun 23, 2012 01:17

by Bad_Command_ » Post

SegFault22 wrote:I don't get how you go about teleporting someone when they are standing on the teleporter pad - what is your ''secret''? (lol)
Nothing secret or hidden in the mod. Take a look at the source code; the code that accomplishes this is neatly contained within the abm. (minetest.register_abm( ... ). Try going through it line-by-line, and understanding what each line does. Remember that the teleporter coordinates are stored in the node metadata.

User avatar
SegFault22
Member
Posts: 872
Joined: Mon May 21, 2012 03:17
Location: NaN

by SegFault22 » Post

I have already done that, but I will try again later...
Thank you
"All we need it the right major crisis and the nations will accept the new world order."

User avatar
RandomBot
Member
Posts: 164
Joined: Sun May 20, 2012 03:46
Location: Behind you, go ahead, look....

by RandomBot » Post

well now i can remove the elevators from my space station
"Everyone has a plan, until they get punched in the face"
- Mike Tyson

Bad_Command_
Member
Posts: 30
Joined: Sat Jun 23, 2012 01:17

by Bad_Command_ » Post

Version 1.07 released. Contains only minor updates: config options were moved in to config.lua.

Thunder
New member
Posts: 9
Joined: Sun Jul 08, 2012 01:36

by Thunder » Post

I fixed up your teleporter a little bit. Things I changed:

added teleporter to creative inventory
allowing destination of default x,y,z
disabled redundant owner message for server
mod tells player where the destination and teleporter are at
mod keeps player off of destination telepad, fixing a very bad glitch

Download the whole thing or replace teleporter/init.lua with this code:

Code: Select all

---
--Teleporter 1.07
--Copyright (C) 2012 Bad_Command
--
--This library is free software; you can redistribute it and/or
--modify it under the terms of the GNU Lesser General Public
--License as published by the Free Software Foundation; either
--version 2.1 of the License, or (at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--GNU General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public
--License along with this library; if not, write to the Free Software
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
----

teleporter = {}
teleporter.version = 1.07

-- config.lua contains configuration parameters
dofile(minetest.get_modpath("teleporter").."/config.lua")

minetest.register_craft({
    output = 'teleporter:teleporter_pad',
    recipe = {
                {'moreores:copper_ingot', 'default:glass', 'moreores:copper_ingot'},
                {'moreores:copper_ingot', 'moreores:gold_block', 'moreores:copper_ingot'},
                {'moreores:copper_ingot', 'mesecons_powerplant:power_plant', 'moreores:copper_ingot'},
        }
})

minetest.register_craft({
    output = 'teleporter:teleporter_pad',
    recipe = {
                {'default:wood', 'default:glass', 'default:wood'},
                {'default:wood', 'default:mese', 'default:wood'},
                {'default:wood', 'default:wood', 'default:wood'},
        }
})

minetest.register_node("teleporter:teleporter_pad", {
    tile_images = {teleporter.tile_image},
    drawtype = "signlike",
    paramtype = "light",
    paramtype2 = "wallmounted",
    walkable = false,
    description="Teleporter Pad",
    inventory_image = teleporter.tile_image,
    metadata_name = "sign",
    --sounds = default.node_sound_defaults(),
    groups = {choppy=2,dig_immediate=2},
    selection_box = {
        type = "wallmounted",
    },
        on_construct = function(pos)
                local meta = minetest.env:get_meta(pos)
                meta:set_string("formspec", "hack:sign_text_input")
                meta:set_string("infotext", "\"Teleport to "..teleporter.default_coordinates.desc.."\"")
        meta:set_string("text", teleporter.default_coordinates.x..","..
            teleporter.default_coordinates.y..","..
            teleporter.default_coordinates.z..","..
            teleporter.default_coordinates.desc)
        meta:set_float("enabled", -1)
        meta:set_float("x", teleporter.default_coordinates.x)
        meta:set_float("y", teleporter.default_coordinates.y)
        meta:set_float("z", teleporter.default_coordinates.z)
        end,
    after_place_node = function(pos, placer)
        local meta = minetest.env:get_meta(pos)
        local name = placer:get_player_name()
        meta:set_string("owner", name)
        
        if teleporter.perms_to_build and not minetest.get_player_privs(name)["teleport"] then
            minetest.chat_send_player(name, 'Teleporter:  Teleport privileges are required to build teleporters.')
            minetest.env:remove_node(pos)
            minetest.env:add_item(pos, 'teleporter:teleporter_pad')
        else
            minetest.chat_send_player(name, 'Teleporter:  My position is '..pos.x..','..pos.y..','..pos.z..'')
            meta:set_float("enabled", 1)
        end

    end,
        on_receive_fields = function(pos, formname, fields, sender)
        local coords = teleporter.coordinates(fields.text)
                local meta = minetest.env:get_meta(pos)
        local name = sender:get_player_name()
        local privs = minetest.get_player_privs(name)

        if name ~= meta:get_string("owner") and not privs["server"] then
            minetest.chat_send_player(name, 'Teleporter:  This is not your teleporter, it belongs to '..meta:get_string("owner"))
            minetest.chat_send_player(name, 'Teleporter:  My position is '..pos.x..','..pos.y..','..pos.z..'')
            return false
        else if name ~= meta:get_string("owner") and privs["server"] then
            minetest.chat_send_player(name, 'Teleporter:  This teleporter belongs to '..meta:get_string("owner"))
        end

        if teleporter.perms_to_configure and not privs["teleport"] then
            minetest.chat_send_player(name, 'Teleporter:  You need teleport privileges to configure a teleporter')
            return
        end

        local infotext = ""
        if coords~=nil then    
            meta:set_float("x", coords.x)
            meta:set_float("y", coords.y)
            meta:set_float("z", coords.z)
            if teleporter.requires_pairing and not teleporter.is_paired(coords) and not privs["server"] then
                minetest.chat_send_player(name, 'Teleporter:  There is no recently-used teleporter pad at the destination!')
                minetest.chat_send_player(name, 'Teleporter:  My position is '..pos.x..','..pos.y..','..pos.z..'')
                        meta:set_string("text", fields.text)
                infotext="Teleporter is Disabled"
                meta:set_float("enabled", -1)
            else
                minetest.chat_send_player(name, 'Teleporter:  Coords set to '..coords.x..','..coords.y..','..coords.z..' from '..pos.x..','..pos.y..','..pos.z..'')
                meta:set_float("enabled", 1)
                if coords.desc~=nil then
                    infotext="Teleport to "..coords.desc
                else
                    infotext="Teleport to "..coords.x..","..coords.y..","..coords.z..""
                end
            end
        else
            minetest.chat_send_player(name, 'Teleporter:  Incorrect coordinates.  Enter them as \'X,Y,Z,Description\' without decimals.')
            meta:set_float("enabled", -1)
            infotext="Teleporter Offline"
        end

                print((sender:get_player_name() or "").." entered \""..fields.text..
                                "\" to teleporter at "..minetest.pos_to_string(pos))
                meta:set_string("text", fields.text)
                meta:set_string("infotext", '"'..infotext..'"')
            end
    end,
    can_dig = function(pos,player)
        local meta = minetest.env:get_meta(pos)
        local name = player:get_player_name()
        local privs = minetest.get_player_privs(name)
        if name == meta:get_string("owner") or privs["server"] then
            return true
        end
        return false
    end
})

teleporter.is_paired = function(coords)
    if coords.x==teleporter.default_coordinates.x and coords.y==teleporter.default_coordinates.y and coords.z==teleporter.default_coordinates.z then
        return true
    end
    for dx=-teleporter.pairing_check_radius,teleporter.pairing_check_radius do
        for dy=-teleporter.pairing_check_radius,teleporter.pairing_check_radius do
            for dz=-teleporter.pairing_check_radius,teleporter.pairing_check_radius do
                local node = minetest.env:get_node({x=coords.x + dx, y=coords.y + dy, z=coords.z + dz})
                if node.name == 'teleporter:teleporter_pad' then
                    return true
                end
            end
        end
    end
    return false
end

local function get_nodedef_field(nodename, fieldname)
    if not minetest.registered_nodes[nodename] then
        return nil
    end
    return minetest.registered_nodes[nodename][fieldname]
end

teleporter.get_safe_dest = function(coords)
        local potentialdest=coords
    for dx=-1,1 do
        for dz=-1,1 do
            local p = {x=coords.x + dx, y=coords.y, z=coords.z + dz}
            local node = minetest.env:get_node(p)
            if node.name ~= 'teleporter:teleporter_pad' then
                if get_nodedef_field(node.name, "walkable")==false then
                    return p
                end
                potentialdest=p
            end
        end
    end
    return potentialdest
end

teleporter.coordinates = function(str) 
    local x,y,z,desc = string.match(str, "^(-?%d+),(-?%d+),(-?%d+),?(.*)$")
    
    if desc=="" then
        desc = nil
    end

    if x==nil or y==nil or z==nil or 
        string.len(x) > 6 or string.len(y) > 6 or string.len(z) > 6 then
            return nil
    end

    x = x + 0.0
    y = y + 0.0
    z = z + 0.0

    if x > 32765 or x < -32765 or y > 32765 or y < -32765 or z > 32765 or z < -32765 then
        return nil
    end

    return {x=x, y=y, z=z, desc=desc}
end


minetest.register_abm(
    {nodenames = {"teleporter:teleporter_pad"},
    interval = 1.0,
    chance = 1,
    action = function(pos, node, active_object_count, active_object_count_wider)
        --0.7071 is half of the square root of 2, meaning the inner circle on the telepad
        local objs = minetest.env:get_objects_inside_radius(pos, 0.7071)
        for k, player in pairs(objs) do
            if player:get_player_name()~=nil then 
                local meta = minetest.env:get_meta(pos)
                if meta:get_float("enabled") > 0 then
                    local target_coords=teleporter.get_safe_dest({x=meta:get_float("x"), y=meta:get_float("y"), z=meta:get_float("z")})
                    --print('player teleported to '..minetest.pos_to_string(target_coords)..' from '..minetest.pos_to_string(pos))
                    minetest.sound_play("teleporter_teleport", {pos = pos, gain = 1.0, max_hear_distance = 10,})
                    player:moveto(target_coords, false)
                    minetest.sound_play("teleporter_teleport", {pos = target_coords, gain = 1.0, max_hear_distance = 10,})
                end
            end
        end
    end    
})

minetest.add_to_creative_inventory('teleporter:teleporter_pad')
Last edited by Thunder on Sun Jul 08, 2012 01:45, edited 1 time in total.

hyudez257
Member
Posts: 55
Joined: Sat Jul 21, 2012 18:22

by hyudez257 » Post

Configuration options
The teleporter mod has a few options that can be used to restrict the use of teleporters. These options are specified as settings (variables) in config.lua. The options are as follows


do you need to configure anything to actually just use the teleporters?

pagliaccio
Member
Posts: 65
Joined: Tue Jul 31, 2012 07:38
Location: italy

by pagliaccio » Post

how i see coord of a point?

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Post

press f5

Matsetes

by Matsetes » Post

Can you modify it adding name for coordinates? Such as here http://minetest.net/forum/viewtopic.php?id=2321
It's more simple to remember a name than three numbers...

User avatar
GJH105775
Member
Posts: 106
Joined: Thu Sep 27, 2012 16:11
Location: Ohio, USA
Contact:

by GJH105775 » Post

Nice mod.
Check out my mod xtrablocks, has some different types of marble that you can build with or mine at different depths

I am not here regularly as I just kind of pop in and out. If you want to find me I'll be on quadcopterforum.com helping with multirotor builds and spending other's money haha.

http://i10.photobucket.com/albums/a119/ ... hicons.jpg

Actev8
Member
Posts: 120
Joined: Sat Sep 15, 2012 14:09

by Actev8 » Post

whats you tp

User avatar
neko259
Member
Posts: 805
Joined: Sun Jun 19, 2011 06:51

by neko259 » Post

I have a strange bug with this mod. Sometimes after a teleport I see myself at the same place, but the real coordinates are changed. When I try to go somewhere, I die because in my real (not seen) position I have already teleported and go to a wall or lava.
s3tuPDfUv2IyvXHzPmE31MQvnWULv1zj

User avatar
jojoa1997
Member
Posts: 2890
Joined: Thu Dec 13, 2012 05:11
Location: Earth

by jojoa1997 » Post

can you update this to use the new mese
Coding;
1X coding
3X debugging
12X tweaking to be just right

User avatar
Zeg9
Member
Posts: 608
Joined: Fri Sep 21, 2012 11:02
Location: France

by Zeg9 » Post

jojoa1997 wrote:can you update this to use the new mese
It can be crafted with mese blocks if you use the latest minetest_game.
EDIT: Happy new year !
Last edited by Zeg9 on Mon Dec 31, 2012 23:02, edited 1 time in total.
I made a few (a lot of?) mods for minetest: here is a list.
See also the MT-Faithful texture pack (work in progress).

User avatar
jojoa1997
Member
Posts: 2890
Joined: Thu Dec 13, 2012 05:11
Location: Earth

by jojoa1997 » Post

Zeg9 wrote:
jojoa1997 wrote:can you update this to use the new mese
It can be crafted with mese blocks if you use the latest minetest_game.
EDIT: Happy new year !
i thought it could not with the pictures being so old
Coding;
1X coding
3X debugging
12X tweaking to be just right

byronarn
Member
Posts: 12
Joined: Mon Jan 19, 2015 16:29

Re: [Mod] Teleporter Mod [1.07] [teleporter]

by byronarn » Post

What is the center block in the second recipe? The other blocks I have been able to identify as wood and glass. The middle one I am not sure of. Of course, I do use texture packs a lot so that's probably why I cannot identify it...

Help would be appreciated! Thanks.

Bad_Command_
Member
Posts: 30
Joined: Sat Jun 23, 2012 01:17

Re: [Mod] Teleporter Mod [1.07] [teleporter]

by Bad_Command_ » Post

byronarn wrote:What is the center block in the second recipe? The other blocks I have been able to identify as wood and glass. The middle one I am not sure of. Of course, I do use texture packs a lot so that's probably why I cannot identify it...

Help would be appreciated! Thanks.
It should be mese. I think the texture in the game changed for a little while back when I wrote the mod.

byronarn
Member
Posts: 12
Joined: Mon Jan 19, 2015 16:29

Re: [Mod] Teleporter Mod [1.07] [teleporter]

by byronarn » Post

Bad_Command_ wrote: It should be mese. I think the texture in the game changed for a little while back when I wrote the mod.
Thanks for your quick response! Yes, it was Mese. I built the teleporter pad with no problem, but then ran into a problem when I went to set the coordinates. I rightclicked on it, and a grey box showed up, but there was no text entry box. Then it kicked me out of the world and back to the main menu.

Here is what debug.txt says about the incident:
14:11:55: ERROR[main]: ServerError: /home/byron/.minetest/mods/teleporter/init.lua:159: bad argument #1 to 'match' (string expected, got nil)
14:11:55: ERROR[main]: stack traceback:
14:11:55: ERROR[main]: [C]: in function 'match'
14:11:55: ERROR[main]: /home/byron/.minetest/mods/teleporter/init.lua:159: in function 'coordinates'
14:11:55: ERROR[main]: /home/byron/.minetest/mods/teleporter/init.lua:86: in function </home/byron/.minetest/mods/teleporter/init.lua:85>
14:11:55: ACTION[ServerThread]: singleplayer leaves game. List of players:
I tried it a few more times, and each time the same thing happened. What do I have to do to fix this?

Bad_Command_
Member
Posts: 30
Joined: Sat Jun 23, 2012 01:17

Re: [Mod] Teleporter Mod [1.07] [teleporter]

by Bad_Command_ » Post

It sounds like something has changed in minetest and the teleporter mod needs to updated. It has been a few years since I've played minetest. I'll look in to it more and update the mod it this evening.

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests