I need some help in improving my code in my Draconic tool tier i have five out that the recipes for the each tier is the same other then different key upgrades using it.
I'm new to coding thing in lua and i hoping posting would help in learning how to improve my code.
Heres my code.
local component =require("component")local sides =require("sides")local colors =require("colors")local rs = component.redstone
local tier =0local c =15--color also using enderio cables
whiletruedoif rs.getBundledInput(sides.top,colors.red)>0then--this part of ther code changes what tier it using redstone signals
tier = tier +1
ptier = tier -1
c = c -1
pc = c +1print("Tier",tier)
os.sleep(1)endif rs.getBundledInput(sides.top,colors.green)>0then
tier = tier -1
ptier = tier +1
c = c +1
pc = c -1print("Tier",tier)
os.sleep(1)end-- ignore this part of the code it old code i plan it reuse later ifmynew code doesn't work for what i'm using it for.--[[if ptier ~= tier and tier ~=0and rs.getInput(sides.top)then--if rs.getBundledInput(sides.top,colors.red)>0or rs.getBundledInput(sides.top,colors.green)>0and ptier ~= tier and tier ~=<1thenprint("color",c)print("prev. color",c)
rs.setBundledOutput(sides.back,pc,0)
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(1)
rs.setBundledOutput(sides.back,colors.black,0)end--]]if tier >0then--this checks if tier greater than 0 also makes my tier system works
print("color",c)--these print stuff are debug code to check if what my current color and before color and tier
print("pcolor",pc)print("ptier",ptier)
rs.setBundledOutput(sides.back,c,15)--this turns what on c isfor what tier is it for making so i shift what tiers i want extracting items to the injectors
if rs.getInput(sides.front)==1then
rs.setBundledOutput(sides.back,c,0)
os.sleep(1)end--ignore this i was wondering ifthis will fix mylast tiers being left on
--[[os.sleep(1)if ptier ==1and rs.getInput(sides.front)~=1then
rs.setBundledOutput(sides.back,pc,0)
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(2)
rs.setBundledOutput(sides.back,colors.black,0)
elseif ptier ==2and rs.getInput(sides.front)~=1then
rs.setBundledOutput(sides.back,pc,0)
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(2)
rs.setBundledOutput(sides.back,colors.black,0)
elseif ptier ==3and rs.getInput(sides.front)~=1then
rs.setBundledOutput(sides.back,pc,0)
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(2)
rs.setBundledOutput(sides.back,colors.black,0)end--]]if rs.getInput(sides.front)==0then--this part code i had hard time figuring out due i had no idea how to fix my past tiers being left on so suppect there some or lot of code needs to be fixed.
rs.setBundledOutput(sides.back,pc,0)
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(5)
rs.setBundledOutput(sides.back,colors.black,0)
os.sleep(5)
elseif ptier ~=0and ptier ~= tier then
rs.setBundledOutput(sides.back,pc,0)
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(5)
rs.setBundledOutput(sides.back,colors.black,0)
os.sleep(1)
ptier = tier
endendif tier ==0then--i need to figure out how fix this one.this part of the code makes so if its on tier 0 it would make sure all redstone signals are off but i need to figure how make the code stop once its done i think make need change how this works.for i =0,15doprint("color cont.",i)
os.sleep(1)if rs.getBundledOutput(sides.back,i)>0then
rs.setBundledOutput(sides.back,colors.black,15)
os.sleep(1)
rs.setBundledOutput(sides.back,i,0)endendend
os.sleep(1)--thisis there so i can breakmy loop
end
got any ideas or good way make this code better can please tell me.
oh i am using a modpack called sky factory 3 on 3.0.13 so i hope help you give idea on what mods i have.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I need some help in improving my code in my Draconic tool tier i have five out that the recipes for the each tier is the same other then different key upgrades using it.
I'm new to coding thing in lua and i hoping posting would help in learning how to improve my code.
Heres my code.
got any ideas or good way make this code better can please tell me.
oh i am using a modpack called sky factory 3 on 3.0.13 so i hope help you give idea on what mods i have.
Link to post
Share on other sites