Page 1 of 1

[Solved]Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 3:23 pm
by paraqles
I want to use the lab and its function as a user of science packs to generate "research power".
Unfortunately I can't figure out how the "remaining" of the science pack is handled and stored.'

From the API documentation, there is no corresponding value.
I tried:
- health
- durability (since a science pack is a tool)

Has someone more insight about that, and can help me with it?

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 3:35 pm
by Adil
When you insert a single portion of items in any consumer, those items disappear at the moment the work begins. If you mine the building, you don't get those back, so the remainder is likely to be stored nowhere.
I believe the lab progress bar shows how far in the consumption of currently inserted items it has gone.

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 3:46 pm
by paraqles
Sure that can be the thing.
But the "remaining" value is in the description tool tip that you get, when you hover over one of the science-pack stacks in the inventory of the lab.

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 8:00 pm
by Supercheese
I thought it was "durability", measured between 0 and 1, did that really not work?

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 10:04 pm
by paraqles
No, it does not work. Besides, that from the LuaAPI Documentation, "durability" is an unsigned integer, capped at max durability of the prototype (for science packs = 1)

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 10:16 pm
by prg
Hold a partially used science pack in the cursor stack and run

Code: Select all

/c game.local_player.print(game.local_player.cursor_stack.durability)

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Thu Apr 14, 2016 10:29 pm
by paraqles
prg wrote:Hold a partially used science pack in the cursor stack and run

Code: Select all

/c game.local_player.print(game.local_player.cursor_stack.durability)
What the heck?
The same code i did this morning, now does what i expected it would do.

And especially it does not comply to the API Documentation.

I have to thank you, the first thought was "Ah, man I tried that already", but at least i should give a try if there is a difference between a stack in lab and stack in hand (curosr).

Re: Lua: Science Pack | api call to change "remaining" value?

Posted: Fri Apr 15, 2016 8:17 am
by Rseding91
paraqles wrote:
prg wrote:Hold a partially used science pack in the cursor stack and run

Code: Select all

/c game.local_player.print(game.local_player.cursor_stack.durability)
What the heck?
The same code i did this morning, now does what i expected it would do.

And especially it does not comply to the API Documentation.

I have to thank you, the first thought was "Ah, man I tried that already", but at least i should give a try if there is a difference between a stack in lab and stack in hand (curosr).
What? It compiles perfectly with the API documentation and there's no difference between stacks in a lab vs. in the cursor.

Re: [Solved]Science Pack | api call to change "remaining" value?

Posted: Fri Apr 15, 2016 2:06 pm
by paraqles
Sorry I may be a little unclear:
http://lua-api.factorio.com/0.12.30/Lua ... durability

Says it is "uint" => http://lua-api.factorio.com/0.12.30/Bui ... .html#uint

So it does not behave like the documentation said.
And at my first try to use the durability it just kept the durability at "1".