ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi! I'm using TFS 1.4 downgraded by nekiro. I tried to create a script for svargrond wrote some local variables to define the different rewards but it's a whole mess and didn't worked. This was my attempt:
The script I wrote is just giving me random rewards xD I wasn't even close. I will explain how svargrond arena chest works; as soon you finish the first challenge (Greenhorn) you should be able to pick between 5 rewards. This rewards are:
You can only pick one and that's it. I tried to use tables to define what is inside the backpack and the present box but I really don't know what i'm doing. Can someone make this for me so I can see how it is supposed to be done? In advance, thanks!!
Regards
Lua:
local storage_id = PlayerStorageKeys.SvargrondArena.GreenhornChest
local presentItems = {{2114, 1}, {6570, 2}, {6574, 1}, {6569, 1}, {7377, 1}} ------ items inside the present
local backpackItems = {{7364, 100}, {7365, 100}} ------ items inside the backpack
local rewards = {
[4028] = {reward_id = present, reward_count = 1}, ---- "present" as reward defined on local variable
[4029] = {reward_id = backpack, reward_count = 1}, ---- "backpack" as reward defined on local variable
[4030] = {reward_id = 7392, reward_count = 1},-- [chest uid] = {reward item id, reward item count},
[4031] = {reward_id = 7380, reward_count = 1},
[4032] = {reward_id = 7406, reward_count = 1}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
---- local to add items inside the present
local present = player:addItem(1990) -- present
for i = 1, #presentItems do
present:addItem(presentItems[i][1], presentItems[i][2], presentItems[i][3], presentItems[i][4], presentItems[i][5])
end
---- local to add items inside the fur backpack
local backpack = player:addItem(7342) -- fur bp
for i = 1, #backpackItems do
backpack:addItem(presentItems[i][1], presentItems[i][2])
end
local storage = player:getStorageValue(storage_id)
if storage > 0 then
return player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
end
local reward = rewards[item.uid]
local reward_type = reward and ItemType(reward.reward_id)
if reward_type then
if player:addItem(reward.reward_id, reward.reward_count, false, 1, CONST_SLOT_WHEREEVER) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. reward_type:getName():lower() .. ".")
player:setStorageValue(storage_id, 1)
else
local weight = reward_type:getWeight()
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found an item weighing ' .. weight / 100 .. ' oz it\'s too heavy or you do not have enough room.')
end
end
return true
end
The script I wrote is just giving me random rewards xD I wasn't even close. I will explain how svargrond arena chest works; as soon you finish the first challenge (Greenhorn) you should be able to pick between 5 rewards. This rewards are:
Code:
a) a present box with a piggy bank, surprise bag (blue), bar of chocolate, 10x candy, ice cream
b) a fur backpack 100 sniper arrows, and 100 onyx arrows
c) orcish maul
d) head chopper
e) blacksteel sword
You can only pick one and that's it. I tried to use tables to define what is inside the backpack and the present box but I really don't know what i'm doing. Can someone make this for me so I can see how it is supposed to be done? In advance, thanks!!
Regards