Connection ErrorBad RequestSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
Well, I worded it a bit incorrectly. I meant all buildings, i.e., level 1 buildings in general. Although, to be honest, the aforementioned function would still be useful, and I would have to ask about it separately. So, everything is fine =)
How can I use a script to move an object to a specific Z coordinate?
Мои карты: Town Готовится:Чума (40%), Сосиска(42%), Война Грааля
Heroist
13 years ago
Auto-translated
I've been wondering for a while: -How will the AI behave if it encounters an object/trigger with message/question boxes and answer choices, for example, after which a battle will begin? I always do a check for the current player in this case, but is there another way...?
So, will all these boxes be addressed to a single player? And if there are multiple players, will each of them receive one? Hmm... that's disappointing. I thought we could avoid the need for verification...
Whatever
Dyrman
13 years ago
Auto-translated
Is it possible to remove elements from an array while simultaneously reducing the array's length by the number of elements removed?
function cut(array, index) local ar for i, e in array do if i ~= index then ar= e end end return ar end
For example, the operation mass=cut(mass, 0) will remove the element with index 0, and the length function for this array will return a number that is 1 less.
Here's a function that will work:
```lua
function cut(array, index)
local ar = {}
for i, e in array do
if i ~= index then
ar[i] = e
end
end
return ar
end
```
mass=cut(mass, 0)
function cut(array, index)
local ar = {}
for i, e in array do
if i ~= index then
ar[i] = e
end
end
return ar
end
So, there isn't a standard function for this? Iterating through an array is already a resource-intensive operation.
And what if you need to add an element to the array later? Would you have to manually write the shift? )))
function add(array, index, change) local ar = {} local f = 0; for i, e in array do if i == index then ar= change; f = 1; end if f == 1 then ar[i+1]= e; else ar= e; end; end return ar end
Added 4 minutes later RedHeavenHero
There isn't a standard one.
That's a shame :( You can write anything by hand, but it's not the same...
function add(array, index, change) local ar = {} local f = 0; for i, e in array do if i == index then ar= change; f = 1; end if f == 1 then ar[i+1]= e; else ar= e; end; end return ar end
In other words, is an array needed where all indices are integers, differing from each other by 1, and where it would be possible to insert new elements between others and delete old ones with a shift?
So, you need an array where all indices are integers, differing from each other by 1, and it should be possible to insert new elements between others and delete old ones with shifting?
Correct. But it's not that difficult to write yourself, but it would be great if there was a way to use a match table or some library... :rolleyes:
Added 5 minutes later And can the index be a string? Like this:
That's right. But it's not difficult to write it yourself, but it would be great to have the ability to use a match table or some kind of library... :rolleyes:
Added 5 minutes later Can the index be assigned as a string?
Yes, but it is highly undesirable to mix strings with numbers, and to put values with indices "0" and 0 into the same array. A string index can be assigned in two ways: array["string"] = element array.string = element but in the second case, string must conform to the standards of ordinary variable names.