Posted 23 September 2016 - 08:37 PM
Hi,
I'm currently trying to write a program which shows the name and the qty of items in a deep storage unit on a monitor.
I'm trying to make a universal program so you can connect as many dsu's as you want to…
The problem is my code will make just a make string, that stands for "peripheral.wrap("deep_storage_unit_0")" and not command that i can execute.
How can i change that ?
This code will make a table filled with "peripheral.wrap("deep_storage_unit_xx") which I obviously want to use later. (e. g. dsus[2].getStoredItems["qty"])
I know that the read() part isn't good becaus nobody know what to write but it's just a test code so dont worry i'll change that in the future.
Btw, I'm new to lua and all that string.format commands i just googled so i guess there is a far better way to do this, maybe you'll let me know :D/>
I'm currently trying to write a program which shows the name and the qty of items in a deep storage unit on a monitor.
I'm trying to make a universal program so you can connect as many dsu's as you want to…
The problem is my code will make just a make string, that stands for "peripheral.wrap("deep_storage_unit_0")" and not command that i can execute.
How can i change that ?
local dsus = {}
begin = read()
stop = read()
local i = 0
for begin, stop do
dsus[i] = string.format("%s(%q%s", "peripheral.wrap", string.format("%s_%i", "deep_storage_unit",begin),")")
i = i + 1
end
This code will make a table filled with "peripheral.wrap("deep_storage_unit_xx") which I obviously want to use later. (e. g. dsus[2].getStoredItems["qty"])
I know that the read() part isn't good becaus nobody know what to write but it's just a test code so dont worry i'll change that in the future.
Btw, I'm new to lua and all that string.format commands i just googled so i guess there is a far better way to do this, maybe you'll let me know :D/>