How to print out which table inside a table is being used? [SOLVED]

I have this code in a enemy generator that for some reason is not rendering, but moving.

I want to be able to print out the value of the table (enemy) so I can see if its sending the right name. If I ask I ask it to print(local.enemy) I just get its a table but not which one. I also tried asking the obj created to printwhich sprite was assigned to it and they all said “redsprite” which is wrong so I want to see what table name is actually being send to the obj at creation etc.

-- enemy definition
local YELLOW = {
	sprite_id = hash("yellowsprite"),
	health = 10,
	speed = 100,
}

-- enemy definition
local RED = {
	sprite_id = hash("redsprite"),
	health = 100,
	speed = 10,
}

-- enemy definition
local BLUE = {
	sprite_id = hash("bluesprite"),
	health = 100,
	speed = 10,
}

-- enemy definition
local GREEN = {
	sprite_id = hash("greensprite"),
	health = 100,
	speed = 10,
}



function init(self)
	
	-- enemies to spawn
	self.enemies = {
		YELLOW,
		BLUE,
		YELLOW,
		GREEN,
		RED
	}

-- get the next enemy to spawn
	local enemy = table.remove(self.enemies)
	if enemy then		
		timer.delay(1, true, function()
			local url = "#factory"
			local position = vmath.vector3(-200, 200, 0) -- position where character spawns
			local rotation = vmath.quat_rotation_z(0) --quat angle the character spawns at
			local properties = { Start_path_ID = 1, End_path_ID = 100, speed = 400 } -- table of values to send to object
			local scale = vmath.vector3(0.5, 0.5, 0.51) -- scale to spawn at
			for key, val in pairs(enemy) do
				properties[key] = val --this adds the tables from enemy to the properties variable for factory.create
			end
			factory.create(url, position, rotation, properties, scale)

		end

you can use pprint(local.enemy).

That will print all the table in a nice (prettyprint) way

Okay Ill try thanks!

that gives this error:
/main/main.script
Line 51: Compilation failed: unexpected symbol near ‘local’

Nevermind i removed local and it worked

1 Like