EDIT: This cannot be right.
Code: Select all
game.print("Count of " .. line.get_item_count() .. " with contents table size " .. #line.get_contents())

Code: Select all
game.print("Count of " .. line.get_item_count() .. " with contents table size " .. #line.get_contents())
Code: Select all
/c game.print(serpent.line(game.player.selected.get_transport_line(1).get_contents()))
A k-v for loop was the first thing I tried (my code was literally doing that when I noticed it was not working). Nothing happened, because it was iterating over an empty set.eradicator wrote:You're doing it wrong™. get_contents() returns a dictionary (string indexed), not an array (continuous integer indexed) so # operations return undefined results. To iterate through the results you need to use a for item_name,count in pair(get_contents()) do loop.
Code: Select all
/c game.print(serpent.line(game.player.selected.get_transport_line(1).get_contents()))
So does the code i posted not work (i.e. print a table with belt content) when you use it in game (while selecting a belt with items on it)? I'm still on 16.12 (slow connection >_>), so there's a small possibility that it broke after that.Reika wrote:A k-v for loop was the first thing I tried (my code was literally doing that when I noticed it was not working). Nothing happened, because it was iterating over an empty set.eradicator wrote:You're doing it wrong™. get_contents() returns a dictionary (string indexed), not an array (continuous integer indexed) so # operations return undefined results. To iterate through the results you need to use a for item_name,count in pair(get_contents()) do loop.
Code: Select all
/c game.print(serpent.line(game.player.selected.get_transport_line(1).get_contents()))
Not on that belt, no.eradicator wrote:So does the code i posted not work (i.e. print a table with belt content) when you use it in game (while selecting a belt with items on it)? I'm still on 16.12 (slow connection >_>), so there's a small possibility that it broke after that.Reika wrote:A k-v for loop was the first thing I tried (my code was literally doing that when I noticed it was not working). Nothing happened, because it was iterating over an empty set.eradicator wrote:You're doing it wrong™. get_contents() returns a dictionary (string indexed), not an array (continuous integer indexed) so # operations return undefined results. To iterate through the results you need to use a for item_name,count in pair(get_contents()) do loop.
Code: Select all
/c game.print(serpent.line(game.player.selected.get_transport_line(1).get_contents()))
Odd. Loaders are a prime suspect to me as well, given that these ones use custom logic.eradicator wrote:Works fine here on a random circuit connected (en-/disabled) belt. I can see a loader on your picture. Maybe that's causing some issues. Can't test loaders myself. But splitters also always return {}.
It was not in the image, but I was trying both.Rseding91 wrote:It looks like that transport belt doesn't have items on one side? Try (2) to see if the other line is the one you're looking for.