[H5 EDITOR] Troubleshooting topic
Disappointed in the lack of response. To spite that, i will ask another question that has bothered me.
What are the commands that the "Archmage" responds to? Everything i found has failed. Such as:
"attack","attack00","cast","happy","death","buff","idle00",etc.
even a few hard-to-find ones like "arch_mage_rangeattack" (or whatever the exacts are).
A few other creatures fail to respond as well. If anyone knows where to find such commands, i would appreciate your insight.
What are the commands that the "Archmage" responds to? Everything i found has failed. Such as:
"attack","attack00","cast","happy","death","buff","idle00",etc.
even a few hard-to-find ones like "arch_mage_rangeattack" (or whatever the exacts are).
A few other creatures fail to respond as well. If anyone knows where to find such commands, i would appreciate your insight.
PlayObjectAnimation("named whatever","idle00",ONESHOT);
The object 'named whatever' will do the 'idle00' animation, if it has such. Problem is, some creatures have different names for simular animations.
My problem is with just a few creature types. For example, an ArchMage has an 'idle' you can see working on the battlefield, but i can't find the names for all the animations. This is but one example of several i could have used.
The object 'named whatever' will do the 'idle00' animation, if it has such. Problem is, some creatures have different names for simular animations.
My problem is with just a few creature types. For example, an ArchMage has an 'idle' you can see working on the battlefield, but i can't find the names for all the animations. This is but one example of several i could have used.
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
New question
Ok a new code question. I'm trying to look at all the human players (PLAYER_ONE in this case) and give them goodies. In this case war machines, but it could as easily be artefacts. Since the names are unknown, I tried the code below, using 5 as the maximum numbers of heroes read. If there were less than 5 heroes then the plaernames(i) <> Nil would bypass the steps in the if statement:
In the console the error message was as follows:
last token read '==' at line 5 in string "DoString script".
I have tried both the single = and a double ==, but the error message is similar('=' or '==') in the error message. Any thoughts or suggestions?
Thanks
playernames(5)
if GetDate(Day) == 2 then
for i =1, 5 do
playernames(i)==GetPlayerHeroes(PLAYER_ONE);
end;
for i=1, 5
if playernames(i) <> Nil then
GiveHeroWarMachine(playernames(i), 1);
GiveHeroWarMachine(playernames(i), 2);
GiveHeroWarMachine(playernames(i), 3);
GiveHeroWarMachine(playernames(i), 4);
end;
end;
end;
In the console the error message was as follows:
last token read '==' at line 5 in string "DoString script".
I have tried both the single = and a double ==, but the error message is similar('=' or '==') in the error message. Any thoughts or suggestions?
Thanks
playernames(5)
if GetDate(Day) == 2 then
for i =1, 5 do
playernames(i)==GetPlayerHeroes(PLAYER_ONE);
end;
for i=1, 5
if playernames(i) <> Nil then
GiveHeroWarMachine(playernames(i), 1);
GiveHeroWarMachine(playernames(i), 2);
GiveHeroWarMachine(playernames(i), 3);
GiveHeroWarMachine(playernames(i), 4);
end;
end;
end;
GetPlayerHeroes returns an array, no cycle needed here. Also, pay attention to constant names. And finally, indexes go in square brackets.
So replace
for i =1, 5 do
playernames(i)==GetPlayerHeroes(PLAYER_ONE);
end;
with
playernames = GetPlayerHeroes(PLAYER_1)
Also, array elements numbering in lua starts with 0. So
instead of
for i=1, 5
if playernames(i) <> Nil then
GiveHeroWarMachine(playernames(i), 1);
use
for i=0, GetHeroCount(PLAYER_1)-1 do
GiveHeroWarMachine(playernames, 1);
So replace
for i =1, 5 do
playernames(i)==GetPlayerHeroes(PLAYER_ONE);
end;
with
playernames = GetPlayerHeroes(PLAYER_1)
Also, array elements numbering in lua starts with 0. So
instead of
for i=1, 5
if playernames(i) <> Nil then
GiveHeroWarMachine(playernames(i), 1);
use
for i=0, GetHeroCount(PLAYER_1)-1 do
GiveHeroWarMachine(playernames, 1);
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
After changing new error messages:
Value was NIL when getting global with 'GetHeroCount'
attempt to perform arithmetic on nil value
Using the concept of your suggestions, I tried this:
for x, length(playernames) - 1 do
The last change worked without any errors.
Thanks for the suggestion, and information about the array.
Value was NIL when getting global with 'GetHeroCount'
attempt to perform arithmetic on nil value
Using the concept of your suggestions, I tried this:
for x, length(playernames) - 1 do
The last change worked without any errors.
Thanks for the suggestion, and information about the array.
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Not on the pc that has the game, but I believe it was version 3.1. I didn't see the GetHeroCount in the documentations in the editor, so perhaps I only downloaded the patch and didn't install it. I'll look when I'm on the machine, thanks.Franzy wrote:GetHeroCount was added in the latest patch. Did you install it?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
OK, finally found your list
viewtopic.php?p=242326&highlight=script+changes#242326
But there was no mention of GetHeroCount. Is there another list somewhere or was this added afterward?
viewtopic.php?p=242326&highlight=script+changes#242326
But there was no mention of GetHeroCount. Is there another list somewhere or was this added afterward?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
My bad, I did find the orignal post and GetHeroCount is there. For reference here is the link.
viewtopic.php?t=9728
viewtopic.php?t=9728
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Tried using the GetHeroCount as follows:
numberofheroes = GetHeroCount(PLAYER_1); (used 1 also)
print (numberofheroes):
Got an error message:
[Script warning] Value was NIL when getting global with name 'GetHeroCount'
(script) ERROR: attempt to call a nil value
I understand the second error message if the first statement gives a NIL value. Since there isn't any documentation to refer, what am I doing wrong?
numberofheroes = GetHeroCount(PLAYER_1); (used 1 also)
print (numberofheroes):
Got an error message:
[Script warning] Value was NIL when getting global with name 'GetHeroCount'
(script) ERROR: attempt to call a nil value
I understand the second error message if the first statement gives a NIL value. Since there isn't any documentation to refer, what am I doing wrong?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
A continuiing series of questions, and here is the code. What I tried to do with this one is give each hero war machines the day after hiring:
GetDate(DAY);
playernames = GetPlayerHeroes(1);
if DAY == 0 then --Alter the for loop starting value
startnumberofheroes = 0;
previousnumberofheroes = length(playernames);
end;
if length(playernames) > previousnumberofheroes then
startnumberofheroes = previousnumberofheroes - 1;
end;
for i = startnumberofheroes, length(playernames) - 1 do
GiveHeroWarMachine(playernames, 1);
GiveHeroWarMachine(playernames, 3);
GiveHeroWarMachine(playernames, 4);
print(playernames); --Print the name whose skills altered
end;
previousnumberofheroes = length(playernames);
print(previousnumberofheroes);
print(DAY);
On DAY = 0, everything worked as I wished. However, after that the code did not work either for hiring a hero the intial day, or ending the day and hiring on the next day, ending that day as well without the desired results.
Question 1:
Does lua (Heroes) perform the script at the end of the previous day or
begining of the next? The reason for the question the two print statements were executed at the start of the mission, but NEVER again.
Question 2:
IF the for statement has the structure of:
for 1 = 1, 1 do --(only an example, real time variables would be used)
Will the above be executed one time or zero time?
My memories of code indicate the statement would be executed one time with the end point evaluated at the end of the for statement(not at the beginning).
Question 3:
Shouldn't the script be evaluated at sometime during EACH day?
GetDate(DAY);
playernames = GetPlayerHeroes(1);
if DAY == 0 then --Alter the for loop starting value
startnumberofheroes = 0;
previousnumberofheroes = length(playernames);
end;
if length(playernames) > previousnumberofheroes then
startnumberofheroes = previousnumberofheroes - 1;
end;
for i = startnumberofheroes, length(playernames) - 1 do
GiveHeroWarMachine(playernames, 1);
GiveHeroWarMachine(playernames, 3);
GiveHeroWarMachine(playernames, 4);
print(playernames); --Print the name whose skills altered
end;
previousnumberofheroes = length(playernames);
print(previousnumberofheroes);
print(DAY);
On DAY = 0, everything worked as I wished. However, after that the code did not work either for hiring a hero the intial day, or ending the day and hiring on the next day, ending that day as well without the desired results.
Question 1:
Does lua (Heroes) perform the script at the end of the previous day or
begining of the next? The reason for the question the two print statements were executed at the start of the mission, but NEVER again.
Question 2:
IF the for statement has the structure of:
for 1 = 1, 1 do --(only an example, real time variables would be used)
Will the above be executed one time or zero time?
My memories of code indicate the statement would be executed one time with the end point evaluated at the end of the for statement(not at the beginning).
Question 3:
Shouldn't the script be evaluated at sometime during EACH day?
The script is executed ONCE right after the map is created BEFORE any player moves. To execute a code on a certain day or event, use triggers. For the new turn (day) trigger use NEW_DAY_TRIGGER. This trigger triggers when the new turn is started by the first player. There is no trigger for the end of turn.
As for your other questions:
for 1 = 1, 1 do will generate an error
I believe you meant something like for i=1,1 do
This will run 1 time.
for i=1,0 do will run 0 times.
Did not understand you 3d question. Is it a suggestion?
Also, day counting starts from 1, not 0.
P.S. To save you from a common mistake, NEW _DAY_TRIGGER does NOT triggers on the first day.
for 1 = 1, 1 do will generate an error
I believe you meant something like for i=1,1 do
This will run 1 time.
for i=1,0 do will run 0 times.
Did not understand you 3d question. Is it a suggestion?
Also, day counting starts from 1, not 0.
P.S. To save you from a common mistake, NEW _DAY_TRIGGER does NOT triggers on the first day.
Who is online
Users browsing this forum: No registered users and 1 guest