H0rn Posted August 7, 2017 Posted August 7, 2017 Hey so I am new to scripting, have general knowledge in Java not too experienced. Was looking to check if some item exists on the floor and then telegrab it if it does, I just cant figure out how to use a spell on a ground item. Sorry for noob.
Apaec Posted August 7, 2017 Posted August 7, 2017 (edited) Looking at the API, Since GroundItem implements Entity, you should be able to call Magic#castSpellOnEntity: GroundItem item = getGroundItems().closest("Egg"); MagicSpell spellToCast = NormalSpells.TELEGRAB; if (item != null && getMagic().canCast(spellToCast) if (getMagic().castSpellOnEntity(spellToCast, item)) log("Yay!"); Hopefully that works, wrote in reply box so i've not tested it... let me know if something isn't right! (: Apa Edited August 7, 2017 by Apaec 2
dreameo Posted August 7, 2017 Posted August 7, 2017 getMagic().castSpellOnEntity(NormalSpells.TELEGRAB, item)
H0rn Posted August 8, 2017 Author Posted August 8, 2017 21 hours ago, Apaec said: Looking at the API, Since GroundItem implements Entity, you should be able to call Magic#castSpellOnEntity: GroundItem item = getGroundItems().closest("Egg"); MagicSpell spellToCast = NormalSpells.TELEGRAB; if (item != null && getMagic().canCast(spellToCast) if (getMagic().castSpellOnEntity(spellToCast, item)) log("Yay!"); Hopefully that works, wrote in reply box so i've not tested it... let me know if something isn't right! (: Apa Works a charm! thanks a lot! 1