Would like to set a limit of nodes (restricting /home) happening from a prior /sethome pos. I don't have the programming knowledge to modify the Lua sethome file.
Thanks
home/ (Limits)
Re: home/ (Limits)
Try adding the middle part (starting with local oldpos) here to sethome/init.lua so it looks like this:
This is untested, but ought to work. If the distance between the two is greater than 2000 nodes, it cancels the sethome and tells the player it's too far away.
Code: Select all
sethome.set = function(name, pos)
local player = minetest.get_player_by_name(name)
if not player or not pos then
return false
end
local oldpos = minetest.string_to_pos(player:get_attribute("sethome:home"))
if vector.distance(oldpos, pos) > 2000 then
minetest.chat_send_player(name, "You are too far from your previous home")
return false
end
player:set_attribute("sethome:home", minetest.pos_to_string(pos))
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile
Re: home/ (Limits)
I like the sethome/home option in a game, yet didn't much care for digging a hole and just jumping out. Sort of easy for stupid. Thank you.
Doesn't work as I intend yet have time to continue figuring...
Doesn't work as I intend yet have time to continue figuring...
Re: home/ (Limits)
Oh you wanted to keep the player from using /home past a certain distance, I misunderstood and thought you wanted to prevent /sethome. Easy fix! We just move our distance check down to the sethome.go function instead:
Added an "if pos" on the front because if there's no home set for this player, it will be a nil value. I think vector.distance might handle that okay, but it's usually best to just skip doing anything if you've got a nil value, passing it to the wrong function can cause crashes.
Code: Select all
sethome.go = function(name)
local pos = sethome.get(name)
local player = minetest.get_player_by_name(name)
local oldpos = player:get_pos()
if pos and vector.distance(oldpos, pos) > 2000 then
minetest.chat_send_player(name, "You are too far from your previous home")
return false
end
if player and pos then
player:set_pos(pos)
return true
end
return false
end
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile
Re: home/ (Limits)
Yes, correct. I'm thinking better to restrict the "home" command operating, unless that person is within/near the spawn area. How much trouble figuring that one?
My apology for my lack of being precise.
My apology for my lack of being precise.
Re: home/ (Limits)
No trouble there, just figure out the "spawn area" center's coordinates, then set "oldpos" to be that in { x = 0, y = 0, z = 0} format. Now you can't /sethome more than 2000 nodes from the center of spawn. Adjust range as desired.
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile
Re: home/ (Limits)
All the modifications been looking into... Just now realized using "sethome/home" in the mod unified_inventory doesn't effect the "sethome" of minetest_game/mods/sethome. Two different sets.
Has anyone ever mentioned linking the two mods to work in union?
Has anyone ever mentioned linking the two mods to work in union?
-
- Member
- Posts: 307
- Joined: Wed Apr 21, 2021 03:05
- GitHub: tigercoding56
- In-game: bm5 or bemo5 also sell_her_on55
Re: home/ (Limits)
most people enjoy having 2 home positions 3 home positions would be even better i wish for 26 home positions but why stop there100 no 9999 better yet INFINITY HOME POSITIONS:D
this is a signature not a place to post messages also if i could change my username i would change it to sell_her_on55
Who is online
Users browsing this forum: No registered users and 6 guests