First, you need to grab the require link for the latest version of the script. Head over to Greasy Fork https://greasyfork.org/en/scripts/488260-pixelshop and copy the bit that starts with // @require, but remove the ?version=whatever bit at the end. This needs to be added to your script's metadata (on top of the script). If you wish to target a specific version however, you can leave the ?version in - but this is not recommended as it can lead to multiple versions of the library being included and conflicting with each other.
This should be done before creating new coins, shops or items
Unless you don't need the currency to be saved between sessions you should load the currency amount after the player login
//If you are using IdlePixel+ you can do something as follow:
onLogin() {
PixelShopPlus.loadCoins()
}
//Do note that to loadCoins work the var_username needs to exist already, so you need to be careful when you will call it if you are not using IPP
//You should start registering your coins, there are no limits as for how many different coins you will use, the format is as follow:
let newCoin = {
name:"testCoin",
image:"https://raw.githubusercontent.com/Dounford-Felipe/DHP-Pets/main/images/goldenHeart.gif",
value:2000
};
PixelShopPlus.newCoin(newCoin);
//You don't need to create a variable:
PixelShopPlus.newCoin({name:'testCoin',image:'https://raw.githubusercontent.com/Dounford-Felipe/DHP-Pets/main/images/goldenHeart.gif',value:2000});
When creating new shops a new tab will appear on the game shop panel, if declared it will show the current value of the main Currency used on the shop.
Do note that even if all shops have a main currency you can create items that use a currency other than the main.
//You can add as many shops as you want, the format is as follow:
PixelShopPlus.newShop(shopName,shopMainCoin);
//It will be something like this:
PixelShopPlus.newShop('testShop','testCoin');
When creating new items they will appear on the corresponding shop tab.
Do note that even if all shops have a main currency you can create items that use a currency other than the main.
//You can add as many items to each shop as you want, the format is as follow:
PixelShopPlus.newItems(shopName,[itemObjects]);
let itemObject1 = {
name:"blueCat2", //The Item name
imageUrl:"https://raw.githubusercontent.com/Dounford-Felipe/DHP-Pets/main/images/blueCat.png", //The image that will be displayed on shop
coin:"testCoin", //The currency used to buy the item
price:1000, //The item price
tooltipText:"<span class='color-primary'>Blue Cat</span><br /><br />This cute cat wants to be your friend", //The text that will show when hovering over the item
buyText:"Adopt this cat to be your friend", //The text that will show when clicking to buy
boughtText:"Charlie will forever love you", //The text that will show after buying
bought:false, //If the item is already bought
callback:function(){IdlePixelPlus.plugins.myplugin.myFunction()} //After buying this function will be called, if you don't need this you can have it as a empty string
}
PixelShopPlus.newItems('testShop',[itemObject1,itemObject2,itemObject100])
If for some reason you need to remove a buyable item you can use this:
//Any item can be removed
PixelShopPlus.removeItem(shopName,itemName);
//The item on shop will be removed too
PixelShopPlus.removeItem('testShop','blueCat2');
The amount can be changed in 3 different ways: it can increase, decrease or be set to a specific amount.
All changes will 1 - Trigger the PixelShopPlus.saveCoins that will save the current amount on localstorage.
2 - Update all elements with the attribute coin-value=coinName with the new coin value.
//If you want to increase it.
PixelShopPlus.coinIncrease(coinName,amount);
PixelShopPlus.coinIncrease('testCoin',1000);
//If you want to decrease it.
PixelShopPlus.coinDecrease(coinName,amount);
PixelShopPlus.coinDecrease('testCoin',1200);
//If you want to have a defined amount.
PixelShopPlus.coinSet(coinName,amount);
PixelShopPlus.coinSet('testCoin',1432007);