View difference between Paste ID: 41Xa2epC and YKKdLG6p
SHOW: | | - or go back to the newest paste.
1
-- BM Altar Automation by Apoc
2
-- v1.0 - 2/20/2016
3
--              Initial Release
4
5
local altarPeripheralName = "tealtar_0"
6
local altarBufferChestDir = "north"
7-
local altarBufferChestName = "diamond_0"
7+
local altarBufferChestName = "diamond_2"
8
local altarOutputChestDir = "south"
9
-- Whether or not the script will wait for the altar to have enough LP in it to do the craft
10
-- Suggested that this is 'false' if you run a well of suffering, or know that you will have enough LP for any given craft
11
-- Not yet implemented :(/>/>
12
local checkAltarLPLevelsFirst = false
13
14
local recipes = {
15
-- "Vanilla" Blood Magic (Stone -> Slate)
16
-- {source="Minecraft:blockStone", final="AWWayofTime:blankSlate", lp=1000},
17
18
-- FTB Infinity Evolved (Expert) Blood Magic (Arcane Stone Block -> Slate)
19-
{source="Thaumcraft:blockCosmeticSolid:6", final="AWWayofTime:blankSlate", lp=1000},
19+
{source="minecraft:stone", final="AWWayofTime:blankSlate", lp=1000},
20
21
22
{source="AWWayofTime:blankSlate", final="AWWayofTime:reinforcedSlate", lp=2000},
23
{source="AWWayofTime:reinforcedSlate", final="AWWayofTime:imbuedSlate", lp=5000},
24
{source="AWWayofTime:imbuedSlate", final="AWWayofTime:demonicSlate", lp=15000},
25
{source="AWWayofTime:demonicSlate", final="AWWayofTime:bloodMagicBaseItems:27", lp=30000},
26
{source="minecraft:glowstone", final="AWWayofTime:dawnScribeTool", lp=20000},
27-
{source="minecraft:nether_star", final="AWWayofTime:enhancedTelepositionFocus", lp=10000},
27+
{source="AWWayofTime:telepositionFocus", final="AWWayofTime:enhancedTelepositionFocus", lp=10000},
28-
{source="Botania:manaResource:1", final="AWWayofTime:telepositionFocus", lp=10000},
28+
{source="minecraft:ender_pearl", final="AWWayofTime:telepositionFocus", lp=10000},
29
{source="AWWayofTime:blockCrystal", final="AWWayofTime:transcendentBloodOrb", lp=200000},
30
{source="AWWayofTime:demonBloodShard", final="AWWayofTime:archmageBloodOrb", lp=75000},
31
{source="minecraft:glass_bottle", final="AWWayofTime:alchemyFlask", lp=2000},
32
-- Add other recipes here if you want.
33
}
34
35
local altar = peripheral.wrap(altarPeripheralName)
36
local chest = peripheral.wrap(altarBufferChestName)
37
38
39
function getAltarItem()
40
  local stack = altar.getStackInSlot(1)
41
  if not stack then return nil end
42
  return stack.name
43
end
44
45
function altarHasOrb()
46
  local item = getAltarItem()
47
  if item ~= nil and string.find(item, "Orb") then
48
        return true
49
  else
50
        return false
51
  end
52
end
53
54
function chestHasOrb()
55
        return getChestOrbSlot() ~= 0
56
end
57
58
function getChestOrbSlot()
59
        for i=1, chest.getInventorySize() do
60
                if chest.getStackInSlot(i) then
61
                        if string.find(chest.getStackInSlot(i).name, "Orb") then
62
                                return i
63
                        end
64
                end
65
        end
66
        return 0
67
end
68
69
function putOrbInAltar()
70
        -- Only check if there is *any* item there. We may be crafting something
71
        -- if the orb is there already, there's no point in running this yet anyway.
72
        if getAltarItem() == nil then
73
                if not chestHasOrb() then
74
                        error("The buffer chest does not have an orb in it, and we expect one for re-charging the LP network. Did you remove it?")
75
                end
76
                print("Moving Blood Orb back into the altar to charge LP")
77
                altar.pullItem(altarBufferChestDir, getChestOrbSlot(), 1)
78
                sleep(0.5)
79
        end
80
end
81
82
function removeOrbFromAltar()
83
        if altarHasOrb() then
84
                altar.pushItem(altarBufferChestDir, 1)
85
                sleep(0.5)
86
        end
87
end
88
89
function findCraftingRecipe(stack)
90
        local itemId = getItemId(stack)
91
        if itemId then
92
                for i=1, #recipes do
93
                        if recipes[i].source == itemId then
94
                                return recipes[i]
95
                        end
96
                end
97
        end
98
        return nil
99
end
100
101
function getItemId(stack)
102
        if stack then
103
                if stack.dmg ~= nil and stack.dmg ~= 0 then
104
                        return stack.id .. ":" .. stack.dmg
105
                else
106
                        return stack.id
107
                end
108
        end
109
        return nil
110
end
111
112
function craftSlate()
113
        for i=1, chest.getInventorySize() do
114
                -- Figure out if we have anything to craft
115
                local stack = chest.getStackInSlot(i)
116
                local recipe = findCraftingRecipe(stack)
117
                if stack ~= nil then
118
                        if recipe ~= nil then
119
                                removeOrbFromAltar()
120
                                print("Transmuting " .. stack.display_name)
121
                                altar.pullItem(altarBufferChestDir, i, 64)
122
                                --sleep(0.5)
123
                                while getItemId(altar.getStackInSlot(1)) ~= recipe.final do
124
                                        sleep(0.1)
125
                                end
126
                                --sleep(0.5)
127
                                altar.pushItem(altarOutputChestDir, 1, 64)
128
                                --sleep(0.5)
129
                                return true
130
                        end
131
                end
132
        end
133
        return false
134
end
135
136
137
while true do
138
        if not craftSlate() then
139
                putOrbInAltar()
140
                sleep(1)
141
        end
142
end