Page 1 of 1

on_player_used_capsule, missing surface where the event happen

Posted: Thu Apr 23, 2020 10:56 am
by Linver
Hi, using the on_player_used_capsule event, I need the surface where the capsule is throwed, that I get from the actual player character (that isn't the correct way), but if is possible have it directly in the event attributes, I think will be better. Many events that provide only the position of something, don't give precise informations, because in Factorio the position is relative to the surface, in my case I can't scan near the capsule position, because I need to know the surface to start doing any kind of find search.

Re: on_player_used_capsule, missing surface where the event happen

Posted: Thu Apr 23, 2020 11:13 am
by Klonan
Linver wrote:
Thu Apr 23, 2020 10:56 am
that I get from the actual player character (that isn't the correct way)
Why do you say it isn't the correct way?

Re: on_player_used_capsule, missing surface where the event happen

Posted: Thu Apr 23, 2020 2:29 pm
by Rseding91
You get the surface by reading player.surface - just like the actual use-capsule game logic does right before it sends that event.

What's the problem with doing it that way?

Re: on_player_used_capsule, missing surface where the event happen

Posted: Mon Apr 27, 2020 7:42 pm
by Linver
In Factorio positions are relative to the surfaces, give a position without the correlated surface is an incomplete information.

I can get the surface from the character of the player that trigger the event, but cost to the script to do much more work (like look for character entity and test validation of all related objects), and the game don't grant that is the correct suface, is only supposed, I don't know if is possible trigger this event with some witchcraft from other surfaces, maybe with fast character switchs.

Re: on_player_used_capsule, missing surface where the event happen

Posted: Tue Apr 28, 2020 12:31 am
by Rseding91
You don't need to touch the player character. You read the surface directly off the player:

Code: Select all

game.get_player(event.player_index).surface