Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
#1247
Auto-translated
end statements should still be placed after else.
Here is a script from another map:
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);
sleep(5);
end
if count == 8 then
SetObjectiveState("obj", OBJECTIVE_COMPLETED);
else
SetObjectiveProgress('obj', count);
end;
old = count
end;
sleep(5);
end;
end;
And it works perfectly.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1248
Auto-translated
Heroist
extra end before else
Warrior777
ends after else

Maybe the problem is in this? Everything is correct in this code.

Whatever
User Avatar
#1249
Auto-translated
Okay, I figured it out myself. I just mixed up BEFORE with AFTER.

Added 51 seconds later
I removed those endings; let's see now...
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1250
Auto-translated
Now he writes completely nonsensical things: The called function: function eh1F(heroname) if eh1p == 0 then eh1p = 1 AddHeroCreatures(heroname,91,fac); AddHeroCreatures(heroname,85,eac); AddHeroCreatures(heroname,86,eac); AddHeroCreatures(heroname,87,eac); AddHeroCreatures(heroname,88,eac); ShowFlyingSign(w.."ehe.txt"); sleep(5); else ShowFlyingSign(w.."ehp.txt"); end; end;
Attachments 1
1 file attached • Total size: 1.2 KB
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1251
Auto-translated
it (the error/console) says that there is a reference to an object in the script, but the name is "", i.e., it has no name. And, of course, it doesn't exist on the map...

Whatever
User Avatar
#1252
Auto-translated
There are no objects with an empty name in the specifically invoked function.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1253
Auto-translated
And why did you conclude that the error refers specifically to this function? The console doesn't seem to say anything about it...

Whatever
User Avatar
#1254
Auto-translated
Because this message appeared not at the beginning, but during the function call. And I also checked the script, and there were no empty fields anywhere.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1255
Auto-translated
Ah, I see. It (the function) didn't recognize heroname as a hero. The function needs to be activated by a hero. For example, attach a touch/region trigger to it. Otherwise, it won't know which hero to give the army to...

Whatever
User Avatar
#1256
Auto-translated
A trigger exists.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1257
Auto-translated
Can I view it (script expression for a trigger that calls a function)?

Whatever
User Avatar
#1258
Trigger(OBJECT_TOUCH_TRIGGER,"eh1","eh1F");
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1259
Auto-translated
are the variables `eac` and `fac` greater than or equal to 0? (although, this is not really important)

Then I don't know what the problem is. Did the hero interact with this object? Then it's `heroname`. And then you can work with it...

Added 2 minutes later
So, does the object (to which the trigger is attached) have a name?

(Or did I already ask?)

Whatever
User Avatar
#1260
Auto-translated
1) fac = random(4,4);
eac = random(20,30);
2) It's obvious from the error.
502 Bad Gateway
__________________________________
nginx/0.8.54
User Avatar
#1261
Auto-translated
As you can see, this function (+trigger) has two objects. One is a hero. The second is an object that, when touched by the hero, starts the function.
Although, yes, since the function is called, the object must exist. The question is resolved.

I don't even know how to help. I checked it in the script editor - the syntax is correct.

Once again (for clarification). You started the map from the beginning. You approached the object with the hero. You clicked. The function failed. Is that correct? I just don't know how an error could occur in such a simple function.

Whatever

Statistics

Welcome our newest member: Emil