• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Check my loops.

thedoc

Member
Joined
Jan 28, 2014
Messages
13
Reaction score
6
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
wi2255.png

(IDS 14973;14974;14975;14976;14977;14978)

Gold borders
2zs76hd.png

(Forgot to include 14986)

2dlkcnt.png

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:
Check the answer I posted to your other thread.

BTW - I can see from this one you have a full set of tiles.

This code might run, but I don't think you're using the right data design, so rather than test it I'd like to get the spec right then do a design from that (it might still turn out this one is ok).
 
Back
Top