Jump to content


VADemon's Content

There have been 2 items by VADemon (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#196680 [SOLVED] [Lua] nested pairs() error

Posted by VADemon on 21 October 2014 - 08:44 PM in Ask a Pro

Thanks for the reply.
So it's either LuaJ or Lua 5.1, cause my code indeed works with plain Lua 5.2.

Workaround: instead directly editing the table that's being iterated through, either edit the original (global) table or create a temporary new one.



#196667 [SOLVED] [Lua] nested pairs() error

Posted by VADemon on 21 October 2014 - 07:34 PM in Ask a Pro

Hi,

I need help with a strange error within nested pairs()

Script description: A customizable crafting (stamper) turtle. To define crafting recipes I used the following construction:
craftingGrid = {-- main table containing all possible recipes
	compressedSawdust = { -- how to craft this item
		true,	 true,	true,	false, -- for slots 1-16, true when there must be an item in the slot, false when not
		true,	 false, true,	false,
		true,	 true,	true,	false,
		false,	 false,	false,	false
	}
}

This table is then used and modified by the "initCraftingGrid" function which fails on the second for-loop with in pairs(gridValue) do with the following error:
line 30: invalid key to 'next'

Any idea what's causing this? Honestly, looks to me like an internal error

Full code:
Spoiler
Temporary link for testing: http://pastebin.com/72Hwre1W

Version: ComputerCraft1.64

UPD: This nested pairs() construction doesn't cause any errors on Lua: Demo
Spoiler