Skip to content
#3676
Auto-translated
Jewily, while your function works (thank you, I'll keep that in mind), it doesn't work in my case.

Here's the thing: as I said, I'm trying to create something similar to the Town Portal system in Heroes 3, but using objects.
How can I do this? The only thing that comes to mind is using a QuestionBox.
Do you want to go to Halad? If the answer is "no," maybe you want to go to Torost, and so on. I have many towns on my map.

So, I can only attach a function to the object that contains a QuestionBox. And a different function is responsible for the actual teleportation.

I'm writing:

function Town_Portal_Tilgatal_Obelisk_F (heroname) -- this is the function for the obelisk of the town of Tilgatal, i.e., attached to the object.
if(GetObjectOwner(heroname) == 1) then
QuestionBox("/Maps/SingleMissions/L1/Portal_Halad.txt", "Portal_HaladF", "Town_Portal_Torost_question_F"); ----question: do you want to go to Halad? If yes, we teleport; if no, we offer Torost.
sleep(1)
else
print("wrong hero");
end;
end;
Trigger(OBJECT_TOUCH_TRIGGER, "town_portal_Tilgatal", "Town_Portal_Tilgatal_Obelisk_F");

And here is the function for the teleport itself:

function Portal_HaladF (heroname)
if(GetObjectOwner(heroname) == 1) then
SetObjectPosition(heroname, 56, 90, 0);
else
print("wrong hero");
end;
end;

The question is asked, but it doesn't teleport; instead, it writes Script Error: Object "1" does not exist.

Moreover, if I write in the second function:

function Portal_HaladF (heroname)
if heroname == "Shadwyn" then
SetObjectPosition("Shadwyn", 56, 90, 0);
sleep(1);
end;
end;

Then nothing is written, but the teleportation doesn't happen.

But if I simply write instead of the second function:
function Portal_HaladF (heroname)
SetObjectPosition("Shadwyn", 56, 90, 0);
sleep(1);
end;
- then everything works fine, it teleports to the right place.

But if I replace "Shadwyn" with heroname, it again writes Script Error: Object "1" does not exist.

What could be the reason for this? Why doesn't the check for the hero's name or belonging to the first player work in the second function?

Statistics

Welcome our newest member: artem

Users Online 4 users 1649 guests