[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.
Emore
Leprechaun
Leprechaun
Posts: 8
Joined: 04 Jul 2010
Location: Arkansas

Unread postby Emore » 18 Jul 2010, 08:50

Nevermind about the sound fx. Stumbled onto them in the editor. I guess that such things as spell effects can be found in like manner, but as of yet, no dice.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 18 Jul 2010, 16:47

All pak files are simple zip archives.

Emore
Leprechaun
Leprechaun
Posts: 8
Joined: 04 Jul 2010
Location: Arkansas

Unread postby Emore » 19 Jul 2010, 01:56

Thank you Franzy. I got spells and sounds all over the place now. ^5

Emore
Leprechaun
Leprechaun
Posts: 8
Joined: 04 Jul 2010
Location: Arkansas

Unread postby Emore » 22 Jul 2010, 08:18

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.

Emore
Leprechaun
Leprechaun
Posts: 8
Joined: 04 Jul 2010
Location: Arkansas

Unread postby Emore » 27 Jul 2010, 12:34

Ok, dead like a grave.

If any passers through know where there is some life, would you be so kind as to pass on a link or some such?

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 27 Jul 2010, 17:45

These are not actions, these are animations. Not all creatures have all types of animations. If you can provide your code we'll be able to determine what's wrong exactly.

Emore
Leprechaun
Leprechaun
Posts: 8
Joined: 04 Jul 2010
Location: Arkansas

Unread postby Emore » 04 Aug 2010, 05:53

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.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 04 Aug 2010, 18:50

Well, just look into the data files and find out what you need. It's just plain text xml-files zipped into one archive!

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

New question

Unread postby bkknight2602 » 07 Aug 2010, 17:13

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;

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 08 Aug 2010, 05:43

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);

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 08 Aug 2010, 10:19

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.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 08 Aug 2010, 14:21

GetHeroCount was added in the latest patch. Did you install it?

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 15 Aug 2010, 19:17

Franzy wrote:GetHeroCount was added in the latest patch. Did you install it?
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
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 15 Aug 2010, 20:26

Docs are not udated with the patch, there is not even a devent readme. I suggest you browse the forum. I posted changelist for the past a while ago.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 16 Aug 2010, 03:09

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?

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 16 Aug 2010, 04:18

My bad, I did find the orignal post and GetHeroCount is there. For reference here is the link.

viewtopic.php?t=9728

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 16 Aug 2010, 13:00

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?

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 16 Aug 2010, 18:02

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?

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 17 Aug 2010, 17:47

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.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 17 Aug 2010, 17:51

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.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 1 guest