Auto-translated
array = {Chupa = 0, Lapa = 2, Nuba = 0, Roma = 2}
New here? I'm Roha — want a quick tour?
array = {Chupa = 0, Lapa = 2, Nuba = 0, Roma = 2}
So, without any special characters, it recognizes it as a string? Or is this only applicable to the second case? Interesting...
for i,e in mass
startThread(oops_..i.._F)
end;
The above is just an example)Yes, it recognizes it.
Is it possible to specify a variable function name in startThread (it doesn't like quotes)? For example:The above is just an example)
for i,e in mass
startThread(oops_..i.._F)
end;
array = {
[1] = function()
end, -- semicolons should be placed inside the array, following tradition :)
[2] = function() -- they are there for another purpose
end,
}
and access it like this: array[1](arg1, arg2)function oops_1_F()end
function oops_2_F()end
for i=1,2 do
startThread(parse('oops_'..i..'_F()'))
end
Added 4 minutes later
[/U]
Excellent. I'll try it out. Thank you.
function oops_1_F()end
function oops_2_F()end
for i=1,2 do
startThread(parse('oops_'..i..'_F()'))
end
Is a composite index possible? Or an alias? Like, you access it using two different string names, but you get the same value.
You can create a multidimensional array or concatenate indices, but it's all complicated when the goal is unknown.
if hero1 >= hero2 then
array[hero1..hero2] = element
else
array[hero2..hero1] = element
end
The same applies when accessing the array.
Will it be necessary to go through all the existing town names listed in the game's resources to check if they are present on the map?
function obj()
while 1 do
local heroes = {};
local m = 0;
local h = 0;
local count = 0;
heroes = GetPlayerHeroes(PLAYER_1);
--for m, h in heroes do
h = "Muscip";
if HasArtefact(h, 36) then
count = count + 1;
end;
if HasArtefact(h, 37) then
count = count + 1;
end;
if HasArtefact(h, 38) then
count = count + 1;
end;
if HasArtefact(h, 39) then
count = count + 1;
end;
if HasArtefact(h, 40) then
count = count + 1;
end;
if HasArtefact(h, 41) then
count = count + 1;
end;
if HasArtefact(h, 42) then
count = count + 1;
end;
if HasArtefact(h, 43) then
count = count + 1;
end;
end;
local sl = GetPlayerHeroes(PLAYER_1);
local res
if count == 8 then
print("Player 1 has all artifacts");
SetObjectiveState("obj", OBJECTIVE_COMPLETED);
Win ();
break;
end;
sleep(5);
end;
end;
startThread (obj);I made some adjustments to it:function obj()
while 1 do
local heroes = {};
local o = 0;
local h = 0;
local count = 0;
heroes = GetPlayerHeroes(PLAYER_1);
--for o, h in heroes do
h = "Muscip";
if HasArtefact(h, 36) then
count = count + 1;
end;
if HasArtefact(h, 37) then
count = count + 1;
end;
if HasArtefact(h, 38) then
count = count + 1;
end;
if HasArtefact(h, 39) then
count = count + 1;
end;
if HasArtefact(h, 40) then
count = count + 1;
end;
if HasArtefact(h, 41) then
count = count + 1;
end;
if HasArtefact(h, 42) then
count = count + 1;
end;
if HasArtefact(h, 43) then
count = count + 1;
end;
end;
o = "obj"
local sl = GetPlayerHeroes(PLAYER_1);
if count == 1 then
print("Player 1 has 1/8 artifacts");
SetObjectiveProgress(o, 1);
end;
if count == 2 then
print("Player 1 has 2/8 artifacts");
SetObjectiveProgress(o, 2);
end;
if count == 3 then
print("Player 1 has 3/8 artifacts");
SetObjectiveProgress(o, 3);
end;
if count == 4 then
print("Player 1 has 4/8 artifacts");
SetObjectiveProgress(o, 4);
end;
if count == 5 then
print("Player 1 has 5/8 artifacts");
SetObjectiveProgress(o, 5);
end;
if count == 6 then
print("Player 1 has 6/8 artifacts");
SetObjectiveProgress(o, 6);
end;
if count == 7 then
print("Player 1 has 7/8 artifacts");
SetObjectiveProgress(o, 7);
end;
if count == 8 then
print("Player 1 has all artifacts");
SetObjectiveState(o, OBJECTIVE_COMPLETED);
Win ();
break;
end;
sleep(5);
end;
end;
startThread (obj);function obj()
local old = 0
while 1 do
local count = 0
for i=36,43 do
count = count + (HasArtefact("Muscip", i) or 0)
end
if count == 8 then
print("Player 1 has all artifacts")
SetObjectiveState("obj", OBJECTIVE_COMPLETED)
Win()
break
end
if count ~= old then
print("Player 1 has "..count.."/8 artifacts")
SetObjectiveProgress("obj", count)
old = count
end
sleep(5)
end
end
startThread (obj)How do you iterate through the cities existing on the map if their names are not known in advance?
Will I have to iterate through all existing city names defined in the game resources to check for their presence on the map?
Problems:
- How to track the fact that a battle has taken place (something like a trigger)?
- How to track the fact that heroes have met or visited a garrison?