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