Question Getting ActiveObject' ID

Vanguard3000

Newcomer
Hi, all,

I'm looking at upgrading my Context-Sensitive Gift Cursor mod, and keep running into this odd quirk where the player's active object (Game1.player.ActiveObject) doesn't have an object id value. I can get its name by calling Game1.player.ActiveObject.Name, but that doesn't help when I'm comparing against a delivery quest's item, which doesn't seem to have a name, but an id instead (i.e., ((ItemDeliveryQuest)q).item.Value).

Basically, when you hover the cursor over an npc, the mod will check all active item delivery quests and see if the selected inventory object (Game1.player.ActiveObject) matches the quest's required item ((ItemDeliveryQuest)q).item), but there seems to be no way to get an id from the ActiveObject, or a name from the delivery item.

Does anyone know of a way to successfully compare the two, preferably by id? I'm thinking there must be an object list in Game1 somewhere that I can get an object from by id or name, but I haven't found it yet. I keep ending up at This page in the Wiki but that seems to concentrate more on adding custom items to the game. It does show the information I can use but it doesn't seem clear how to get all that info.

Anyway, thanks in advance for the help!
 

Vanguard3000

Newcomer
With some help from the Stardew Valley Discord, I found out that ActiveObject.ParentSheetIndex returns the correct ID that will match a quest's target item, provided the ActiveObject is an Object (as opposed to clothing, furniture, etc). here's an edited snippet of my code for reference:

Code:
foreach (Quest q in Game1.player.questLog) {
    if (((ItemDeliveryQuest)q).item.Value == Game1.player.ActiveObject.ParentSheetIndex) {
        return true;
    }
}
 
Top