I’m coding an inventory system in Computer Craft and I’d like to know if it would be possible to make a file edit variable that it doesn’t exactly know about…
Here’s my file structure:
root
inv.lua
chestAPI
inv_list.lua
inv_scan.lua
So my inv_scan.lua
file scans all my inventories and stores the data in a 2D array.
My inv_list.lua
file is supposed to take that data and print it to a monitor.
Scanning all the inventories takes some time and I’d like to only do it once when you boot up the computer OR when you click refresh on the monitor to keep it optimized.
My listing script needs the scan script’s variables to be able to print anything. The inv.lua
script controls everything. It currently calls the scanning script when it gets executed and the it waits for a user input (because I’m going to add scripts to add or fetch items from the storage.
So I want the inv.lua
to call the scan, get all the variables, shoot them to the listing script if the user wants to display the items, and then the listing will read them and print them.
I could do everything in one file but it would be horribly organized.
I tried using require(), but then the listing would always call the scan and it wouldn’t be as optimized as I want it to be.
That’s pretty much the only thing I tried that gave me a result. I learned Lua while making this project so I’m not that familiar with everything.
Nola is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.