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 = {

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

P#118844 2022-10-09 17:13

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.


block = {
 func = print;
 params = function()
  return {x,63,63,7}
P#118845 2022-10-09 17:20 ( Edited 2022-10-10 06:32)

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

P#118846 2022-10-09 17:42

@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.

P#118850 2022-10-09 19:34

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-18 23:13:22 | 0.037s | Q:15