mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 09:18:05 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into bc7
This commit is contained in:
commit
c92dfe413c
@ -208,7 +208,7 @@ opencomputers {
|
|||||||
# can reconfigure any CPU to use the Lua 5.3 architecture. This is
|
# can reconfigure any CPU to use the Lua 5.3 architecture. This is
|
||||||
# not enabled by default for the time being, because it needs some
|
# not enabled by default for the time being, because it needs some
|
||||||
# more stability testing.
|
# more stability testing.
|
||||||
enableLua53: false
|
enableLua53: true
|
||||||
|
|
||||||
# The sizes of the six levels of RAM, in kilobytes. This list must
|
# The sizes of the six levels of RAM, in kilobytes. This list must
|
||||||
# contain exactly six entries, or it will be ignored. Note that while
|
# contain exactly six entries, or it will be ignored. Note that while
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
The capacitor stores energy to be used by the network, acting as an energy buffer when needed. Unlike conversion from other mod's energy to OpenComputers' internal energy type (using a [power converter](powerConverter.md) for example), transferring energy inside a single subnetwork is instantaneous. Having an internal energy bugger will be useful for tasks that require a lot of energy, such as [assembling](assembler.md) and/or [charging](charger.md) devices such as [robots](robot.md) or [drones](../item/drone.md).
|
The capacitor stores energy to be used by the network, acting as an energy buffer when needed. Unlike conversion from other mod's energy to OpenComputers' internal energy type (using a [power converter](powerConverter.md) for example), transferring energy inside a single subnetwork is instantaneous. Having an internal energy buffer will be useful for tasks that require a lot of energy, such as [assembling](assembler.md) and/or [charging](charger.md) devices such as [robots](robot.md) or [drones](../item/drone.md).
|
||||||
|
|
||||||
The storage efficiency of capacitors increases with the number of capacitors in direct contact or in the vicinity. For example, two capacitors directly next to each other will have a higher storage capacity than the sum of two separated capacitors. This adjacency bonus applies for capacitors up to two blocks away, and is reduced as the distance between capacitors increases.
|
The storage efficiency of capacitors increases with the number of capacitors in direct contact or in the vicinity. For example, two capacitors directly next to each other will have a higher storage capacity than the sum of two separated capacitors. This adjacency bonus applies for capacitors up to two blocks away, and is reduced as the distance between capacitors increases.
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
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](http://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:
|
Non-standard libraries will need to be
|
||||||
|
`require`d in order to use them in a script. For example:
|
||||||
|
|
||||||
`local component = require("component")`
|
`local component = require("component")`
|
||||||
`local rs = component.redstone`
|
`local rs = component.redstone`
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -27,13 +27,11 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
|
|||||||
if (hasMouse && Mouse.hasWheel && Mouse.getEventDWheel != 0) {
|
if (hasMouse && Mouse.hasWheel && Mouse.getEventDWheel != 0) {
|
||||||
val mouseX = Mouse.getEventX * width / mc.displayWidth
|
val mouseX = Mouse.getEventX * width / mc.displayWidth
|
||||||
val mouseY = height - Mouse.getEventY * height / mc.displayHeight - 1
|
val mouseY = height - Mouse.getEventY * height / mc.displayHeight - 1
|
||||||
val bx = (mouseX - x - bufferMargin) / TextBufferRenderCache.renderer.charRenderWidth.toDouble
|
toBufferCoordinates(mouseX, mouseY) match {
|
||||||
val by = (mouseY - y - bufferMargin) / TextBufferRenderCache.renderer.charRenderHeight.toDouble
|
case Some((bx, by)) =>
|
||||||
val bw = buffer.getWidth
|
val scroll = math.signum(Mouse.getEventDWheel)
|
||||||
val bh = buffer.getHeight
|
buffer.mouseScroll(bx, by, scroll, null)
|
||||||
if (bx >= 0 && by >= 0 && bx < bw && by < bh) {
|
case _ => // Ignore when out of bounds.
|
||||||
val scroll = math.signum(Mouse.getEventDWheel)
|
|
||||||
buffer.mouseScroll(bx, by, scroll, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,15 +58,9 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
|
|||||||
super.mouseMovedOrUp(mouseX, mouseY, button)
|
super.mouseMovedOrUp(mouseX, mouseY, button)
|
||||||
if (hasMouse && button >= 0) {
|
if (hasMouse && button >= 0) {
|
||||||
if (didDrag) {
|
if (didDrag) {
|
||||||
val bx = (mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth
|
toBufferCoordinates(mouseX, mouseY) match {
|
||||||
val by = (mouseY - y - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderHeight
|
case Some((bx, by)) => buffer.mouseUp(bx, by, button, null)
|
||||||
val bw = buffer.getWidth
|
case _ => buffer.mouseUp(-1.0, -1.0, button, null)
|
||||||
val bh = buffer.getHeight
|
|
||||||
if (bx >= 0 && by >= 0 && bx < bw && by < bh) {
|
|
||||||
buffer.mouseUp(bx, by, button, null)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buffer.mouseUp(-1.0, -1.0, button, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
didDrag = false
|
didDrag = false
|
||||||
@ -78,21 +70,26 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def clickOrDrag(mouseX: Int, mouseY: Int, button: Int) {
|
private def clickOrDrag(mouseX: Int, mouseY: Int, button: Int) {
|
||||||
val bx = (mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth
|
toBufferCoordinates(mouseX, mouseY) match {
|
||||||
val by = (mouseY - y - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderHeight
|
case Some((bx, by)) if bx.toInt != mx || by.toInt != my =>
|
||||||
val bw = buffer.getWidth
|
|
||||||
val bh = buffer.getHeight
|
|
||||||
if (bx >= 0 && by >= 0 && bx < bw && by < bh) {
|
|
||||||
if (bx.toInt != mx || by.toInt != my) {
|
|
||||||
if (mx >= 0 && my >= 0) buffer.mouseDrag(bx, by, button, null)
|
if (mx >= 0 && my >= 0) buffer.mouseDrag(bx, by, button, null)
|
||||||
else buffer.mouseDown(bx, by, button, null)
|
else buffer.mouseDown(bx, by, button, null)
|
||||||
didDrag = mx >= 0 && my >= 0
|
didDrag = mx >= 0 && my >= 0
|
||||||
mx = bx.toInt
|
mx = bx.toInt
|
||||||
my = by.toInt
|
my = by.toInt
|
||||||
}
|
case _ =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def toBufferCoordinates(mouseX: Int, mouseY: Int): Option[(Double, Double)] = {
|
||||||
|
val bx = (mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth
|
||||||
|
val by = (mouseY - y - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderHeight
|
||||||
|
val bw = buffer.getWidth
|
||||||
|
val bh = buffer.getHeight
|
||||||
|
if (bx >= 0 && by >= 0 && bx < bw && by < bh) Some((bx, by))
|
||||||
|
else None
|
||||||
|
}
|
||||||
|
|
||||||
override def drawScreen(mouseX: Int, mouseY: Int, dt: Float): Unit = {
|
override def drawScreen(mouseX: Int, mouseY: Int, dt: Float): Unit = {
|
||||||
super.drawScreen(mouseX, mouseY, dt)
|
super.drawScreen(mouseX, mouseY, dt)
|
||||||
drawBufferLayer()
|
drawBufferLayer()
|
||||||
|
@ -134,7 +134,8 @@ class ClassTransformer extends IClassTransformer {
|
|||||||
{
|
{
|
||||||
val classNode = newClassNode(transformedClass)
|
val classNode = newClassNode(transformedClass)
|
||||||
if (classNode.interfaces.contains("li/cil/oc/api/network/SimpleComponent") &&
|
if (classNode.interfaces.contains("li/cil/oc/api/network/SimpleComponent") &&
|
||||||
!classNode.visibleAnnotations.exists(_.desc == "Lli/cil/oc/api/network/SimpleComponent$SkipInjection;")) {
|
(classNode.visibleAnnotations == null || !classNode.visibleAnnotations.
|
||||||
|
exists(annotation => annotation != null && annotation.desc == "Lli/cil/oc/api/network/SimpleComponent$SkipInjection;"))) {
|
||||||
try {
|
try {
|
||||||
transformedClass = injectEnvironmentImplementation(classNode)
|
transformedClass = injectEnvironmentImplementation(classNode)
|
||||||
log.info(s"Successfully injected component logic into class $name.")
|
log.info(s"Successfully injected component logic into class $name.")
|
||||||
|
@ -17,7 +17,7 @@ class TransformerLoader extends DummyModContainer({
|
|||||||
val md = new ModMetadata()
|
val md = new ModMetadata()
|
||||||
md.authorList.add("Sangar")
|
md.authorList.add("Sangar")
|
||||||
md.modId = "OpenComputers|Core"
|
md.modId = "OpenComputers|Core"
|
||||||
md.version = "1.0.0"
|
md.version = "@VERSION@"
|
||||||
md.name = "OpenComputers (Core)"
|
md.name = "OpenComputers (Core)"
|
||||||
md.url = "http://oc.cil.li/"
|
md.url = "http://oc.cil.li/"
|
||||||
md.description = "OC core mod used for class transformer and as API owner to avoid cyclic dependencies."
|
md.description = "OC core mod used for class transformer and as API owner to avoid cyclic dependencies."
|
||||||
|
@ -49,7 +49,7 @@ abstract class Template {
|
|||||||
|
|
||||||
val progress =
|
val progress =
|
||||||
if (!hasCPU) Localization.Assembler.InsertCPU
|
if (!hasCPU) Localization.Assembler.InsertCPU
|
||||||
else if (!hasRAM) Localization.Assembler.InsertRAM
|
else if (!hasRAM && requiresRAM) Localization.Assembler.InsertRAM
|
||||||
else Localization.Assembler.Complexity(complexity, maxComplexity)
|
else Localization.Assembler.Complexity(complexity, maxComplexity)
|
||||||
|
|
||||||
val warnings = mutable.ArrayBuffer.empty[IChatComponent]
|
val warnings = mutable.ArrayBuffer.empty[IChatComponent]
|
||||||
|
@ -35,6 +35,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
|
|||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
import scala.language.existentials
|
import scala.language.existentials
|
||||||
|
|
||||||
|
// Note to self: this class is used by ExtraCells (and potentially others), do not rename / drastically change it.
|
||||||
trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActionHost] {
|
trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActionHost] {
|
||||||
def tile: AETile
|
def tile: AETile
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import li.cil.oc.common.Slot
|
|||||||
import li.cil.oc.common.Tier
|
import li.cil.oc.common.Tier
|
||||||
import li.cil.oc.common.item
|
import li.cil.oc.common.item
|
||||||
import li.cil.oc.common.item.Delegator
|
import li.cil.oc.common.item.Delegator
|
||||||
|
import li.cil.oc.server.machine.luac.NativeLuaArchitecture
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
|
|
||||||
import scala.collection.convert.WrapAsScala._
|
import scala.collection.convert.WrapAsScala._
|
||||||
@ -40,7 +41,13 @@ abstract class DriverCPU extends Item with Processor {
|
|||||||
|
|
||||||
override def architecture(stack: ItemStack): Class[_ <: Architecture] = {
|
override def architecture(stack: ItemStack): Class[_ <: Architecture] = {
|
||||||
if (stack.hasTagCompound) {
|
if (stack.hasTagCompound) {
|
||||||
val archClass = stack.getTagCompound.getString(Settings.namespace + "archClass")
|
val archClass = stack.getTagCompound.getString(Settings.namespace + "archClass") match {
|
||||||
|
case clazz if clazz == classOf[NativeLuaArchitecture].getName =>
|
||||||
|
// Migrate old saved CPUs to new versions (since the class they refer still
|
||||||
|
// exists, but is abstract, which would lead to issues).
|
||||||
|
api.Machine.LuaArchitecture.getName
|
||||||
|
case clazz => clazz
|
||||||
|
}
|
||||||
if (!archClass.isEmpty) try return Class.forName(archClass).asSubclass(classOf[Architecture]) catch {
|
if (!archClass.isEmpty) try return Class.forName(archClass).asSubclass(classOf[Architecture]) catch {
|
||||||
case t: Throwable =>
|
case t: Throwable =>
|
||||||
OpenComputers.log.warn("Failed getting class for CPU architecture. Resetting CPU to use the default.", t)
|
OpenComputers.log.warn("Failed getting class for CPU architecture. Resetting CPU to use the default.", t)
|
||||||
|
@ -124,9 +124,12 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
case Some(driver: Processor) if driver.slot(stack) == Slot.CPU =>
|
case Some(driver: Processor) if driver.slot(stack) == Slot.CPU =>
|
||||||
Option(driver.architecture(stack)) match {
|
Option(driver.architecture(stack)) match {
|
||||||
case Some(clazz) =>
|
case Some(clazz) =>
|
||||||
if (architecture == null || architecture.getClass != clazz) {
|
if (architecture == null || architecture.getClass != clazz) try {
|
||||||
newArchitecture = clazz.getConstructor(classOf[machine.Machine]).newInstance(this)
|
newArchitecture = clazz.getConstructor(classOf[machine.Machine]).newInstance(this)
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
case t: Throwable => OpenComputers.log.warn("Failed instantiating a CPU architecture.", t)
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
newArchitecture = architecture
|
newArchitecture = architecture
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,8 @@ object LuaStateFactory {
|
|||||||
state.openLib(jnlua.LuaState.Library.MATH)
|
state.openLib(jnlua.LuaState.Library.MATH)
|
||||||
state.openLib(jnlua.LuaState.Library.STRING)
|
state.openLib(jnlua.LuaState.Library.STRING)
|
||||||
state.openLib(jnlua.LuaState.Library.TABLE)
|
state.openLib(jnlua.LuaState.Library.TABLE)
|
||||||
// TODO Enable once I update the natives.
|
state.openLib(jnlua.LuaState.Library.UTF8)
|
||||||
// state.openLib(jnlua.LuaState.Library.UTF8)
|
state.pop(8)
|
||||||
state.pop(7)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ object GameTimeFormatter {
|
|||||||
day = yearDay
|
day = yearDay
|
||||||
val monthLengths = monthLengthsForYear(year)
|
val monthLengths = monthLengthsForYear(year)
|
||||||
var month = 0
|
var month = 0
|
||||||
while (day > monthLengths(month)) {
|
while (day >= monthLengths(month)) {
|
||||||
day = day - monthLengths(month)
|
day = day - monthLengths(month)
|
||||||
month = month + 1
|
month = month + 1
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user