View difference between Paste ID: 0z3LAXaZ and er9gJDD1
SHOW: | | - or go back to the newest paste.
1-
[9/26/2016 09:41:55.190 PM][LUA]Recipe: chemical-plant-4
1+
function bobmods.lib.recipe.replace_ingredient(recipe, old, new)
2-
[9/26/2016 09:41:55.190 PM][LUA]HELP(0)! chemical-plant-4
2+
  print("Hello from replace_ingredient in bobs!")
3-
[9/26/2016 09:41:55.192 PM][LUA]OUTPUTTING data.raw
3+
  print("Recipe: "..recipe)
4-
[9/26/2016 09:41:55.192 PM][LUA]table: 3c153a1
4+
  print("HELP(0)! "..recipe)
5-
[9/26/2016 09:41:55.192 PM][LUA]OUTPUTTING data.raw.recipe
5+
  print("OUTPUTTING data.raw")
6-
[9/26/2016 09:41:55.192 PM][LUA]table: b62fe6d
6+
  print(data.raw)
7-
[9/26/2016 09:41:55.192 PM][LUA]OUTPUTTING data.raw.recipe[recipe] 
7+
  print("OUTPUTTING data.raw.recipe")
8-
[9/26/2016 09:41:55.192 PM][LUA]table: fdefd3f
8+
  print(data.raw.recipe)
9-
[9/26/2016 09:41:55.192 PM][LUA]OUTPUTTING bobmods 
9+
  print("OUTPUTTING data.raw.recipe[recipe] ")
10-
[9/26/2016 09:41:55.192 PM][LUA]table: 3e3047e6
10+
  print(data.raw.recipe[recipe])
11-
[9/26/2016 09:41:55.192 PM][LUA]OUTPUTTING bobmods.lib 
11+
  print("OUTPUTTING bobmods ")
12-
[9/26/2016 09:41:55.192 PM][LUA]table: 37e547da
12+
  print(bobmods)
13-
[9/26/2016 09:41:55.192 PM][LUA]OUTPUTTING bobmods.lib.item 
13+
  print("OUTPUTTING bobmods.lib ")
14-
[9/26/2016 09:41:55.192 PM][LUA]table: 2b6856dd
14+
  print(bobmods.lib)
15-
[9/26/2016 09:41:55.192 PM][LUA]HALP I'M IN GET_TYPE AND ITS SCURRY advanced-processing-unit
15+
  print("OUTPUTTING bobmods.lib.item ")
16-
[9/26/2016 09:41:55.192 PM][LUA]HALP I'M LEAVING GET_TYPE AND ITS MORE SCURRY advanced-processing-unit
16+
  print(bobmods.lib.item)
17-
[9/26/2016 09:41:55.193 PM][LUA]HELP(1)! chemical-plant-4
17+
  
18-
[9/26/2016 09:41:55.193 PM][LUA]HALP I'M IN GET_TYPE AND ITS SCURRY advanced-processing-unit
18+
  if not data.raw.recipe[recipe] then
19-
[9/26/2016 09:41:55.193 PM][LUA]HALP I'M LEAVING GET_TYPE AND ITS MORE SCURRY advanced-processing-unit
19+
    return false
20-
[9/26/2016 09:41:55.193 PM][LUA]HALP I'M IN GET_TYPE AND ITS SCURRY nitinol-bearing
20+
  end
21-
[9/26/2016 09:41:55.193 PM][LUA]HALP I'M LEAVING GET_TYPE AND ITS MORE SCURRY nitinol-bearing
21+
  
22-
[9/26/2016 09:41:55.193 PM][LUA]Hello from replace_ingredient in bobs!
22+
  if data.raw.recipe[recipe] and bobmods.lib.item.get_type(new) then
23-
[9/26/2016 09:41:55.193 PM][LUA]Recipe: electrolyser-2
23+
    print("HELP(1)! "..recipe)
24-
[9/26/2016 09:41:55.193 PM][LUA]HELP(0)! electrolyser-2
24+
    local amount = 0
25-
[9/26/2016 09:41:55.193 PM][LUA]OUTPUTTING data.raw
25+
    for i, ingredient in pairs(data.raw.recipe[recipe].ingredients) do
26-
[9/26/2016 09:41:55.193 PM][LUA]table: 3c153a1
26+
      if ingredient[1] == old then
27-
[9/26/2016 09:41:55.193 PM][LUA]OUTPUTTING data.raw.recipe
27+
        amount = ingredient[2] + amount
28-
[9/26/2016 09:41:55.193 PM][LUA]table: b62fe6d
28+
      end
29-
[9/26/2016 09:41:55.193 PM][LUA]OUTPUTTING data.raw.recipe[recipe] 
29+
      if ingredient.name == old then
30-
[9/26/2016 09:41:55.193 PM][LUA]nil
30+
        amount = ingredient.amount + amount
31-
[9/26/2016 09:41:55.193 PM][LUA]OUTPUTTING bobmods 
31+
      end
32-
[9/26/2016 09:41:55.193 PM][LUA]table: 3e3047e6
32+
    end
33-
[9/26/2016 09:41:55.193 PM][LUA]OUTPUTTING bobmods.lib 
33+
    if amount > 0 then
34-
[9/26/2016 09:41:55.193 PM][LUA]table: 37e547da
34+
      bobmods.lib.recipe.remove_ingredient(recipe, old)
35-
[9/26/2016 09:41:55.193 PM][LUA]OUTPUTTING bobmods.lib.item 
35+
      bobmods.lib.recipe.add_ingredient(recipe, {new, amount})
36-
[9/26/2016 09:41:55.193 PM][LUA]table: 2b6856dd
36+
      return true
37-
[9/26/2016 09:41:55.196 PM][ERROR][LUA-ERROR]Error loading __bobassembly__/data-updates.lua
37+
    else
38-
LuaError: @__boblibrary__/recipe-functions.lua:45 attempt to call nil     
38+
      return false
39-
     org.luaj.vm2.LuaValue.checkmetatag(LuaValue.java:3366)
39+
    end
40-
     org.luaj.vm2.LuaValue.callmt(LuaValue.java:1985)
40+
    print("HELP(2)! "..recipe)
41
  else
42
    print("HELP(3)! "..recipe)
43
    if not data.raw.recipe[recipe] then
44
      log("Recipe " .. recipe .. " does not exist.")
45
    end
46
    print("HELP(4)! "..recipe)
47
    if not bobmods.lib.item.get_type(new) then
48
      log("Ingredient " .. new .. " does not exist.")
49
    end
50
    print("HELP(5)! "..recipe)
51
    return false
52
  end
53
end