on_player_setup_blueprint ?

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

on_player_setup_blueprint ?

Post by d3x0r »

on_player_setup_blueprint seems like a pretty useless event...
I was hoping that would be called after the items were set into the blueprint, but before it shows to the player. Rail Power System uses a ghost entity power pole, this shows on the blueprint, but when the blueprint is built the power pole isn't. So I was hoping to change the item in the blueprint to the correct item so it would get built. Seems like doing this fixup during on_player_configured_blueprint would be too late; since the player would have already been accepting what is in the blueprint. (Although it does work to do my fixup there) Unfortunatly components shows a blank icon until the blueprint is re-opened for configuration.

Code: Select all

	local player = game.players[event.player_index]
	local stack = player.cursor_stack
	if not stack.valid then 
		log( "stack not valid" );
		return
	end
	if not stack.valid_for_read then
		log( "stack not valid for read" );
		return
	end
valid_for read is not true; and if I skip that and continue, of course it crashes when I do local entities = stack.get_blueprint_entities().


.

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

Re: on_player_setup_blueprint ?

Post by Rseding91 »

The blueprint item isn't actually in the cursor when the player sets up a blueprint. It's stored in a different stack which isn't currently exposed through the Lua API. I'll see about adding in support to read/modify it but it might not make it into 0.15.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding discussion”