Page 1 of 1

Setup a "teleport to" point

Posted: Wed Dec 04, 2019 18:01
by Visitor247
Hi,
Is there a way or a mod that can do the following.
My students are creating things, or doing tasks. I want to visit the results when no one is on the server.
Maybe they can set something with their name on, where I can teleport to?

Is there a way to find places when the player is not online?
Will it help if the players use the Area Mod?

Re: Setup a "teleport to" point

Posted: Wed Dec 04, 2019 18:04
by Visitor247
I just found "Points of Interest". It sounds if it is what I need. !?

Re: Setup a "teleport to" point

Posted: Wed Dec 04, 2019 19:23
by Krock
EDIT2:
Okay. This is a little bit hacky. Let's abuse the sethome mod.
1) Create an empty file called "homes" (no file extension) in your world directory
2) Add the following code to the bottom of sethome/init.lua: (quote post to preserve tabs)

Code: Select all

-- CUSTOM MODIFICATION START
sethome.set = function(name, pos)
	local player = minetest.get_player_by_name(name)
	if not player or not pos then
		return false
	end
	player:set_attribute("sethome:home", minetest.pos_to_string(pos))

	-- ADD! `name` to the old storage file
	local data = {}
	local output = io.open(homes_file, "w")
	if output then
		homepos[name] = vector.new(pos)
		for i, v in pairs(homepos) do
			table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, i))
		end
		output:write(table.concat(data))
		io.close(output)
		return true
	end
	return true -- if the file doesn't exist - don't return an error.
end

sethome.get = function(name)
	local player = minetest.get_player_by_name(name)
	-- Player may also be offline
	local pos = player and minetest.string_to_pos(player:get_attribute("sethome:home"))
	if pos then
		return pos
	end

	-- fetch old entry from storage table
	pos = homepos[name]
	if pos then
		return vector.new(pos)
	else
		return nil
	end
end

minetest.register_chatcommand("student_home", {
	-- Require server privilege to use this cmd
	privs = {server = true},
	func = function(name, dst_name)
		local pos = sethome.get(dst_name)
		local player = minetest.get_player_by_name(name)
		if player and pos then
			player:set_pos(pos)
			return true, S("Teleported to home!")
		end
		return false, S("Player not found!")
	end,
})

-- CUSTOM MODIFICATION END
3) Tell your players to use /sethome again to add it to the file.
4) Use "/student_home Lucifer44" to teleport to someone's home

Re: Setup a "teleport to" point

Posted: Thu Dec 05, 2019 02:18
by Sokomine
Or just use my travelnet mod in combination with a hub (=place where everyone places one station). That way, the students may also visit each other.

Re: Setup a "teleport to" point

Posted: Thu Dec 19, 2019 13:02
by Visitor247
Thanks everyone, but Points of Interest it was.
I set the Categories to the names of my classes. The students can now set PoIs with the GUI and they have to name them with their real names. Through the categories I can filter them by class.
I now can double-click a name in the GUI and am teleported to the building site of the player.