News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[API script] get player_x id

Started by Yona-TYT, November 28, 2024, 09:28:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

I noticed that in the scripts tool the pl parameter is actually a player_x , so there is no method to get the player id.

0001-Add-player_x-get_id.patch

I need to send the player id (integral), because plain data does not accept class.


prissi

Would it not be better to change the script tools to accept player_x?

Yona-TYT

Quote from: prissi on December 03, 2024, 12:24:49 AMWould it not be better to change the script tools to accept player_x?
I think I don't understand you.

The script tools do accept player_x, the problem is that I didn't know how to get the player id.

But now I discovered that you can easily get the id from player_x, although I didn't see it in the documentation.

Example:
local player = player_x(1)
local id = player.id

Andarix


Yona-TYT

Quote from: Andarix on December 03, 2024, 05:57:45 AMlocal pl_id = player_x.nr

I noticed that this is only working on my builds, but releases are not working.
Can you confirm this?.
Captura de pantalla -2024-12-08 15-58-35.png

It seems that get_id() is needed, if I revert the patch changes, player_x.id will no longer work.

@Prissi, can you merge this?. 0001-Add-player_x-get_id.patch

prissi


Yona-TYT

Quote from: prissi on December 08, 2024, 11:45:28 PMplayer.nr works for me in normal builds.
That's strange, it doesn't work for me, are you using a script tool in your case?.