fixthissite Posted October 7, 2015 Posted October 7, 2015 When looking for/interacting with an item/npc/object, is it preferred to use the ID or the name? Are there times when one would be preferred over the other? What's the benifit from using a name rather than an ID and vice versa? I haven't seen this question answered publicly, and I'm sure it'll be helpful seeing how it's a common aspect of scripting
Chris Posted October 7, 2015 Posted October 7, 2015 (edited) i dont think item ids ever change but objects ids sometimes do. It will be easier to just use names for objects incase of a rs update. Hope my nooby self helped somewhat Edited October 7, 2015 by TheObserver 1
Apaec Posted October 7, 2015 Posted October 7, 2015 Ye, Object Ids change frequently (pretty much every RS update), so basically you should use anything other than IDs to define them... Index/name etc As for item IDs, these never change but using names is probably better anyway because a name is guarenteed never to change also easier to read when using names. apa 2
Fruity Posted October 7, 2015 Posted October 7, 2015 Only downside to using the name is it applies to noted items aswell as unnoted :3 1
Khaleesi Posted October 7, 2015 Posted October 7, 2015 Item id's never change, so thats not a problem. NPc's and gameobjects do change, so you should use names for those There also more advanced ways, like using models to search for entities ^^ Khaleesi 1
fixthissite Posted October 7, 2015 Author Posted October 7, 2015 i dont think item ids ever change but objects ids sometimes do. It will be easier to just use names for objects incase of a rs update. Hope my nooby self helped somewhat Ye, Object Ids change frequently (pretty much every RS update), so basically you should use anything other than IDs to define them... Index/name etc As for item IDs, these never change but using names is probably better anyway because a name is guarenteed never to change also easier to read when using names. apa Only downside to using the name is it applies to noted items aswell as unnoted :3 Item id's never change, so thats not a problem. NPc's and gameobjects do change, so you should use names for those There also more advanced ways, like using models to search for entities ^^ Khaleesi So it seems you should use IDs for items to avoid name collisions with noted items and names for objects incase their IDs change. What about NPCs? 1
Apaec Posted October 7, 2015 Posted October 7, 2015 So it seems you should use IDs for items to avoid name collisions with noted items and names for objects incase their IDs change. What about NPCs? Same applies to NPCs I believe. Their IDs frequently change. I recommend using names for NPCs I try and avoid using ids for anything tbh. Either names (or if they dont work eg multiple npcs with same name next to eachother), I find some other difference between them such as modified colours or index 1
Flamezzz Posted October 7, 2015 Posted October 7, 2015 Noted items is not an issue, you could use inventory.getItem(i -> i.getName().equals(name) && !i.isNote()) 3
Khaleesi Posted October 7, 2015 Posted October 7, 2015 (edited) So it seems you should use IDs for items to avoid name collisions with noted items and names for objects incase their IDs change. What about NPCs? Item id's never change, so you can use them if you want to Entities have their ID changed every update. This means, NPC's and objects will have swapped ID's. So you should use names. NOte: Jagex will be a bitch and call some npcs/gameobjects "null". You should use models to get those specific entities ^^ Khaleesi Edited October 8, 2015 by Khaleesi Scripts 1
Joseph Posted October 12, 2015 Posted October 12, 2015 Only downside to using the name is it applies to noted items aswell as unnoted :3 There's a boolean for is noted items