Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Sorry, but this is a very strange code)
That's how it works:

--script: lua
attribs={"spam","toast","blah"}
--get a random attribute
function get_attrib()
  trace("getting attribute...",14)
  local random=math.random(1,3)
  local attrib=attribs[random]
  trace("gotten attribute is...")
  trace(attrib,9)
  trace("")
  return attrib
end
--get an object with three attributes
function get_obj()
  trace("building object...",8)
  local z={
    get_attrib(),
    get_attrib(),
    get_attrib()
  }
  trace("objects returned attributes...")
  trace(z[1],6)
  trace(z[2],6)
  trace(z[3],6)
  trace("")
  return z
end
function TIC()
  --test get_attrib() return directly
  trace("getting a test attribute",8)
  temp=get_attrib()
  trace("test attribute...")
  trace(temp,2)
  trace("")
  --log an object 
  local objs = get_obj()
  --iterate through objects and test for
  --certain attributes
  trace("started object testing",8)
  for i,v in pairs(objs) do
    trace("object attributes are")
    trace(v,6)
    trace("")
  end
  trace("end of process",6)
  exit()
end