Detect if specific placeable is owned ?

Your forum for all discussions around Modding.
C-Bay
Posts: 1
Joined: Thu Aug 04, 2022 7:05 pm

Detect if specific placeable is owned ?

Post by C-Bay »

Very noob here.
Basically, at a specific hour I need my script to detect if a specific modded placeable is owned at farm X.

I thought I could use these two functions in my script but I can't seem to get it right.

Local storeItem = StoreManager:getItemByXMLFilename (xmlFilename)

Local numItem = g_currentMission:getNumOfItems (storeItem, FarmId)


I have tried to replace xmlFilename with: "$moddir$MyMod/sign/HorseTrainerSign.xml"
But then my script wont load, I get the error dataS/scripts/shop/StoreManager.lua(482) : attempt to index field 'xmlFilenameToItem' (a nil value).

If I try to skip the first function, I replace storeItem with the name from my modDesc, the l10n text name: "shopItem_HorseTrainer".
I replace FarmId with "1". But the function still returns 0 when I buy this modded placeable. I have also tried using the <en> translated name of the item with same result.

How do I get this to work? or is there another way? :hmm:

btw the script is in the same mod as the placeable.