Log In  


I'm trying to make a block-coding program, but I need to store a reference to a variable. As in, whenever you try and get a value of something, it returns the variable. If there's no way to do this, then I have other ideas. Anyway, heres what I got:

block = {
 func = print

 params = {
  x,
  63,
  63,
  7
 }
}

However, it just assumes the current value of x rather that storing a reference to it. How would I go about doing this?



You can store a function that returns the params. The variable value will be looked up every time the function is called, not when the table is defined.

E.g.

block = {
 func = print;
 params = function()
  return {x,63,63,7}
 end;
}

hmmm func calls could work I guess though that seems a bit clunky to maintain,
Off the top of my head you could store them in a table with a string key and look up based on that like "x" = ...
Unless I'm missing something lua really only gives you refrences to tables


@SmellyFishtiks: Oops! I edited my message while you were replying to it. So my message now addresses the concerns you raised with my original code.



[Please log in to post a comment]