turretgun.lua Code: function init(args) object.setInteractive(true) object.setAnimationState("beaconState", "active") end function main(args) local radius = object.configParameter("detectRadius") local monsterIds = world.monsterQuery(object.position(), radius) if #monsterIds > 0 then for i=1,#monsterIds do world.spawnProjectile(projectile.projectileType, monsterIds[i].position()) end end end (in case monsterIds.position() would never work, I've also tried entityPosition) turretgun.object Code: { "objectName": "turretgun", "rarity": "Common", "objectType": "wire", "category": "tools", "printable": "false", "price": "0", "description": "Will automatically fire at approaching enemies.", "shortdescription": "Turretgun", "race": "generic", "apexDescription" : "A turret gun.", "avianDescription" : "A turret gun.", "floranDescription" : "A turret gun.", "glitchDescription" : "Analysis. A turret gun.", "humanDescription" : "Pew pew pew.", "hylotlDescription" : "A turret gun.", "inventoryIcon": "turretgunicon.png", "orientations" : [ { "dualImage" : "turretgun.png:<color>.<frame>", "imagePosition" : [-16, 0], "frames" : 12, "animationCycle" : 2, "spaceScan" : 0.1, "anchors" : [ "bottom" ] } ], "animation": "turretgun.animation", "animationParts": { "beacon": "turretgun.png" }, "animationPosition": [-16, 0], "scripts" : [ "turretgun.lua" ], "scriptDelta": 5, "inboundNodes": [ ], "outboundNodes": [ ], "detectRadius": "100", "projectileOptions" : [ { "projectileType": "poisonstatusprojectile", "projectileParams": { } }, { "projectileType": "burningstatusprojectile", "projectileParams": { } } ] } I combined some functionalities of statuspod and ironbeacon hoping to get a decent result... but I don't seem to be able to get it to work. What I'd like it to do is target all the enemies in the near vicinity (radius: 100 at the moment) with a poison attack or burning attack.
Hi there, The entity ids returned by monsterQuery are just numeric ids, so you can't call functions on them directly. You can, however, pass them to various world.entity* functions, like : Code: world.entityPosition(monsterIds[i])
It seems like you have a problem with: Code: local monsterIds = world.monsterQuery(object.position(), radius) world.spawnProjectile(projectile.projectileType, monsterIds[i].position()) You're getting the position of a position, as far as I can tell.