lobbyplox 0 Share Posted July 17, 2017 Hi everyone, I have a quick question regarding a scripting function. I'm having trouble finding the function to select an item in your inventory? Could anyone help me out here? Thanks Link to comment Share on other sites More sharing options...
Pyth 127 Share Posted July 17, 2017 getInventory().get("ItemName") or getInventory().get("ItemName").interact("Use"); Link to comment Share on other sites More sharing options...
Nex 2542 Share Posted July 17, 2017 getInventory().get("ItemName") or getInventory().get("ItemName").interact("Use"); to add onto this there is also a useOn option: getInventory().get("Item").useOn("Item2"); Link to comment Share on other sites More sharing options...
lobbyplox 0 Author Share Posted July 18, 2017 thank you both. Link to comment Share on other sites More sharing options...
Nuclear Nezz 2055 Share Posted July 18, 2017 or getInventory().interact("Item name","Use"); Link to comment Share on other sites More sharing options...
lobbyplox 0 Author Share Posted July 25, 2017 Another question, related to this one: Is it a similiar command to interact with an NPC? I'm using NPC = getNpcs().closest(f-> f.getName().contains("npc name"));NPC.interact("Use"); but am having trouble, could it be because they are out of vision? and if so How could I move nearby the NPC. Link to comment Share on other sites More sharing options...
RetroBot 35 Share Posted July 25, 2017 Another question, related to this one: Is it a similiar command to interact with an NPC? I'm using NPC = getNpcs().closest(f-> f.getName().contains("npc name")); NPC.interact("Use"); but am having trouble, could it be because they are out of vision? and if so How could I move nearby the NPC. You need to null check the npc and check if the npc is on screen. If the npc is not on your screen you can grab the distance of the npc to determine whether you should turn your camera or walk to the NPC. To use an item on an npc you can use getInventory().get("Item").useOn(npc);. I suggest you learn some java (if you havn't already) and look at some open source scripts to get a better understanding on how to use the API, and how to form the logic of your script. Link to comment Share on other sites More sharing options...
lobbyplox 0 Author Share Posted July 25, 2017 You need to null check the npc and check if the npc is on screen. If the npc is not on your screen you can grab the distance of the npc to determine whether you should turn your camera or walk to the NPC. To use an item on an npc you can use getInventory().get("Item").useOn(npc);. I suggest you learn some java (if you havn't already) and look at some open source scripts to get a better understanding on how to use the API, and how to form the logic of your script. Thanks. Yeah I've done a handful of C and C++ before, so I've ran into a little learning curve here. I appreciate your advice! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.