get assembling recipe

Place to get help with not working mods / modding interface.
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

get assembling recipe

Post by drs9999 »

Hello, I just looked trough the wiki and saw that there is a handler to get the assembling machines recipe. So I tried to add it to the BP mod.

First the given example:

Code: Select all

game.player.print(game.player.selected.recipe.name) -- prints the recipe of the selected assembling machine
do not work for me.
I have to use game.player.controller.getselected() instead of game.player.selected

But still then recipe nor recipe.name are valid keys.

So is it a bug or just me doing something stupid?!
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: get assembling recipe

Post by rk84 »

This should work.

Code: Select all

game.player.print(game.player.controller.getselected().getrecipe().name)
Last edited by rk84 on Sun Oct 06, 2013 3:52 pm, edited 2 times in total.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: get assembling recipe

Post by ficolas »

It says game.player.selected on the wiki? Then it should be changed I guess :)

I didnt know this existed I needed it and I thnk I also asked for it but I dont remember :s
Anyways now I can use it :)
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: get assembling recipe

Post by FreeER »

Actually game.player.selected is for 0.7.1, it is being changed to a property rather than a method of the player (like it is now). Actually several methods are changing to properties, read Random Ramblings #4
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: get assembling recipe

Post by ficolas »

FreeER wrote:Actually game.player.selected is for 0.7.1, it is being changed to a property rather than a method of the player (like it is now). Actually several methods are changing to properties, read Random Ramblings #4
Aaaaah did not remember that :)
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: get assembling recipe

Post by drs9999 »

ficolas wrote:Aaaaah did not remember that :)
Oh me too :D
slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: get assembling recipe

Post by slpwnd »

Unfortunately this might break quite some mods. But in the long run it is better to have cleaner and simpler api.
User avatar
Nova
Filter Inserter
Filter Inserter
Posts: 960
Joined: Mon Mar 04, 2013 12:13 am
Contact:

Re: get assembling recipe

Post by Nova »

Factorio is still alpha, every update has the capability to break any mod. Better break them now than in the final version or have a messy mod api. ;)
Post Reply

Return to “Modding help”