mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 14:34:04 +09:00
more AI, divided ACCELBUFF and ACCELMULT_MOVEMENT
Former-commit-id: f3b4c390c363612dcc58c3d50cb7a47ba7452567 Former-commit-id: 95f71db97104cf55af7aba8e0289eb89efc078a4
This commit is contained in:
@@ -27,14 +27,18 @@ open class HumanoidNPC(luaScript: EncapsulatedString, born: GameDate) : ActorHum
|
||||
|
||||
/**
|
||||
* Initialised in init block.
|
||||
* Use function "function update(delta)" to step the AI.
|
||||
* Use lua function "update(delta)" to step the AI.
|
||||
*/
|
||||
protected val luaInstance: LuaValue
|
||||
|
||||
private val aiLuaAPI: AILuaAPI
|
||||
|
||||
init {
|
||||
luag["io"] = LuaValue.NIL
|
||||
luag["os"] = LuaValue.NIL
|
||||
luag["luajava"] = LuaValue.NIL
|
||||
aiLuaAPI = AILuaAPI(luag, this)
|
||||
// load the script and execute it (initialises target script)
|
||||
luaInstance = luag.load(luaScript.getString(), luaScript.javaClass.simpleName)
|
||||
luaInstance.call()
|
||||
}
|
||||
@@ -77,8 +81,8 @@ open class HumanoidNPC(luaScript: EncapsulatedString, born: GameDate) : ActorHum
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
super.update(gc, delta)
|
||||
aiLuaAPI.update(delta)
|
||||
|
||||
// run "update()" function in the script
|
||||
luag.get("update").call(delta.toLuaValue())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user