23 lines
810 B
Kotlin
23 lines
810 B
Kotlin
package at.petrak.hexcasting.common.casting.actions.lists
|
|
|
|
import at.petrak.hexcasting.api.casting.asActionResult
|
|
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
|
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
|
import at.petrak.hexcasting.api.casting.getInt
|
|
import at.petrak.hexcasting.api.casting.getList
|
|
import at.petrak.hexcasting.api.casting.iota.Iota
|
|
|
|
object OpRemove : ConstMediaAction {
|
|
override val argc: Int
|
|
get() = 2
|
|
|
|
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
|
|
val list = args.getList(0, argc).toMutableList()
|
|
val index = args.getInt(1, argc)
|
|
if (index < 0 || index >= list.size)
|
|
return list.asActionResult
|
|
list.removeAt(index)
|
|
return list.asActionResult
|
|
}
|
|
}
|