Merge branch 'master-MC1.7.10' into master-MC1.10

# Conflicts:
#	src/main/scala/li/cil/oc/server/component/Trade.scala
#	src/main/scala/li/cil/oc/server/component/UpgradeTrading.scala
This commit is contained in:
payonel 2018-10-06 11:53:40 -07:00
commit 837edf6029
17 changed files with 51 additions and 28 deletions

View File

@ -93,9 +93,9 @@ In the case you wish to use Eclipse rather than IntelliJ IDEA, the process is mo
[api]: https://github.com/MightyPirates/OpenComputers/tree/master-MC1.7.10/src/main/java/li/cil/oc/api
[code conventions]: http://ocdoc.cil.li/lua_conventions
[dev-jar]: http://oc.cil.li/index.php?/page/latest.php?repo=OpenComputers-dev-MC1.7.10&type=dev
[forums]: http://oc.cil.li/
[code conventions]: https://ocdoc.cil.li/lua_conventions
[dev-jar]: https://oc.cil.li/index.php?/page/latest.php?repo=OpenComputers-dev-MC1.7.10&type=dev
[forums]: https://oc.cil.li/
[irc]: http://webchat.esper.net/?channels=#oc
[issues]: https://github.com/MightyPirates/OpenComputers/issues?state=open
[jenkins]: http://ci.cil.li/
@ -107,7 +107,7 @@ In the case you wish to use Eclipse rather than IntelliJ IDEA, the process is mo
[pack.mcmeta]: https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/resources/pack.mcmeta
[releases]: https://github.com/MightyPirates/OpenComputers/releases
[robot names]: https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/resources/assets/opencomputers/robot.names
[wiki]: http://ocdoc.cil.li/
[wiki]: https://ocdoc.cil.li/
[integration]: https://github.com/MightyPirates/OpenComputers/tree/master-MC1.7.10/src/main/scala/li/cil/oc/integration
[ingame manual]: https://github.com/MightyPirates/OpenComputers/tree/master-MC1.7.10/src/main/resources/assets/opencomputers/doc
[idea_1.7.10]: http://ocdoc.cil.li/tutorial:debug_1.7.10
[idea_1.7.10]: https://ocdoc.cil.li/tutorial:debug_1.7.10

View File

@ -1,6 +1,6 @@
# Lua
Die Lua-[Dokumentation (englisch)](http://www.lua.org/manual/5.2/manual.html) und die [Programming in Lua](http://www.lua.org/pil/)-Bücher (englisch) (die erste Ausgabe ist online kostenlos verfügbar) sind eine gute Anlaufstelle für die Grundlagen von Lua und zum Verständnis der Syntax und Standardbibliotheken der Sprache. [OpenOS](openOS.md) versucht die Standardbibliotheken so gut wie möglich mit ein paar Unterschieden (wie zum Beispiel die großteils fehlende Debugging-Bibliothek) zu emulieren. Diese Unterschiede sind [im Wiki dokumentiert (englisch)](http://ocdoc.cil.li/api:non-standard-lua-libs).
Die Lua-[Dokumentation (englisch)](http://www.lua.org/manual/5.2/manual.html) und die [Programming in Lua](http://www.lua.org/pil/)-Bücher (englisch) (die erste Ausgabe ist online kostenlos verfügbar) sind eine gute Anlaufstelle für die Grundlagen von Lua und zum Verständnis der Syntax und Standardbibliotheken der Sprache. [OpenOS](openOS.md) versucht die Standardbibliotheken so gut wie möglich mit ein paar Unterschieden (wie zum Beispiel die großteils fehlende Debugging-Bibliothek) zu emulieren. Diese Unterschiede sind [im Wiki dokumentiert (englisch)](https://ocdoc.cil.li/api:non-standard-lua-libs).
Nicht standardisierte Bibliotheken müssen `require`-d werden, um sie in einem Script zu verwenden. Zum Beispiel:

View File

@ -10,6 +10,6 @@ Das Handbuch funktioniert ähnlich wie ein Wiki: Auf Links zu klicken öffnet di
Das Handbuch erinnert sich an die Seite die zuletzt geöffnet war, wenn es geöffnet wird. Wenn das Buch im Schleichen geöffnet wird, öffnet sich das Inhaltsverzeichnis. Wenn Informationen über einen Block in der Welt benötigt werden, genügt es diesen Block rechts mit der Umschalttaste anzuklicken, während das Handbuch in der Hand ist.
Sollten nach Lesen des Handbuchs Fragen übrig bleiben, gibt es andere Informationsquellen, wie das [Wiki](http://ocdoc.ci.li), der [IRC-Channel](http://webchat.esper.net/?channels=#oc) (#oc auf esper.net) sowie das [Forum](http://oc.cil.li).
Sollten nach Lesen des Handbuchs Fragen übrig bleiben, gibt es andere Informationsquellen, wie das [Wiki](https://ocdoc.ci.li), der [IRC-Channel](http://webchat.esper.net/?channels=#oc) (#oc auf esper.net) sowie das [Forum](https://oc.cil.li).
Sollten im Handbuch inhaltliche, grammatische oder andere Fehler oder Bugs in der Modifikation auftauchen, melde dies bitte über den [Issue Tracker](https://github.com/MightyPirates/OpenComputers/issues). Wenn du zum Handbuch beitragen möchtest, indem du es mit Inhalt bereicherst, bitte melde dich im IRC oder erstelle ein Ticket im Issue Tracker.

View File

@ -1,6 +1,6 @@
# Lua
The Lua [reference manual](http://www.lua.org/manual/5.2/manual.html) and the [Programming in Lua](http://www.lua.org/pil/) books (first edition is available for free online) are a good place to get started with the basics of Lua and becoming familiar with the basic syntax and standard libraries. [OpenOS](openOS.md) strives to emulate the standard libraries very closely, with a few deviations, such as the mostly missing debug library (for sandboxing reasons). These differences are [documented on the wiki](http://ocdoc.cil.li/api:non-standard-lua-libs).
The Lua [reference manual](http://www.lua.org/manual/5.2/manual.html) and the [Programming in Lua](http://www.lua.org/pil/) books (first edition is available for free online) are a good place to get started with the basics of Lua and becoming familiar with the basic syntax and standard libraries. [OpenOS](openOS.md) strives to emulate the standard libraries very closely, with a few deviations, such as the mostly missing debug library (for sandboxing reasons). These differences are [documented on the wiki](https://ocdoc.cil.li/api:non-standard-lua-libs).
Non-standard libraries will need to be
`require`d in order to use them in a script. For example:

View File

@ -10,6 +10,6 @@ Navigating the manual is similar to browsing a wiki: click on links (1) to follo
The manual will remember the page where you last left off, when re-opening it. You can start over on the main index page by using it while sneaking. It is also possible to directly jump to a page concerning a block in the world by shift-right clicking the block with the manual in hand.
If your questions are not answered by the manual, other places with information are [the wiki](http://ocdoc.cil.li), OpenComputers' [IRC channel](http://webchat.esper.net/?channels=#oc) and [the forums](http://oc.cil.li/).
If your questions are not answered by the manual, other places with information are [the wiki](https://ocdoc.cil.li), OpenComputers' [IRC channel](http://webchat.esper.net/?channels=#oc) and [the forums](https://oc.cil.li/).
If you spot any mistakes in the manual, factual, grammatical or otherwise; or bugs in the mod, for that matter, please let us know [via the issue tracker](https://github.com/MightyPirates/OpenComputers/issues). If you'd like to contribute to the manual by adding content, get in touch via IRC or by creating a ticket on the issue tracker.

View File

@ -1,6 +1,6 @@
# Lua
Le [manuel de référence](http://www.lua.org/manual/5.2/manual.html) en Lua et le livre [Programming Lua](http://www.lua.org/pil/) (la première édition est disponible gratuitement en ligne) sont un bon endroit pour démarrer avec les bases de Lua et se familiariser avec la syntaxe de base et les bibliothèques standard. [OpenOS](openOS.md) s'efforce d'émuler les bibliothèques standard au plus près, avec quelques écarts, comme la bibliothèque de débogage qui est principalement absente (pour des raisons de sécurité liées au mode "bac à sable"). Ces différences sont [documentées sur le wiki](http://ocdoc.cil.li/api:non-standard-lua-libs).
Le [manuel de référence](http://www.lua.org/manual/5.2/manual.html) en Lua et le livre [Programming Lua](http://www.lua.org/pil/) (la première édition est disponible gratuitement en ligne) sont un bon endroit pour démarrer avec les bases de Lua et se familiariser avec la syntaxe de base et les bibliothèques standard. [OpenOS](openOS.md) s'efforce d'émuler les bibliothèques standard au plus près, avec quelques écarts, comme la bibliothèque de débogage qui est principalement absente (pour des raisons de sécurité liées au mode "bac à sable"). Ces différences sont [documentées sur le wiki](https://ocdoc.cil.li/api:non-standard-lua-libs).
Les bibliothèques non-standard devront être importées avec `require` pour les utiliser dans un script. Par exemple :

View File

@ -10,6 +10,6 @@ Naviguer dans le manuel est semblable à la navigation dans un wiki : cliquez su
Le manuel se souviendra de la page sur laquelle vous étiez en le fermant, quand vous le ré-ouvrirez. Vous pouvez revenir sur la page principale en vous accroupissant pour l'utiliser. Il est également possible d'accéder directement à la page concernant un bloc en faisant un clic droit sur le bloc avec la touche Maj. enfoncée, et le manuel en main.
Si le manuel ne répond pas à vos questions, les autres endroits où vous pourrez trouver des informations sont [le wiki](http://ocdoc.cil.li), le [canal IRC](http://webchat.esper.net/?channels=#oc) d'OpenComputers et [le forum](http://oc.cil.li/).
Si le manuel ne répond pas à vos questions, les autres endroits où vous pourrez trouver des informations sont [le wiki](https://ocdoc.cil.li), le [canal IRC](http://webchat.esper.net/?channels=#oc) d'OpenComputers et [le forum](https://oc.cil.li/).
Si vous repérez des erreurs dans le manuel, à propos d'une information, ou de la grammaire ou quoi que ce soit d'autre; ou même des bugs dans le mod d'ailleurs, faites nous le savoir sur [le gestionnaire de tickets](https://github.com/MightyPirates/OpenComputers/issues). Si vous voulez contribuer au manuel en ajoutant du contenu, contactez nous sur IRC ou en créant un ticket sur le gestionnaire de tickets.

View File

@ -1,6 +1,6 @@
# Lua
Для знакомства с языком Lua и стандартными библиотеками полезно прочитать [справочное руководство по Lua](http://www.lua.org/manual/5.2/manual.html) и книгу ["Программирование на Lua"](http://www.lua.org/pil/) (первое издание доступно бесплатно). [OpenOS](openOS.md) стремится близко соответствовать стандартным библиотекам с несколькими различиями, например в библиотеке debug. Эти различия [документированы в wiki](http://ocdoc.cil.li/api:non-standard-lua-libs).
Для знакомства с языком Lua и стандартными библиотеками полезно прочитать [справочное руководство по Lua](http://www.lua.org/manual/5.2/manual.html) и книгу ["Программирование на Lua"](http://www.lua.org/pil/) (первое издание доступно бесплатно). [OpenOS](openOS.md) стремится близко соответствовать стандартным библиотекам с несколькими различиями, например в библиотеке debug. Эти различия [документированы в wiki](https://ocdoc.cil.li/api:non-standard-lua-libs).
Нестандартные библиотеки должны быть подключены с помощью `require`, чтобы использовать их в программах. Например:

View File

@ -10,6 +10,6 @@
Руководство запомнит страницу, на которой вы остановились, даже если вы его закрыли. Вы можете начать с главной страницы, открыв руководство его с зажатой клавишей Shift. Вы также можете перейти на страницу о нужном блоке, если кликните, приседая, правой кнопкой мыши по блоку, держа руководство в руке.
Если у вас остались вопросы, вы можете ознакомиться с [Wiki](http://ocdoc.cil.li), спросить в [IRC-канале](http://webchat.esper.net/?channels=#oc) или на [форуме](http://oc.cil.li/).
Если у вас остались вопросы, вы можете ознакомиться с [Wiki](https://ocdoc.cil.li), спросить в [IRC-канале](http://webchat.esper.net/?channels=#oc) или на [форуме](https://oc.cil.li/).
Если вы нашли ошибки в данном руководстве или ошибки в моде - грамматические или какие-либо другие, - сообщите на [баг-трекере мода](https://github.com/MightyPirates/OpenComputers/issues). Если вы хотите внести свой вклад в данное руководство путем добавления страниц, напишите нам в IRC или на баг-трекере.

View File

@ -1,6 +1,6 @@
# Lua
[LUA编程手册](http://www.lua.org/manual/5.2/manual.html) 和 [LUA编程第一版](http://www.lua.org/pil/) 是学习基本功能并熟悉lua标准库的好帮手. [OpenOS](openOS.md) 尽可能准确的模拟标准库,当然有些许变化比如某些高权限的debug库去掉了. 这些不同点写在了[这里](http://ocdoc.cil.li/api:non-standard-lua-libs).
[LUA编程手册](http://www.lua.org/manual/5.2/manual.html) 和 [LUA编程第一版](http://www.lua.org/pil/) 是学习基本功能并熟悉lua标准库的好帮手. [OpenOS](openOS.md) 尽可能准确的模拟标准库,当然有些许变化比如某些高权限的debug库去掉了. 这些不同点写在了[这里](https://ocdoc.cil.li/api:non-standard-lua-libs).
require命令用来在脚本里引用模块
比如

View File

@ -8,7 +8,7 @@
由loveyanbei(https://github.com/loveyanbei) 汉化
如果有问题可以访问 http://ocdoc.cil.li 查看wiki
如果有问题可以访问 https://ocdoc.cil.li 查看wiki
对翻译有疑问可以自行pull request

View File

@ -16,7 +16,7 @@ Most blocks act as 'cables' - use relays and power distributors to create separa
Welcome to the dark side - here, have some cookies.
Screens can display Unicode - paste the special chars or use unicode.char.
Run `help` or `man programname` for ingame help on programs shipped with OpenOS - start with `man man`.
For more help, there's a wiki at http://ocdoc.cil.li/ - or find the IRC loot disk and join #oc.
For more help, there's a wiki at https://ocdoc.cil.li/ - or find the IRC loot disk and join #oc.
Computers have a very basic, built-in speaker - control it using computer.beep().
Many component methods have a short documentation - use `=component.componentName.methodName` in the Lua interpreter to see it.
You can get a list of all attached components using the `components` program.

View File

@ -4,7 +4,7 @@
"description": "This mod adds modular computers and robots that can be programmed in Lua.",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "http://oc.cil.li/",
"url": "https://oc.cil.li/",
"authorList": ["Florian 'Sangar' Nuecke", "Johannes 'Lord Joda' Lohrer", "Everyone who contributed to the mod on Github - thank you!"],
"credits" : "Inspired by a couple of other mods, most notably ComputerCraft.",
"logoFile" : "assets/opencomputers/textures/gui/logo.png",

View File

@ -11,7 +11,7 @@ class CoreModContainer extends DummyModContainer({
md.modId = "OpenComputers|Core"
md.version = "@VERSION@"
md.name = "OpenComputers (Core)"
md.url = "http://oc.cil.li/"
md.url = "https://oc.cil.li/"
md.description = "OC core mod used for class transformer and as API owner to avoid cyclic dependencies."
md
}) {

View File

@ -24,8 +24,8 @@ import scala.ref.WeakReference
class Trade(val info: TradeInfo) extends AbstractValue {
def this() = this(new TradeInfo())
def this(upgrade: UpgradeTrading, merchant: IMerchant, recipeID: Int) =
this(new TradeInfo(upgrade.host, merchant, recipeID))
def this(upgrade: UpgradeTrading, merchant: IMerchant, recipeID: Int, merchantID: Int) =
this(new TradeInfo(upgrade.host, merchant, recipeID, merchantID))
def maxRange = Settings.get.tradingRange
@ -40,6 +40,10 @@ class Trade(val info: TradeInfo) extends AbstractValue {
override def save(nbt: NBTTagCompound) = info.save(nbt)
@Callback(doc = "function():number -- Returns a sort index of the merchant that provides this trade")
def getMerchantId(context: Context, arguments: Arguments): Array[AnyRef] =
result(info.merchantID)
@Callback(doc = "function():table, table -- Returns the items the merchant wants for this trade.")
def getInput(context: Context, arguments: Arguments): Array[AnyRef] =
result(info.recipe.map(_.getItemToBuy.copy()).orNull,
@ -122,11 +126,11 @@ class Trade(val info: TradeInfo) extends AbstractValue {
}
}
class TradeInfo(var host: Option[EnvironmentHost], var merchant: WeakReference[IMerchant], var recipeID: Int) {
def this() = this(None, new WeakReference[IMerchant](null), -1)
class TradeInfo(var host: Option[EnvironmentHost], var merchant: WeakReference[IMerchant], var recipeID: Int, var merchantID: Int) {
def this() = this(None, new WeakReference[IMerchant](null), -1, -1)
def this(host: EnvironmentHost, merchant: IMerchant, recipeID: Int) =
this(Option(host), new WeakReference[IMerchant](merchant), recipeID)
def this(host: EnvironmentHost, merchant: IMerchant, recipeID: Int, merchantID: Int) =
this(Option(host), new WeakReference[IMerchant](merchant), recipeID, merchantID)
def recipe = merchant.get.map(_.getRecipes(null).get(recipeID))
@ -145,6 +149,7 @@ class TradeInfo(var host: Option[EnvironmentHost], var merchant: WeakReference[I
private final val HostYTag = "hostY"
private final val HostZTag = "hostZ"
private final val RecipeID = "recipeID"
private final val MerchantID = "merchantID"
def load(nbt: NBTTagCompound): Unit = {
val isEntity = nbt.getBoolean(HostIsEntityTag)
@ -155,6 +160,7 @@ class TradeInfo(var host: Option[EnvironmentHost], var merchant: WeakReference[I
case _ => null
})
recipeID = nbt.getInteger(RecipeID)
merchantID = if (nbt.hasKey(MerchantID)) nbt.getInteger(MerchantID) else -1
}
def save(nbt: NBTTagCompound): Unit = {
@ -179,6 +185,7 @@ class TradeInfo(var host: Option[EnvironmentHost], var merchant: WeakReference[I
case _ =>
}
nbt.setInteger(RecipeID, recipeID)
nbt.setInteger(MerchantID, merchantID)
}
private def loadEntity(nbt: NBTTagCompound, uuid: UUID): Option[Entity] = {

View File

@ -1,6 +1,7 @@
package li.cil.oc.server.component
import java.util
import java.util.UUID
import li.cil.oc.Constants
import li.cil.oc.api.driver.DeviceInfo.DeviceAttribute
@ -21,6 +22,7 @@ import net.minecraft.util.math.Vec3d
import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._
import scala.collection.mutable
class UpgradeTrading(val host: EnvironmentHost) extends prefab.ManagedEnvironment with traits.WorldAware with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network).
@ -44,9 +46,18 @@ class UpgradeTrading(val host: EnvironmentHost) extends prefab.ManagedEnvironmen
@Callback(doc = "function():table -- Returns a table of trades in range as userdata objects.")
def getTrades(context: Context, args: Arguments): Array[AnyRef] = {
result(entitiesInBounds[Entity](classOf[Entity], position.bounds.expand(maxRange, maxRange, maxRange)).
val merchants = entitiesInBounds[Entity](classOf[Entity], position.bounds.expand(maxRange, maxRange, maxRange)).
filter(isInRange).
collect { case merchant: IMerchant => merchant }.
flatMap(merchant => merchant.getRecipes(null).indices.map(new Trade(this, merchant, _))))
collect { case merchant: IMerchant => merchant }
var nextId = 1
val idMap = mutable.Map[UUID, Int]()
for (id: UUID <- merchants.collect { case merchant: IMerchant => merchant.getPersistentID }.sorted) {
idMap.put(id, nextId)
nextId += 1
}
// sorting the result is not necessary, but will help the merchant trades line up nicely by merchant
result(merchants.sortBy(m => m.getPersistentID).flatMap(merchant => merchant.getRecipes(null).indices.map(index => {
new Trade(this, merchant, index, idMap(merchant.getPersistentID))
})))
}
}

View File

@ -37,7 +37,12 @@ trait Node extends ImmutableNode {
if (network == null) Iterable.empty[ImmutableNode].toSeq
else network.neighbors(this)
def connect(node: ImmutableNode) = network.connect(this, node)
// a node should be added to a network before it can connect to a node
// but, sometimes other mods try to create nodes and connect them before
// the network is ready. we dont those things to crash here
// with typical nodes we are talking about components here
// which will be connected anyways when the network is created
def connect(node: ImmutableNode): Unit = if (network != null) network.connect(this, node)
def disconnect(node: ImmutableNode) =
if (network != null && isInSameNetwork(node)) network.disconnect(this, node)