edited March 5 in ORK Scripting
Hi GiL,
I can't find the API to do the purchase in the shop, so here is what I do:
Combatant leader = ORK.Game.ActiveGroup.Leader;
selectedItem = (ShopWrapperShortcut)sender;
...
...
bool successAdded = false;
if(selectedItem.IsCombatant){
Combatant combatant = ORK.Combatants.Create(selectedItem.Shortcut.ID, ORK.Game.ActiveGroup, false, false);
combatant.Init();
CombatantShortcut combatantShortcut = new CombatantShortcut(combatant, 1);
successAdded = leader.Inventory.Add(combatantShortcut, false, false, true);
}else if(selectedItem.IsItem)......
......
if(successAdded){
leader.Inventory.AddMoney(0, -selectedItem.BuyPrice(leader), false, false); //Pay the money
}
}
}
But this causes a problem if the items have Limit Quantity, how can I deduct the purchased quantity from the shop remain quantity? Is there a purchase API that can do the job?
Thanks.
Post edited by bitmore on
  • The inventory's GetAllowedQuantity function will let you know that - it takes a shortcut instance and a quantity (if you pass -1 for the quantity, it'll use the quantity of the shortcut).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • @gamingislove Hi GiL, I'm still having this problem.
    I use theShopItem.quantity -= 1; to reduce the quantity if the purchase is done.
    But if I re-open the shop, the quantity will be reset.
    The setting of World->Shops->BaseSettings->Save Shop is checked.
    How can I save the shop in the script? Or is there an API that I should call when purchasing items from the shop?
  • You can get and set in-game shop data via ORK.Game.Scene.GetShop and ORK.Game.Scene.SetShop. If the shop wasn't saved before, you'll need to initialize it via the shop setting's GetItemList function.

    It's probably best to check this out in the ShopScreen class in ORK's source code. The whole functionality is used in there :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.