- Bought casks not getting assigned actionID for unwrap script
- When unwrapped it only has 1 charge
I did manage to somehow make it unwrap to the correct id, but Ive been tinkering with the script so much and had to revert back to an older version and lost that progress. When I managed to make it unwrap correct I ran into another issue. The charges for the cask was not assigned and it was always giving a cask with 1 charge instead of the 1000 charges it should get when bought from the store.
Added 2 prints and both prints in console, so the code is being called for those sections atleast.
If Ive missed any script you need, just let me know.
Using this Distro, [TFS1.3]
Here is the code snip for buying a cask. And here is the full init.lua script.
Lua:
function GameStore.processHouseRelatedPurchase(player, offerId, offerCount)
local function isCaskItem(itemId)
return (itemId >= ITEM_HEALTH_CASK_START and itemId <= ITEM_HEALTH_CASK_END) or
(itemId >= ITEM_MANA_CASK_START and itemId <= ITEM_MANA_CASK_END) or
(itemId >= ITEM_SPIRIT_CASK_START and itemId <= ITEM_SPIRIT_CASK_END)
end
local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
if inbox and inbox:getEmptySlots() > 0 then
local decoKit = inbox:addItem(26054, 1)
local function changeKit(kit)
local decoItemName = ItemType(offerId):getName()
if kit then
kit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a <" .. decoItemName .. ">.")
kit:setCustomAttribute("unWrapId", offerId)
print(1)
if isCaskItem(offerId) then
kit:setAttribute(ITEM_ATTRIBUTE_DATE, offerCount)
print(2)
end
end
end
addEvent(function() changeKit(decoKit) end, 250)
else
return error({code = 0, message = "Please make sure you have free slots in your store inbox."})
end
end
This part here is a code snip from the values when buying said cask, in this case the normal mana potion cask (yes the code is missing brackets, this is more to show the values that the script above uses.) Full gamestore.lua script can be found here.
Lua:
{
icons = { "Category_Potions.png" },
name = "Casks",
offers = {
{
icons = { "Mana_Cask.png" },
name = "Mana Cask",
price = 26,
id = 28565,
count = 1000,
number = 1,
description = "Desc removed to condense code for easier reading.",
type = GameStore.OfferTypes.OFFER_TYPE_HOUSE,
},