Good vs. Evil

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
17 it is only 129 lines long
but then again the first 37 lines are only there because I hate to hard-code stuff and the functions to actually automate it start at stop at line 104 the rest is to use the functions and I wouldn't be surprised if I end up changing it to work with rednet or something
 

xTordX

New Member
Jul 29, 2019
576
-6
1
16 reading that like:

aaaaaaaaaaaaaaaaaajrbsucbdhdjfudvsbHFYjvfrikvBBHHVDYJNOPPI F73729:!;7:!28;@293!,!;!/).&/)?.!,83836
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
17 >_>
Code:
--declare all variables
--configuration
--chest coontaining the presses and the circuits. This is also the output(highest slot in gui)
local configPressChest        = "container_chest_9"
--the chest containing the printed silicon (lowest slot in the gui)
local configSiliconChest    = "container_chest_8"
--the chest containing the other materials(the middle slot in the gui)
local configMaterialChest    = "container_chest_11"
--not yet implemented
local sleepTime             = 1
--time in seconds needed to craft
local craftTime                = 10
--need better implementation (for all chests)
local materialChestSide     = "west"   
--amount of slots in the machine(inscriber has 4)
local machineSlots            = 4
--get all the peripherals
local chests={}
chests['top']                = peripheral.wrap(configPressChest)
chests['bottom']            = peripheral.wrap(configSiliconChest)
chests[materialChestSide]    = peripheral.wrap(configMaterialChest)

--tables
--crafting recipes
local crafting={}
--silicon
crafting['printedSilicon']        ={'Inscriber Silicon Press',"Silicon"}
--printed circuits
crafting['printedLogic']        ={'Inscriber Logic Press','Gold Ingot'}
crafting['printedCalculation']    ={'Inscriber Calculation Press','Pure Certus Quartz Crystal'}
crafting['printedEngineering']    ={'Inscriber Engineering Press','Diamond'}
--processors
crafting['logicProcessor']        ={'Printed Logic Circuit','Redstone','Printed Silicon'}
crafting['calculationProcessor']={'Printed Calculation Circuit','Redstone','Printed Silicon'}
crafting['EngineeringProcessor']={'Printed Engineering Circuit','Redstone','Printed Silicon'}
--used to get the direction items need to be pushed or pulled from
local useableDirection={north="SOUTH",east="WEST",south="NORTH",west="EAST",top="DOWN",bottom="UP"}
--functions

function craft(ingredients)
    local items={}
    local amount=0
    local errorMessage=nil
    local succes=nil
    local errorMessage=nil
    --remove all items from the machine
    cleanup(machineSlots)
    --loop over all the items that need to be inserted
    for key,value in pairs(ingredients) do
        --insert the item
        succes,errorMessage=itemToInscriber(key,value)
        --if something went wrong give the error message
        if not succes then
            print(errorMessage)
            return false, errorMessage
        end
    end
    --wait until it is done and then all the items need to be removed from the machine
    sleep(craftTime)
    cleanup(machineSlots)
    return true
end
--put the item in the inscriber
function itemToInscriber(slot,needed)
    print("inserting ",needed)
    local pushed=0
    --loop over all the chests, to look if it has the needed items and insert them
    for chestKey, chest in pairs (chests) do
        --get a table with all the items in the current chest
        local items =chest.getAllStacks(false)
        --loop over all the items
        for key,value in pairs(items) do
            --check if the needed item is found
            if value['display_name']==needed then
                --if the current chests place does not match one of the possibilities give an error
                if useableDirection[chestKey] ==nil then
                    return false , chestKey.." is not a valid place for the chest to be."
                end
                --push the item to the machine, and get the amount of items that got pushed
                pushed=chest.pushItem(useableDirection[chestKey],key,1)
                --the amount of pushed items does match one, stop return true and no error message as there was no error to be seen
                if pushed==1 then
                    return true, nil
                end
            end
        end
    end
    --the needed item was not found or was found but couldn't be inserted, give error + error message
    return false,needed.." was not found in the chests"
end
--used to clean the inscriber up
function cleanup (slots)
    print("cleaning the machine")
    --loop over all the chests
    for chestKey,chest in pairs(chests) do
        --loop over all the items the machine has
        for times=1,slots do
            --make sure the chest has an usable direction
            if useableDirection[chestKey]~=nil then
                chest.pullItem(useableDirection[chestKey],times,64)
            end
        end
    end
end
       
--other variables
local what=nil

--main loop
while true do
    print("Welcome to LC's inscribe'omatic. How can I help you?")
    what=io.read()
    if crafting[what]~=nil then
        print("How much do you want to be made?")
        amount=io.read()
        print("I'm on it. Making this would require ",((craftTime*amount)+(sleepTime*amount))," seconds to make. Sorry for the inconvenience, I hope you can forgive me.")
        for make=1,amount do
            craft(crafting[what])
            sleep(sleepTime)
        end
        print("Sir, I am happy to say that your order is done. Look in the press chest to find your crafted items.")
    else
        print("I am so sorry sir, but I don't know how to make ",what,". I however do know how to make the following:")
        for key,value in pairs(crafting)do
            print(key)
        end
        print("I hope you can forgive me.")
    end
end
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
18 Something I hate in hearthstone is when the opponent let his turn rope because you have lethal on board and he can't stop you.
Just concede or end the turn and don't let me fricking wait so fricking long!
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
20 if they do that then I just go to the forum and when its finally my turn I do all the actions required to win except the last then read the forum a bit more until I hear the rope then I do the last action, or they concede before it happens. :p
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
22 they can concede whenever they want without changing anything. I can not.
I just beat fire with fire:p
It is even worse if they where a face hunter because they are so boring to play against all they do is play minion-> drag minion to opponents hero