This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Marval's profile picture

How to split long program for few smaller

Started by Marval, 07 October 2012 - 02:18 PM
Marval #1
Posted 07 October 2012 - 04:18 PM
Hi, I writing program using ARP addon for crafting thinks and its going to be very long, when I want to add one item, I must scroll and scroll up and down, is the way to split this on some, for example, apis? This is my code http://pastebin.com/i9mwNZ1J . This is maybe not something owesome but it works :D/>/>
MysticT #2
Posted 07 October 2012 - 04:38 PM
Well, you could put all the items in an api, so they are in a separate file. Then, for the crafting function, using a table would shorten the code a lot, something like:

local tCraft = {
["Furnace"] = piecrec,
["Copper Cable"] = copcablerec,
-- etc.
}

local function crafting(:D/>/>
  if tCraft[b] then
    craftuj(tCraft[b])
  else
    surowce(;)/>/>
  end
end

-- to call:
crating("Furnace")
remiX #3
Posted 07 October 2012 - 05:10 PM
Well, you could put all the items in an api, so they are in a separate file. Then, for the crafting function, using a table would shorten the code a lot, something like:

-- to call:
crating("Furnace")

crafting*? :D/>/>
Marval #4
Posted 07 October 2012 - 06:47 PM
Thank You very much. This is what I want :D/>/>