mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-19 15:04:05 +09:00
ActorAI's walk speed can be adjusted now
Former-commit-id: 556677bddf9cc29358471c81f7febc40e8e6cc7d Former-commit-id: 35b994001dd034e166ba6c6709cb92fd5dca073e
This commit is contained in:
@@ -126,32 +126,56 @@ internal class AILuaAPI(val g: Globals, actor: ActorWithBody) {
|
||||
}
|
||||
}
|
||||
|
||||
class MoveLeft(val actor: AIControlled) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
class MoveLeft(val actor: AIControlled) : LuaFunction() {
|
||||
override fun call(): LuaValue { // hard key press
|
||||
actor.moveLeft()
|
||||
return LuaValue.NONE
|
||||
}
|
||||
|
||||
/** @param amount [0.0 - 1.0] */
|
||||
override fun call(amount: LuaValue): LuaValue { // stick tilt
|
||||
actor.moveLeft(amount.checkdouble().toFloat())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
class MoveRight(val actor: AIControlled) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
class MoveRight(val actor: AIControlled) : LuaFunction() {
|
||||
override fun call(): LuaValue { // hard key press
|
||||
actor.moveRight()
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
class MoveUp(val actor: AIControlled) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
actor.moveUp()
|
||||
/** @param amount [0.0 - 1.0] */
|
||||
override fun call(amount: LuaValue): LuaValue { // stick tilt
|
||||
actor.moveRight(amount.checkdouble().toFloat())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
class MoveDown(val actor: AIControlled) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
class MoveUp(val actor: AIControlled) : LuaFunction() {
|
||||
override fun call(): LuaValue { // hard key press
|
||||
actor.moveUp()
|
||||
return LuaValue.NONE
|
||||
}
|
||||
|
||||
/** @param amount [0.0 - 1.0] */
|
||||
override fun call(amount: LuaValue): LuaValue { // stick tilt
|
||||
actor.moveUp(amount.checkdouble().toFloat())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
class MoveDown(val actor: AIControlled) : LuaFunction() {
|
||||
override fun call(): LuaValue { // hard key press
|
||||
actor.moveDown()
|
||||
return LuaValue.NONE
|
||||
}
|
||||
|
||||
/** @param amount [0.0 - 1.0] */
|
||||
override fun call(amount: LuaValue): LuaValue { // stick tilt
|
||||
actor.moveDown(amount.checkdouble().toFloat())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
class MoveTo(val actor: AIControlled) : LuaFunction() {
|
||||
@@ -166,11 +190,17 @@ internal class AILuaAPI(val g: Globals, actor: ActorWithBody) {
|
||||
}
|
||||
}
|
||||
|
||||
class Jump(val actor: AIControlled) : ZeroArgFunction() {
|
||||
class Jump(val actor: AIControlled) : LuaFunction() {
|
||||
override fun call(): LuaValue {
|
||||
actor.moveJump()
|
||||
return LuaValue.NONE
|
||||
}
|
||||
|
||||
/** @param amount [0.0 - 1.0] */
|
||||
override fun call(amount: LuaValue): LuaValue { // stick tilt
|
||||
actor.moveJump(amount.checkdouble().toFloat())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ function update(delta)
|
||||
elseif currentMode == "move" then
|
||||
-- move
|
||||
if moveMode == "left" then
|
||||
ai.moveLeft()
|
||||
ai.moveLeft(0.5)
|
||||
elseif moveMode == "right" then
|
||||
ai.moveRight()
|
||||
ai.moveRight(0.5)
|
||||
end
|
||||
-- reset counter
|
||||
if timeCounter >= countMax then
|
||||
|
||||
Reference in New Issue
Block a user