set_pos work not

Post Reply
User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

set_pos work not

by debiankaios » Post

I have a problem, i have set_pos programmed:

Code: Select all

object:set_pos(checkpoint)
But this error come:

Code: Select all

AsyncErr: ServerThread::run Lua: Runtime error from mod 'deathrun' in callback on_respawnplayer(): /home/debiankaios/.minetest/mods/deathrun/auto.lua:8: attempt to call method 'set_pos' (a nil value)
stack traceback:
	/home/debiankaios/.minetest/mods/deathrun/auto.lua:8: in function </home/debiankaios/.minetest/mods/deathrun/auto.lua:5>
	/usr/share/games/minetest/builtin/game/register.lua:429: in function </usr/share/games/minetest/builtin/game/register.lua:413>

User avatar
rubenwardy
Moderator
Posts: 6424
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: set_pos work not

by rubenwardy » Post

Object won't be an object in that case

Please post the rest of your code - a single line often doesn't show the problem

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

rubenwardy wrote: ↑
Sat Jan 30, 2021 20:02
Object won't be an object in that case

Please post the rest of your code - a single line often doesn't show the problem

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  local object = player:get_player_name()
  object:set_pos(checkpoint)
end)

User avatar
davidthecreator
Member
Posts: 382
Joined: Mon Aug 18, 2014 19:48
GitHub: daviddoesminetest
In-game: DavidDoesMinetest
Location: Lithuania

Re: set_pos work not

by davidthecreator » Post

IDK...

Maybe try just using the player itself right away, instead of "object" that is actually player's name and see if it works ? ...

player:set_pos(checkpoint)

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

davidthecreator wrote: ↑
Sun Jan 31, 2021 10:49
IDK...

Maybe try just using the player itself right away, instead of "object" that is actually player's name and see if it works ? ...

player:set_pos(checkpoint)
No there come the same error

User avatar
davidthecreator
Member
Posts: 382
Joined: Mon Aug 18, 2014 19:48
GitHub: daviddoesminetest
In-game: DavidDoesMinetest
Location: Lithuania

Re: set_pos work not

by davidthecreator » Post

Odd...

Maybe you have to define the checkpoint before using it, if it's not global?
Last edited by davidthecreator on Sun Jan 31, 2021 11:09, edited 1 time in total.

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

davidthecreator wrote: ↑
Sun Jan 31, 2021 11:07
Odd...
What?

User avatar
davidthecreator
Member
Posts: 382
Joined: Mon Aug 18, 2014 19:48
GitHub: daviddoesminetest
In-game: DavidDoesMinetest
Location: Lithuania

Re: set_pos work not

by davidthecreator » Post

debiankaios wrote: ↑
Sun Jan 31, 2021 11:09
What?
Are you getting the same error still, or is MineTest crashing over checkpoint now?

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

davidthecreator wrote: ↑
Sun Jan 31, 2021 11:10
debiankaios wrote: ↑
Sun Jan 31, 2021 11:09
What?
Are you getting the same error still, or is MineTest crashing over checkpoint now?
The same!

User avatar
rubenwardy
Moderator
Posts: 6424
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: set_pos work not

by rubenwardy » Post

debiankaios wrote: ↑
Sun Jan 31, 2021 10:03

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  local object = player:get_player_name()
  object:set_pos(checkpoint)
end)
The problem is here:

Code: Select all

local object = player:get_player_name()
This line stores the player name into the object variable. Player names are text - strings - and so don't have a set_pos method. Player names are also not ObjectRefs.

You need to call set_pos() on the ObjectRef, not on the player name. You already have an ObjectRef available - player.

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  player:set_pos(checkpoint)
end)

User avatar
davidthecreator
Member
Posts: 382
Joined: Mon Aug 18, 2014 19:48
GitHub: daviddoesminetest
In-game: DavidDoesMinetest
Location: Lithuania

Re: set_pos work not

by davidthecreator » Post

Try using
{x=0,y=0,z=0}
Instead of " checkpoint "...
If you get teleported somewhere, then there is a problem with how checkpoint is defined...

If it still crashes... I have no clue what is wrong anymore...

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

rubenwardy wrote: ↑
Sun Jan 31, 2021 11:18
debiankaios wrote: ↑
Sun Jan 31, 2021 10:03

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  local object = player:get_player_name()
  object:set_pos(checkpoint)
end)
The problem is here:

Code: Select all

local object = player:get_player_name()
This line stores the player name into the object variable. Player names are text - strings - and so don't have a set_pos method. Player names are also not ObjectRefs.

You need to call set_pos() on the ObjectRef, not on the player name. You already have an ObjectRef available - player.

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  player:set_pos(checkpoint)
end)
Thank you, work now!

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

rubenwardy wrote: ↑
Sun Jan 31, 2021 11:18
debiankaios wrote: ↑
Sun Jan 31, 2021 10:03

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  local object = player:get_player_name()
  object:set_pos(checkpoint)
end)
The problem is here:

Code: Select all

local object = player:get_player_name()
This line stores the player name into the object variable. Player names are text - strings - and so don't have a set_pos method. Player names are also not ObjectRefs.

You need to call set_pos() on the ObjectRef, not on the player name. You already have an ObjectRef available - player.

Code: Select all

minetest.register_on_respawnplayer(function(player, pos)
  if not arena_lib.is_player_in_arena(player:get_player_name(), "deathrun") then return end
  player:set_pos(checkpoint)
end)
Thank you, work now!

User avatar
debiankaios
Member
Posts: 304
Joined: Thu Dec 03, 2020 12:48
In-game: debiankaios Nowe
Location: germany
Contact:

Re: set_pos work not

by debiankaios » Post

Code: Select all

AsyncErr: ServerThread::run Lua: Runtime error from mod 'deathrun' in callback on_respawnplayer(): Invalid position coordinate 'x' (expected number got nil).
stack traceback:
	[C]: in function 'set_pos'

MisterE
Member
Posts: 238
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: set_pos work not

by MisterE » Post

use move_to

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests