Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
Regarding your script, it updates the task when there are exactly 8 artifacts.

Added 5 minutes later
function am()
	local old = 8
	while 1 do
		local count = 0
		for i=36,43 do
			count = count + (HasArtefact("Muscip", i) or 0)
		end
		if count ~= old then
			if old < 8 then
				SetObjectiveState("obj", OBJECTIVE_ACTIVE);
			end
			if count == 8 then
				SetObjectiveState("obj", OBJECTIVE_COMPLETED);
			else
				SetObjectiveProgress('obj', count);
			end;
			old = count
		end;
		sleep(5);
	end;
end;
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
Auto-translated
if old == 8 then
Because of this, I doubt your script.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
Auto-translated
So, it turns out that the task will only update if the number of artifacts is equal to 8, but in the place where I actually need it, i.e., with a smaller value, it won't.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
(Script) ERROR: Objective obj is not active
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
Auto-translated
Yes, it was exactly your version, unchanged.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
SetRegionBlocked("Block1", true, 2);
SetRegionBlocked("Block2", true, 2);
SetObjectiveVisible("killall", nil);

function am()
local old = 8
while 1 do
local count = 0
for i=36,43 do
count = count + (HasArtefact("Muscip", i) or 0)
end
if count ~= old then
if old == 8 then
SetObjectiveState("obj", OBJECTIVE_ACTIVE);
end
if count == 8 then
SetObjectiveState("obj", OBJECTIVE_COMPLETED);
else
SetObjectiveProgress('obj', count);
end;
old = count
end;
sleep(5);
end;
end;

function killallactive()
SetObjectiveVisible("killall", true);
startThread (am);
end;

function winF()
Win();
end;

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);
QuestionBox(GetMapDataPath().."complete-game.txt", "killallactive", "winF");
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);
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
Auto-translated
It is the true one.
502 Bad Gateway
__________________________________
nginx/0.8.54
In reply to Warrior777
User Avatar
Auto-translated
Does yours work?

(Script) ERROR: Objective obj is not active
Basically, this means that the objective was not activated before the progress was changed.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
My version differs from yours only in that instead of "equal to," there's "less than" in the line `if old == 8`.
502 Bad Gateway
__________________________________
nginx/0.8.54

Statistics

Welcome our newest member: Emil