Post your modding questions here
Attach to an object with using set_attach function
In multiplayer, if the player is attached to an object (for example a horse) with using set_attach function, and the object is out of sight of another player (as well as the second player logged later than the first was attached), then the second player lost the first player model. It's look like a horse without player but player is on the horse.
How to fix this?
How to fix this?
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
Is the position for players always the bottom of the collisionbox, or is it just hardcoded 1 below the collisionbox origin?
Every time a mod API is left undocumented, a koala dies.
- Hybrid Dog
- Member
- Posts: 2835
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
The eye position ()mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm,,,,,m ,mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm (ignoring bobbing) is 1.625 m higher than the position got with player:getpos(), so l assume if pos is player:getpos() then the collision box is {pos.x-0.5, pos.y, pos.z-0.5, pos.x+0.5, pos.y+2, pos.z+0.5}. Sorry for the ms, something issmm,m, sorry, was, on my keyboard.
Re: Post your modding questions here
How to know if ALT is pressed by the player?
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
Re: Post your modding questions here
You can't detect hardware keys, but you can detect game keys by using get_player_control.drkwv wrote:How to know if ALT is pressed by the player?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!
Check out my stuff! | Donations greatly appreciated! PayPal
Check out my stuff! | Donations greatly appreciated! PayPal
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
The player collisionbox is {-0.3, -1, -0.3, 0.3, 1, 0.3} (so would map to {pos.x-0.3, pos.y, pos.z-0.3, pos.x + 0.3, pos.y + 2, pos.z + 0.3}) by default, but that was not my question.Hybrid Dog wrote:The eye position ()mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm,,,,,m ,mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm (ignoring bobbing) is 1.625 m higher than the position got with player:getpos(), so l assume if pos is player:getpos() then the collision box is {pos.x-0.5, pos.y, pos.z-0.5, pos.x+0.5, pos.y+2, pos.z+0.5}. Sorry for the ms, something issmm,m, sorry, was, on my keyboard.
My question is whether the player position offset from the collisionbox origin is hardcoded at -1, or if it adapts to match the current collisionbox. Under a normal collisionbox, the player collisionbox's bottom is at the position returned by getpos, which happens to be 1 below the origin of the collisionbox as specified in a player's object properties. If for example I changed the collision box to {-0.3, -2, -0.3, 0.3, 50, 0.3}, would that place the player position 2 below the collisionbox origin, or at 1 below the collisionbox origin again?
Every time a mod API is left undocumented, a koala dies.
- Hybrid Dog
- Member
- Posts: 2835
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
l tested it, the collisionbox isn't automatically heightened to make the player's feet touch its bottom:
btw: The player position doesn't change, player collision is coded for the client, so the collisionbox doesn't have an effect on the movement, which can also be seen on the screenshot.
btw: The player position doesn't change, player collision is coded for the client, so the collisionbox doesn't have an effect on the movement, which can also be seen on the screenshot.
- Attachments
-
- screenshot_20160210_223810.png (48.47 KiB) Viewed 531 times
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
Thank you Hybrid Dog. My purpose was just calculating the center of the player's collisionbox, so I don't need to worry about whether it affects player collision or not.Hybrid Dog wrote:l tested it, the collisionbox isn't automatically heightened to make the player's feet touch its bottom:
btw: The player position doesn't change, player collision is coded for the client, so the collisionbox doesn't have an effect on the movement, which can also be seen on the screenshot.
Every time a mod API is left undocumented, a koala dies.
Re: Post your modding questions here
Is an endless loop checking every player's player:get_player_control() is the only way to implement sprinting in game? Doesn't it affects performance in a bad way because of excessive checks every tick? Is there another way to implement it more efficient? Like putting an event emitter on a client (that would check keypresses every tick on a client but let it burn) and putting an event handler on a server?
https://github.com/GunshipPenguin/sprin ... sprint.lua
Code: Select all
for playerName,playerInfo in pairs(players) do
local player = minetest.get_player_by_name(playerName)
if player:get_player_control()["aux1"] and player:get_player_control()["up"] then
players[playerName]["shouldSprint"] = true
...
- paramat
- Developer
- Posts: 3700
- Joined: Sun Oct 28, 2012 00:05
- GitHub: paramat
- IRC: paramat
- Location: UK
Re: Post your modding questions here
Perhaps use a sprint-toggling item with an 'on use' function. Make sure to enable sprinting by editing per-player physics.
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
what this error means?
My code
Debug
Code: Select all
status_tp = {}
...
status_tp[name] = false
Code: Select all
attempt to index upvalue 'status_tp' (a boolean value)
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
Re: what this error means?
More context needed.BrunoMine wrote:My codeDebugCode: Select all
status_tp = {} ... status_tp[name] = false
Code: Select all
attempt to index upvalue 'status_tp' (a boolean value)
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!
Check out my stuff! | Donations greatly appreciated! PayPal
Check out my stuff! | Donations greatly appreciated! PayPal
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Re: what this error means?
My Codekaeza wrote: More context needed.
Code: Select all
local status_tp = {}
func_status_tp = function(name)
if name then
status_tp[name] = false
end
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
status_tp[name] = true
minetest.after(3, func_status_tp, name)
end)
Last edited by BrunoMine on Fri Feb 12, 2016 15:49, edited 1 time in total.
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
Re: Post your modding questions here
Try putting `local` before `status_tp = {}`. If it works, you may have another mod somewhere setting the global `status_tp` to other value.
EDIT: You should always use locals unless really needed (e.g. exported API), and then only use a single global named the same as your mod. The console/log should print a warning about unintended globals if you set the log level high enough.
EDIT: You should always use locals unless really needed (e.g. exported API), and then only use a single global named the same as your mod. The console/log should print a warning about unintended globals if you set the log level high enough.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!
Check out my stuff! | Donations greatly appreciated! PayPal
Check out my stuff! | Donations greatly appreciated! PayPal
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Re: Post your modding questions here
In fact I put it (but save this information).kaeza wrote:Try putting `local` before `status_tp = {}`. If it works, you may have another mod somewhere setting the global `status_tp` to other value.
I tried to use nil and not false.
Code: Select all
status_tp[name] = nil
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Post your modding questions here
That is not a solution. You should still be able to set = false.
You must still make things local. The only global variable you make should be a table with the same name as your mod.
You must still make things local. The only global variable you make should be a table with the same name as your mod.
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Re: Post your modding questions here
Okay. This is my code. It is correct?rubenwardy wrote:That is not a solution. You should still be able to set = false.
You must still make things local. The only global variable you make should be a table with the same name as your mod.
Code: Select all
local status_tp = {}
local func_status_tp = function(name)
if name then
status_tp[name] = false
end
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
status_tp[name] = true
minetest.after(3, func_status_tp, name)
end)
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
Re: Post your modding questions here
Does it cause errors now?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!
Check out my stuff! | Donations greatly appreciated! PayPal
Check out my stuff! | Donations greatly appreciated! PayPal
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Re: Post your modding questions here
Continued to occur the error.kaeza wrote:Does it cause errors now?
HELP!
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
Re: Post your modding questions here
It works for me. Only other thing I can think of is that the error is not in that file. Make sure you're editing the correct file and not a duplicate somewhere.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!
Check out my stuff! | Donations greatly appreciated! PayPal
Check out my stuff! | Donations greatly appreciated! PayPal
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Re: Post your modding questions here
Apparently I have to show the whole script.kaeza wrote:It works for me. Only other thing I can think of is that the error is not in that file. Make sure you're editing the correct file and not a duplicate somewhere.
Code: Select all
--
-- Mod Ant-Cracker
--
-- Ant-Fast
--
local diretrizes = anti_cracker.diretrizes.anti_fast
-- calculating variables
local dist_max_andando = (diretrizes.tempo_att*diretrizes.velocidade_max)
local dist_max_andando_suspeito = (diretrizes.tempo_att_suspeitos*diretrizes.velocidade_max)
local dist_verif_emissor = diretrizes.dist_verif + dist_max_andando + 1
local dist_verif_receptor = diretrizes.dist_verif
local spawn = minetest.setting_get_pos("static_spawnpoint") or {x=0,y=0,z=0}
local blocos_receptor = diretrizes.blocos_tp_livre
local blocos_emissor = diretrizes.blocos_tp_emissor
for i, bloco in ipairs(diretrizes.blocos_tp_livre) do
table.insert(blocos_emissor, bloco)
end
local ultima_pos = {}
local status_tp = {}
local acumulador = {}
local suspeitos = {}
local cancelar_suspeito = function(name)
if name then
local Nsuspeitos = {}
for pname, n in pairs(suspeitos) do
if name ~= pname then
Nsuspeitos[pname] = suspeitos[pname]
end
end
suspeitos = Nsuspeitos
end
end
-- Updates the position of the player
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= diretrizes.tempo_att then
timer = 0
for name, n in pairs(ultima_pos) do
local player = minetest.get_player_by_name(name)
if player and not suspeitos[name] then
ultima_pos[name] = player:getpos()
end
end
end
end)
-- Updates the position of the player suspects
local timer2 = 0
minetest.register_globalstep(function(dtime)
timer2 = timer2 + dtime
if timer2 >= diretrizes.tempo_att_suspeitos then
timer2 = 0
for name, n in pairs(suspeitos) do
local player = minetest.get_player_by_name(name)
if player and ultima_pos[name] then
ultima_pos[name] = player:getpos()
end
end
end
end)
local zerar_status_tp = function(name)
if name then
status_tp[name] = false
end
end
local zerar_acumulador = function(name)
if name then
acumulador[name] = false
end
end
minetest.register_on_cheat(function(player, cheat)
if cheat.type == "moved_too_fast" then
if player then
local name = player:get_player_name()
if acumulador[name] == false and status_tp[name] == false then
acumulador[name] = true
minetest.after(2, zerar_acumulador, name)
if minetest.check_player_privs(name, {teleport=true}) then
return
end
-- Checks if the player is too far from your last recorded position
local pos = player:getpos()
local dist = dist_max_andando
if suspeitos[name] then
dist = dist_max_andando_suspeito
end
if ultima_pos[name].x+dist < pos.x
or ultima_pos[name].x-dist > pos.x
or ultima_pos[name].z+dist < pos.z
or ultima_pos[name].z-dist > pos.z
or ultima_pos[name].y+dist < pos.y
then
-- Verifica se tem blocos de legitimem a distancia tao longa como um tp
if not minetest.find_node_near(ultima_pos[name], dist_verif_emissor, blocos_emissor)
or not minetest.find_node_near(player:getpos(), dist_verif_receptor, blocos_receptor)
then
-- O teleport nao foi legitimo (ou o movimento pareceu muito rapido)
local msg = "Aparentemente "..name.." moveu-se rapido demais."
minetest.chat_send_player(name, "[Ant-Cracker] Medida 2 | Aparentemente correste rapido demais.")
tomar_medida(name, 2, msg)
player:setpos(ultima_pos[name])
else
-- O teleport foi legitimo
status_tp = true
minetest.after(2, zerar_status_tp, name)
ultima_pos[name] = player:getpos()
end
else
-- O movimento pareceu rapido
if not suspeitos[name] then
suspeitos[name] = true
minetest.after(20, cancelar_suspeito, name)
end
end
end
end
end
end)
-- Inserts record players entering the server
minetest.register_on_joinplayer(function(player)
if player then
local name = player:get_player_name()
ultima_pos[name] = (player:getpos())
status_tp[name] = false
acumulador[name] = false
end
end)
-- Clear the variables when the player leaves the server
minetest.register_on_leaveplayer(function(player)
if player then
local name = player:get_player_name()
local Nultima_pos = {}
local Nstatus_tp = {}
local Nacumulador = {}
for pname, n in pairs(status_tp) do
if name ~= pname then
Nultima_pos[pname] = ultima_pos[pname]
Nstatus_tp[pname] = status_tp[pname]
Nacumulador[pname] = acumulador[pname]
end
end
acumulador = Nacumulador
ultima_pos = Nultima_pos
status_tp = Nstatus_tp
end
end)
-- Keeps the player instead of the spawn
minetest.register_on_respawnplayer(function(player)
if player then
local pos = player:getpos()
local name = player:get_player_name()
if minetest.find_node_near(pos, dist_verif_receptor, blocos_respawn) then
ultima_pos[name] = pos
status_tp = true
minetest.after(2, zerar_status_tp, name)
else
ultima_pos[name] = spawn
end
end
end)
-- As vezes o jogador nao vai para o spawn
minetest.register_on_dieplayer(function(player)
if player then
local name = player:get_player_name()
ultima_pos[name] = spawn
suspeitos[name] = true
minetest.after(diretrizes.tempo_att, cancelar_suspeito, name)
end
end)
Code: Select all
00:44:20: WARNING: Undeclared global variable "blocos_respawn" accessed at ...root/minetest/bin/../mods/anti_cracker/anti_fast.lua:164
2016-02-13 00:54:48: ACTION[Server]: Player TheMiner moved too fast; resetting position
2016-02-13 00:54:50: ERROR[Main]: UNRECOVERABLE error occurred. Stopping server. Please fix the following error:
2016-02-13 00:54:50: ERROR[Main]: Runtime error from mod '' in callback environment_Step(): ...root/minetest/bin/../mods/anti_cracker/anti_fast.lua:69: attempt to index upvalue 'status_tp' (a boolean value)
2016-02-13 00:54:50: ERROR[Main]: stack traceback:
2016-02-13 00:54:50: ERROR[Main]: ...root/minetest/bin/../mods/anti_cracker/anti_fast.lua:69: in function 'func'
2016-02-13 00:54:50: ERROR[Main]: /root/minetest/bin/../builtin/game/misc.lua:18: in function 'update_timers'
2016-02-13 00:54:50: ERROR[Main]: /root/minetest/bin/../builtin/game/misc.lua:50: in function '?'
2016-02-13 00:54:50: ERROR[Main]: /root/minetest/bin/../builtin/game/register.lua:355: in function </root/minetest/bin/../builtin/game/register.lua:335>
In thread 7fc0c76be7c0:
/root/minetest/src/server.cpp:505: void Server::step(float): A fatal error occurred: Runtime error from mod '' in callback environment_Step(): ...root/minetest/bin/../mods/anti_cracker/anti_fast.lua:69: attempt to index upvalue 'status_tp' (a boolean value)
stack traceback:
...root/minetest/bin/../mods/anti_cracker/anti_fast.lua:69: in function 'func'
/root/minetest/bin/../builtin/game/misc.lua:18: in function 'update_timers'
/root/minetest/bin/../builtin/game/misc.lua:50: in function '?'
/root/minetest/bin/../builtin/game/register.lua:355: in function </root/minetest/bin/../builtin/game/register.lua:335>
Debug stacks:
DEBUG STACK FOR THREAD 7fc0b6bfd700:
#0 virtual void* EmergeThread::run()
(Leftover data: #1 MapBlock* ServerMap::loadBlock(v3s16))
(Leftover data: #2 void ServerMap::loadBlock(std::string*, v3s16, MapSector*, bool))
(Leftover data: #3 void ItemStack::deSerialize(std::istream&, IItemDefManager*))
DEBUG STACK FOR THREAD 7fc0b75fe700:
#0 virtual void* CurlFetchThread::run()
DEBUG STACK FOR THREAD 7fc0b7fff700:
#0 virtual void* ServerThread::run()
#1 void Server::Receive()
(Leftover data: #2 void Server::SendBlocks(float))
(Leftover data: #3 void RemoteClient::GetNextBlocks(ServerEnvironment*, EmergeManager*, float, std::vector<PrioritySortedBlockTransfer>&))
(Leftover data: #4 void ItemStack::serialize(std::ostream&) const)
(Leftover data: #5 bool getCraftingResult(Inventory*, ItemStack&, std::vector<ItemStack>&, bool, IGameDef*))
(Leftover data: #6 bool getCraftingResult(Inventory*, ItemStack&, std::vector<ItemStack>&, bool, IGameDef*))
DEBUG STACK FOR THREAD 7fc0c76be7c0:
#0 int main(int, char**)
#1 Dedicated server branch
#2 void dedicated_server_loop(Server&, bool&)
#3 void Server::step(float)
- kaeza
- Moderator
- Posts: 2162
- Joined: Thu Oct 18, 2012 05:00
- GitHub: kaeza
- IRC: kaeza diemartin blaaaaargh
- In-game: kaeza
- Location: Montevideo, Uruguay
- Contact:
Re: Post your modding questions here
That could have helped a lot.BrunoMine wrote:Apparently I have to show the whole script.
Line 166:
Code: Select all
status_tp = true
EDIT: Also on line 113.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!
Check out my stuff! | Donations greatly appreciated! PayPal
Check out my stuff! | Donations greatly appreciated! PayPal
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Re: Post your modding questions here
No problems. Glad that it's solved.BrunoMine wrote:Sorry again.
Re: Post your modding questions here
Hi all. How add thrown snowball and other items? I mean default_snowball.png from default mod.
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
How genetare map
Is there any way to generate the map without a present player?
Who is online
Users browsing this forum: No registered users and 11 guests