Page 1 of 1
MOD : spawncorrection (Avoid spawning under earth)

Posted:
Wed Nov 16, 2016 18:31
by KGM
It is nasty to spawn into stone when accessing a new world
so I made this mod to avoid the player
spawning and respawning under earth.
To install the mod, just unzip it and
paste it into the /mods directory of
the concerning subgame.
PS: If you have downloaded it before the 25.12.2016, you shall replace it by the newest version,because the last releases all had some bugs for example porting up 3D ladders at spawn point(oldest one) or porting up when jumping in a 2 blocks heigh room at spawn point(one of the newer ones) and,very important:
IF YOU FIND A BUG IN THE ACTUAL RELEASE,PLEASE TELL ME
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Thu Nov 17, 2016 15:48
by DS-minetest
i never spawned in stone
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Thu Nov 17, 2016 17:40
by KGM
Spiel doch mal z.b. den Lord Of The Test Master mit 1 als seed.
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Thu Nov 17, 2016 17:49
by DS-minetest
ah, i think i know now, what you mean
some mods generate above the normal generation level to get a nice mapgen
but the players spawn on normal hight
ok, then this mod could be useful
ps.: das -master kommt von github, weil es vom master branch stammt, das gehört jedoch nicht zum namen => es heißt einfach nur lord of the test, oder kurz lott
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Thu Nov 17, 2016 18:14
by KGM
Danke für diese Informationen.
Es ist immer nett, etwas neues zu lernen.
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Thu Nov 17, 2016 18:39
by cx384
Why do you talk German on an international topic?
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Thu Nov 17, 2016 18:39
by DS-minetest
KGM started, i did only the ps german
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Mon Dec 19, 2016 19:23
by KGM
I found out that my mod bugs when trying to go down ladders at the spawn point so I fixed the zip
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Mon Dec 19, 2016 21:19
by Wuzzy
Can you please post an issue on the Minetest issue tracker on GitHub?
Spawning in stone/dirt is one of the oldest problems in Minetest, and if you could suggest a bugfix, it will help a lot.
Doing this in a mod is the wrong way IMO. A good spawning algorithm is very essential, so it should be available in the engine.
Re: MOD : spawncorrection (Avoid spawning under earth)

Posted:
Wed Dec 21, 2016 16:38
by KGM
sorry,but I don't have an github account
by the way,here is how it works
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Minetest mod: spawncorrection
-- See README.txt for licensing and other information.
function spawn_over(player)
pos = player:getpos()
walkable = true
while walkable do
--node the player stands in
node0 = minetest.get_node(pos)
pos.y = pos.y+0.8
--"headnode"
node1 = minetest.get_node(pos)
pos.y = pos.y-0.8
--this part checks if the nodes the player is in are solid
if (minetest.registered_nodes[node1.name].walkable or
minetest.registered_nodes[node0.name].walkable) and
--this part checks if the node is not some little solid node like a ladder that can be passed by checking if light
--passes them (such nodes are usually passable by sunlight)
(minetest.registered_nodes[node1.name].sunlight_propagates == false or
minetest.registered_nodes[node0.name].sunlight_propagates == false or
minetest.registered_nodes[node1.name].sunlight_propagates == nil or
minetest.registered_nodes[node0.name].sunlight_propagates == nil) then
--the player couldn't move freely at this location,the location checked next is one higher
pos.y = pos.y+1
else
--if the player could move freely at this location,the location is good to port the player to it,so the while-loop gets stopped
walkable = false
end
--port the player to it
player:setpos(pos)
end
end
function spawn_over_after(player,time)
minetest.after(time,spawn_over,player)
end
minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do
pos = player:getpos()
node0 = minetest.get_node(pos)
pos.y = pos.y+0.8
node1 = minetest.get_node(pos)
pos.y = pos.y-0.8
--this part checks if the nodes the player is in are solid
if (minetest.registered_nodes[node1.name].walkable or
minetest.registered_nodes[node0.name].walkable) and
--this part checks if the player is at spawn location(if any unfixed problems are there,they just occur at spawn location)
pos.x > 59.2 and
pos.x < 60.8 and
pos.z > -0.8 and
pos.z < 0.8 then
spawn_over(player)
end
end
end)