on_player_used_capsule, missing surface where the event happen

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

on_player_used_capsule, missing surface where the event happen

Post 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.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5148
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: on_player_used_capsule, missing surface where the event happen

Post 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?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13175
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_player_used_capsule, missing surface where the event happen

Post 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?
If you want to get ahold of me I'm almost always on Discord.

User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Re: on_player_used_capsule, missing surface where the event happen

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13175
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_player_used_capsule, missing surface where the event happen

Post 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
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding interface requests”