Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Error in @ignatz code

edited March 21 in Questions Posts: 815

Hi All,

Can anyone help me, I have encountered a problem several times which is @Ignatz code. It involves passing parameters including a table in the following line:


function AddTerrain(...) local x,y,z,w,d,p,f,h,r,n,tbl,img,sc,hm,ns=Params( {"x","y","z","width","depth","tileSize","minY","maxY","random","noiseLevel", "heightTable","img","scaleFactor","heightMaps","noiseStep"},arg) local nw,nd=math.floor(w/p),math.floor(d/p) --number of tiles in each direction --if no table of heights provided, generate one with noise if tbl==nil then

It reports an error as ‘attempt to index a nil value (local ‘tbl’)’. and refers to the last line in the above code. The code is checking to see if the table is occupied or not. The code is part of an early 3D terrain demo made by Ignatz.

Comments

  • Posts: 402

    This could be from the update to lua5.3 which handles parameters to functions slightly differently. Try putting {...} in place of arg at the end of the Params call (note: it might need some similar work in the Params function itself).

  • Posts: 815

    @LoopSpace - thanks for that, spot on resolved that issue and you were also correct in the parameters that all need reducing to integers. Always thought Lua needed an integer type, makes everything tidier. And more precise.

Sign In or Register to comment.