Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

okay...Here's a simplified version of my generation code to test the application. it has all the problems of the original code (I've tested it extensively) If you run it in TIC-80, you'll see that the problem is in the get_obj() function. The attributes end up nil.

The get_attrib() function seems to retrieve the data correctly, but it may have a problem returning the value.

Or maybe there's a problem calling a function with a return value from within another function.

 I can't seem to figure out why there's a problem assigning my attributes. anybody got any ideas?


--script: lua

attribs={"spam","toast","blah"}
objs={}

--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={
attrib1=get_attrib(),
attrib2=get_attrib(),
attrib3=get_attrib()}

  trace("objects returned attributes...")
trace(attrib1,6)
trace(attrib2,6)
  trace(attrib3,6)
trace("")

  --log the object in the "objs" table
  trace("logging object",5)
  trace("")
table.insert(objs,#objs+1,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 
 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(attrib1,6)
trace(attrib2,6)
trace(attrib3,6)
trace("")
end
trace("end of process",6)
 exit()
end