Hello! I finished this script but hadnt the opportunity to try it. can anyone see if it is correct? The idea is make a npc that is a tax collector and every 100k of donations he create one more sqm of gold in the vault of the city. So I want the script to check if there are golds on the tiles, if they are the central parts, move on. if they are gold BORDERS, it will remove the borders and add a central part and on pos x - 1 (left side) it will add a new border and obviously correct the border tiles above or below. I will make the gold being added only in 1 direction for now because the vault is small so there is no need to make a complex script that checks all kinds of borders and fills the vault in all directions
Gold center filling parts
(IDS 14973;14974;14975;14976;14977;14978)
Gold borders
(Forgot to include 14986)
Vault
Gold center filling parts
(IDS 14973;14974;14975;14976;14977;14978)
Gold borders
(Forgot to include 14986)
Vault
vault = {}
vault.coords = {
[14986] = {
{x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
[14979] = {
{ {x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
[14985] = {
{ {x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
[15025] = {
{ {x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
[15024] = {
{ {x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
[14980] = {
{ {x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
[14984] = {
{ {x = 959, y = 1001, z = 7}, {x = 958, y = 1001, z = 7}, {x = 957, y = 1001, z = 7}, {x = 959, y = 1002, z = 7}, {x = 958, y = 1002, z = 7},
{x = 957, y = 1002, z = 7}
}
}
vault.golds = {goldcenters = {14973, 14974, 14975, 14976, 14977, 14978}, goldborder = {14986, 14979, 14985, 15025, 15024, 14984, 14980}}
vault.funds = {totalfunds = 9898, holdingfunds = 9797}
hfunds = getGlobalStorageValue(vault.holdingfunds)
vault = setmetatable({}, { __index = vault.coords, vault.golds, vault.funds})
local x = vaul.goldborder[item.uid]
local z =vault.goldcenters[item.uid]
local i = vault.coords[item.uid]
local searchborder = getTileItemById(i[], x[]).uid
for item, positionArray in pairs(vault.coords) and (hfunds >= 100000) do /* check where are the borders and if the last donations reach 100k *\
for indx, vault.coords[] in ipairs(positionArray ) do
doRemoveItem(x[], 1) /*then remove the border and create a goldcenter*\
doCreateItem(vault.golds[1], 1)
setGlobalStorageValue(vault.holdingfunds, -100000)
for getTileItemById({y + 1}, 14986) do /*check if the tile below is with the wrong border, it will correct making the corners *\
doRemoveItem(getTileItemById({y + 1}, 14986).uid,1)
doCreateItem(15025, 1, {y + 1})
doCreateItem(14985, 1, {x - 1, y + 1})
end
for getTileItemById({y - 1}, 14986) do /* check if the tile above is with the wrong border, it will correct making the corners *\
doRemoveItem(getTileItemById({y - 1}, x[]).uid,1)
doCreateItem(15024, 1, {y + 1})
doCreateItem(14979, 1, {x - 1, y + 1})
end
for getTileItemById({y - 1}, 14979) do /*check if the tile below is with the wrong border, it will correct making the corners *\
doRemoveItem(getTileItemById({y - 1}, x[]).uid,1)
doCreateItem(14980, 1, {y - 1})
doCreateItem(14979, 1, {x - 1, y - 1})
end
for getTileItemById({X + 1}, 14980) do /*check if the tile below is with the wrong border, it will correct making the corners *\
doRemoveItem(getTileItemById({y - 1}, x[]).uid,1)
doCreateItem(14980, 1, {y - 1})
doCreateItem(14979, 1, {x - 1, y - 1})
end
end
end
Last edited: