testymain 0 Share Posted December 1, 2018 i found I should use this Item item = getEquipment().getItemInSlot(EquipmentSlot.HAT); but getItemInSlot takes int as argument and my IDE shows this error The method getItemInSlot(int) in the type AbstractItemContainer<Item> is not applicable for the arguments (EquipmentSlot) What is the correct way of getting equipped item in weapon slot for example Link to comment Share on other sites More sharing options...
testymain 0 Author Share Posted December 1, 2018 the problem is probably caused because i have a class that extends AbstractScript and the actual code is in different helper class. I used private MethodContext ctx = new MethodContext(); and then anything that is called through ctx example ctx.getLocalPlayer() causes NPE. How exactly do i access these methoud outside of the main script that extends abstract script? I thought MethodContext was the class that provides it. Link to comment Share on other sites More sharing options...
dQw4w9WgXcQ 184 Share Posted December 1, 2018 just pass the script to ur other classes Link to comment Share on other sites More sharing options...
Hashtag 8670 Featured Comment Share Posted December 1, 2018 To answer your initial question, use EquipmentSlot.HAT.getSlot() Link to comment Share on other sites More sharing options...
testymain 0 Author Share Posted December 1, 2018 Ok thank you hashtag, but i still cant use methods like getLocalPlayer(), getEquipment() etc. outside of script that inherits from AbstractScript, i tried initializing object in my main script like that Miner miner = new Miner(getEquipment()); and the in miner class i had this constructor public Miner(Equipment equipment) { this.equipment = equipment; } but that doesnt work either. what do you mean by 'just pass the script to ur other classes' could you make an example? Link to comment Share on other sites More sharing options...
Hashtag 8670 Featured Comment Share Posted December 1, 2018 public class Main extends AbstractScript { void onStart() { new Other(this); } } public class Other { public Other(MethodContext ctx) { ctx.getTabs().logout(); } } Link to comment Share on other sites More sharing options...
testymain 0 Author Share Posted December 1, 2018 thanks that woprked Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.