From b55641b7226da1bca7265ec7c10d5b61bc1776bf Mon Sep 17 00:00:00 2001 From: Kubuxu Date: Sat, 2 May 2015 16:45:27 +0200 Subject: [PATCH 1/3] Allow [name]/init.lua in require. This change allows to store complex libraries in one directory. --- .../resources/assets/opencomputers/loot/OpenOS/lib/package.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/lib/package.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/lib/package.lua index b83119b0b..cd8bf10fa 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/lib/package.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/lib/package.lua @@ -1,6 +1,6 @@ local package = {} -package.path = "/lib/?.lua;/usr/lib/?.lua;/home/lib/?.lua;./?.lua" +package.path = "/lib/?.lua;/usr/lib/?.lua;/home/lib/?.lua;./?.lua;/lib/?/init.lua;/usr/lib/?/init.lua;/home/lib/?/init.lua;./?/init.lua" local loading = {} From b96204dc56d20e96afa8ee5b042e2e70ba8ef167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 2 May 2015 21:36:18 +0200 Subject: [PATCH 2/3] Should fix #1119. --- .../scala/li/cil/oc/integration/appeng/DriverController.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala b/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala index 13d83ce8d..fdf3a09c7 100644 --- a/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala +++ b/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala @@ -57,7 +57,7 @@ object DriverController extends DriverTileEntity with EnvironmentAware { class Environment(tileEntity: AETile) extends ManagedTileEntityEnvironment[AETile](tileEntity, "me_controller") with NamedBlock { override def preferredName = "me_controller" - override def priority = 0 + override def priority = 5 @Callback(doc = "function():table -- Get a list of tables representing the available CPUs in the network.") def getCpus(context: Context, args: Arguments): Array[AnyRef] = @@ -281,4 +281,4 @@ object DriverController extends DriverTileEntity with EnvironmentAware { } } -} \ No newline at end of file +} From 6851128cc2b66350ecf9ac6ebf6c8c4d04c17737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 3 May 2015 16:10:27 +0200 Subject: [PATCH 3/3] Add support for generic recipes in recipe declaration (i.e. arbitrary output). Added recipe for end stone, for people that absolutely, positively can't be bothered to go to the end, but still want drones... --- .../opencomputers/recipes/default.recipes | 9 +++++++ .../li/cil/oc/common/recipe/Recipes.scala | 24 ++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/opencomputers/recipes/default.recipes b/src/main/resources/assets/opencomputers/recipes/default.recipes index bfb7698b4..83f905aff 100644 --- a/src/main/resources/assets/opencomputers/recipes/default.recipes +++ b/src/main/resources/assets/opencomputers/recipes/default.recipes @@ -36,6 +36,15 @@ luaBios { type: shapeless input: ["oc:eeprom", "oc:manual"] } +generic: [ + { + result: {block="minecraft:end_stone"} + input: [[enderPearl, sandstone, enderPearl] + [sandstone, blockCoal, sandstone] + [enderPearl, sandstone, enderPearl]] + output: 4 + } +] droneCase1 { input: [[{block="minecraft:end_stone"}, compass, {block="minecraft:end_stone"}] diff --git a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala index ec5ac0ffe..3f5c764f2 100644 --- a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala +++ b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala @@ -127,7 +127,7 @@ object Recipes { val value = recipes.getValue(name) value.valueType match { case ConfigValueType.OBJECT => - addRecipe(stack, recipes.getConfig(name), "'" + name + "'") + addRecipe(stack, recipes.getConfig(name), s"'$name'") case ConfigValueType.BOOLEAN => // Explicitly disabled, keep in NEI if true. if (!value.unwrapped.asInstanceOf[Boolean]) { @@ -150,7 +150,7 @@ object Recipes { for (recipe <- lootRecipes) { val name = recipe.getString("name") Loot.builtInDisks.get(name) match { - case Some((stack, _)) => addRecipe(stack, recipe, "loot disk '" + name + "'") + case Some((stack, _)) => addRecipe(stack, recipe, s"loot disk '$name'") case _ => OpenComputers.log.warn(s"Failed adding recipe for loot disk '$name': No such global loot disk.") hadErrors = true @@ -163,6 +163,24 @@ object Recipes { hadErrors = true } + if (recipes.hasPath("generic")) try { + val genericRecipes = recipes.getConfigList("generic") + for (recipe <- genericRecipes) { + val result = recipe.getValue("result").unwrapped() + parseIngredient(result) match { + case stack: ItemStack => addRecipe(stack, recipe, s"'$result'") + case _ => + OpenComputers.log.warn(s"Failed adding generic recipe for '$result': Invalid output (make sure it's not an OreDictionary name).") + hadErrors = true + } + } + } + catch { + case t: Throwable => + OpenComputers.log.warn("Failed parsing generic recipes.", t) + hadErrors = true + } + // Recrafting operations. val navigationUpgrade = api.Items.get(Constants.ItemName.NavigationUpgrade) val mcu = api.Items.get(Constants.BlockName.Microcontroller) @@ -314,7 +332,7 @@ object Recipes { def tryGetCount(recipe: Config) = if (recipe.hasPath("output")) recipe.getInt("output") else 1 - def parseIngredient(entry: AnyRef) = entry match { + def parseIngredient(entry: AnyRef): AnyRef = entry match { case map: java.util.Map[AnyRef, AnyRef]@unchecked => if (map.contains("oreDict")) { map.get("oreDict") match {