[1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Bugs that are actually features.
User avatar
ZwerOxotnik
Fast Inserter
Fast Inserter
Posts: 115
Joined: Tue Dec 19, 2017 6:58 pm
Contact:

[1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by ZwerOxotnik »

Expected:
  • 1. Changed default respawn time after death
  • 2. Updated respawn time during death (which works fine)
Steps to reproduce:
  • Start a new game in single-player
  • Code: Select all

    /c game.player.ticks_to_respawn = 100
Actual Result:
  • 1. To my surprise, after that command I saw a notice that I "died" and then I was teleported to a respawn point with a new character without items etc., but the old character still exists in the previous position with the old inventory as a character, not a corpse. Also, `/c game.player.ticks_to_respawn = nil` doesn't do anything in this case, but `/c game.player.ticks_to_respawn = 0` does.
  • 2. Updated respawn time during death (as it's expected)
Notes:
  • I tested it in single-player v1.1.60 only
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 14403
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by Rseding91 »

Thanks for the report however how it is working is how it is meant to work. The respawn time is on the character prototype: https://wiki.factorio.com/Prototype/Cha ... spawn_time and is not adjustable runtime.
If you want to get ahold of me I'm almost always on Discord.
User avatar
ZwerOxotnik
Fast Inserter
Fast Inserter
Posts: 115
Joined: Tue Dec 19, 2017 6:58 pm
Contact:

Re: [1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by ZwerOxotnik »

Rseding91 wrote: Sat Jun 18, 2022 6:42 pm Thanks for the report however how it is working is how it is meant to work. The respawn time is on the character prototype: https://wiki.factorio.com/Prototype/Cha ... spawn_time and is not adjustable runtime.
Well, I wonder about the interaction still. It seems like LuaPlayer.ticks_to_respawn is less predictable than it is, but I have to test it more to confirm. I wonder, how it'd behave if some mod will use `player.ticks_to_respawn = nil`, but another mod will use `player.ticks_to_respawn = 1` after that.
Duplication of the character is weird.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14403
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by Rseding91 »

Writing a value to ticks_to_respawn forces the player into the respawn state regardless of where they were before. This doesn't kill the character entity they were previously controlling (if any). Additionally the character entity is just that; an entity. There can be any number of them in the game as mods/scripts want.

Code: Select all

/c game.player.surface.create_entity(name="character", position={1, 1}, force="player"}
will create another non-owned character entity on the player force.
If you want to get ahold of me I'm almost always on Discord.
User avatar
ZwerOxotnik
Fast Inserter
Fast Inserter
Posts: 115
Joined: Tue Dec 19, 2017 6:58 pm
Contact:

Re: [1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by ZwerOxotnik »

:)

Code: Select all

/c game.player.character.die() game.player.ticks_to_respawn = nil game.player.ticks_to_respawn = 10
Anyway, it doesn't seem to be important, but I guess it's possible to create unintentionally a character in events by mods in some cases.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14403
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by Rseding91 »

ZwerOxotnik wrote: Mon Jun 20, 2022 4:29 pm :)

Code: Select all

/c game.player.character.die() game.player.ticks_to_respawn = nil game.player.ticks_to_respawn = 10
Anyway, it doesn't seem to be important, but I guess it's possible to create unintentionally a character in events by mods in some cases.
That's the same as setting ticks_to_respawn on a not-dead player. All of this is documented on the Lua API page: https://lua-api.factorio.com/latest/Lua ... to_respawn
If you want to get ahold of me I'm almost always on Discord.
User avatar
ZwerOxotnik
Fast Inserter
Fast Inserter
Posts: 115
Joined: Tue Dec 19, 2017 6:58 pm
Contact:

Re: [1.1.60] confusion with "LuaPlayer.ticks_to_respawn"

Post by ZwerOxotnik »

Well, I always thought when a player with a character respawns, then the one has a corpse in most cases, so it's another case that I didn't count.

So, I have to make a little fix with LuaRendering to avoid visual bugs because of my assumption in some events.
Image
Post Reply

Return to “Not a bug”