LuaState push для векторов
This commit is contained in:
parent
a46fa20748
commit
ca23dd2b95
@ -369,21 +369,7 @@ class Starbound : ISBFileLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.setTableFunction("imageSize", this) {args ->
|
state.setTableFunction("imageSize", this) {args ->
|
||||||
val (width, height) = imageSize(args.getString())
|
args.lua.push(imageSize(args.getString()))
|
||||||
|
|
||||||
with(args.lua) {
|
|
||||||
pushTable(arraySize = 2)
|
|
||||||
val table = stackTop
|
|
||||||
|
|
||||||
push(1)
|
|
||||||
push(width)
|
|
||||||
setTableValue(table)
|
|
||||||
|
|
||||||
push(2)
|
|
||||||
push(height)
|
|
||||||
setTableValue(table)
|
|
||||||
}
|
|
||||||
|
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,29 +379,7 @@ class Starbound : ISBFileLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.setTableFunction("nonEmptyRegion", this) { args ->
|
state.setTableFunction("nonEmptyRegion", this) { args ->
|
||||||
val (x, y, z, w) = imageData(args.getString()).nonEmptyRegion
|
args.lua.push(imageData(args.getString()).nonEmptyRegion)
|
||||||
|
|
||||||
with(args.lua) {
|
|
||||||
pushTable(arraySize = 4)
|
|
||||||
val table = stackTop
|
|
||||||
|
|
||||||
push(1)
|
|
||||||
push(x)
|
|
||||||
setTableValue(table)
|
|
||||||
|
|
||||||
push(2)
|
|
||||||
push(y)
|
|
||||||
setTableValue(table)
|
|
||||||
|
|
||||||
push(3)
|
|
||||||
push(z)
|
|
||||||
setTableValue(table)
|
|
||||||
|
|
||||||
push(4)
|
|
||||||
push(w)
|
|
||||||
setTableValue(table)
|
|
||||||
}
|
|
||||||
|
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ import org.lwjgl.system.MemoryStack
|
|||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.io.json.InternedJsonElementAdapter
|
import ru.dbotthepony.kstarbound.io.json.InternedJsonElementAdapter
|
||||||
|
import ru.dbotthepony.kvector.vector.nint.Vector2i
|
||||||
|
import ru.dbotthepony.kvector.vector.nint.Vector3i
|
||||||
|
import ru.dbotthepony.kvector.vector.nint.Vector4i
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.lang.ref.Cleaner
|
import java.lang.ref.Cleaner
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
@ -695,6 +698,60 @@ class LuaState private constructor(private val pointer: Pointer, val stringInter
|
|||||||
LuaJNR.INSTANCE.lua_pushboolean(this.pointer, if (value) 1 else 0)
|
LuaJNR.INSTANCE.lua_pushboolean(this.pointer, if (value) 1 else 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun push(value: Vector4i) {
|
||||||
|
pushTable(arraySize = 4)
|
||||||
|
val table = stackTop
|
||||||
|
val (x, y, z, w) = value
|
||||||
|
|
||||||
|
push(1)
|
||||||
|
push(x)
|
||||||
|
setTableValue(table)
|
||||||
|
|
||||||
|
push(2)
|
||||||
|
push(y)
|
||||||
|
setTableValue(table)
|
||||||
|
|
||||||
|
push(3)
|
||||||
|
push(z)
|
||||||
|
setTableValue(table)
|
||||||
|
|
||||||
|
push(4)
|
||||||
|
push(w)
|
||||||
|
setTableValue(table)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun push(value: Vector3i) {
|
||||||
|
pushTable(arraySize = 3)
|
||||||
|
val table = stackTop
|
||||||
|
val (x, y, z) = value
|
||||||
|
|
||||||
|
push(1)
|
||||||
|
push(x)
|
||||||
|
setTableValue(table)
|
||||||
|
|
||||||
|
push(2)
|
||||||
|
push(y)
|
||||||
|
setTableValue(table)
|
||||||
|
|
||||||
|
push(3)
|
||||||
|
push(z)
|
||||||
|
setTableValue(table)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun push(value: Vector2i) {
|
||||||
|
pushTable(arraySize = 2)
|
||||||
|
val table = stackTop
|
||||||
|
val (x, y) = value
|
||||||
|
|
||||||
|
push(1)
|
||||||
|
push(x)
|
||||||
|
setTableValue(table)
|
||||||
|
|
||||||
|
push(2)
|
||||||
|
push(y)
|
||||||
|
setTableValue(table)
|
||||||
|
}
|
||||||
|
|
||||||
fun pushStrings(strings: Iterable<String?>) {
|
fun pushStrings(strings: Iterable<String?>) {
|
||||||
val index = this.pushTable(arraySize = if (strings is Collection) strings.size else 0)
|
val index = this.pushTable(arraySize = if (strings is Collection) strings.size else 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user