[H5 EDITOR] Troubleshooting topic
Hi experts !
I have created a new single player map.
First I've tried to script something quite simple but it didn't work.
So I just have copied and pasted the example provided by the manual:
function Meeting( heroname )
if heroname == "Arthur" then
SetPlayerResource( PLAYER_1, GOLD, 10000 );
AddHeroCreatures( heroname, CREATURE_ARCHANGEL, 1 );
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "meeting", nil );
end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "meeting", "Meeting" );
I have created a region and named it "meeting".
I have named my hero "Arthur".
I've tested the script in game and... nothing.
In the editor, when I perform a "check script", I have two errors:
Function Meeting not defined, line 1
Function CREATURE_ARCHANGEL not defined, line 4
Now, I have an headache.
Could you please help me ?
(Excuse my bad english, I'm belgian)
It seems that the game
I have created a new single player map.
First I've tried to script something quite simple but it didn't work.
So I just have copied and pasted the example provided by the manual:
function Meeting( heroname )
if heroname == "Arthur" then
SetPlayerResource( PLAYER_1, GOLD, 10000 );
AddHeroCreatures( heroname, CREATURE_ARCHANGEL, 1 );
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "meeting", nil );
end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "meeting", "Meeting" );
I have created a region and named it "meeting".
I have named my hero "Arthur".
I've tested the script in game and... nothing.
In the editor, when I perform a "check script", I have two errors:
Function Meeting not defined, line 1
Function CREATURE_ARCHANGEL not defined, line 4
Now, I have an headache.
Could you please help me ?
(Excuse my bad english, I'm belgian)
It seems that the game
Probably, you've changed hero name in wrong place... Here's what must be done:
Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.
Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.
Hello alavris.alavris wrote:Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.
That's what I had done. But no result.
Maybe you should use the scripting name of the hero ?josip wrote:Hello alavris.alavris wrote:Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.
That's what I had done. But no result.
That's what we actually were talking aboutMarzhin wrote:Maybe you should use the scripting name of the hero ?
Maybe the problem is here:josip wrote:That's what I had done. But no result.
So, maybe your hero that enters the region, doesn't stop there? Try it again using REGION_ENTER_WITHOUT_STOP_TRIGGER.HOMM5_Script_Functions.pdf wrote:REGION_ENTER_AND_STOP_TRIGGER – the hero enters the region (and must stay within it)
REGION_ENTER_WITHOUT_STOP_TRIGGER – the hero enters the region (and does not have to stay within it)
.
I have tried each kind of region trigger with no success.
So I have tried the most simple script:
GiveExp( "Arthur", 4000 );
I am sure that my hero is named Arthur.
If I open the .h5m file, I find a file "name.1.txt" that contains the name "Arthur". So it should work, but.... no !
If I perform a check test, I have the result :
Function GiveExp not defined, line 1
And more amazing, I have started the game with console enabled to see the code history. The console says :
(script error) Hero Arthur not exists
Incredible but I'm sure of the name of my hero.
Is it possible that the problem come with the language of my keayboard ?
As an example, to enable console, I had to write :
bind show_console '`'
But in game the console is opened only if I press the key "²". That is because the "²" key on a belgian keyboard is at the place of the "`" key on english keyboard.
I'm stuck
So I have tried the most simple script:
GiveExp( "Arthur", 4000 );
I am sure that my hero is named Arthur.
If I open the .h5m file, I find a file "name.1.txt" that contains the name "Arthur". So it should work, but.... no !
If I perform a check test, I have the result :
Function GiveExp not defined, line 1
And more amazing, I have started the game with console enabled to see the code history. The console says :
(script error) Hero Arthur not exists
Incredible but I'm sure of the name of my hero.
Is it possible that the problem come with the language of my keayboard ?
As an example, to enable console, I had to write :
bind show_console '`'
But in game the console is opened only if I press the key "²". That is because the "²" key on a belgian keyboard is at the place of the "`" key on english keyboard.
I'm stuck
what was arthur's name before you customized it?
many times the game wants the heroscript name.
http://www.heroesofmightandmagic.com/he ... ames.shtml
this link has all the hero names. try that, and if its not that, then then its definetly something else. maybe the example in the manual was just a generic one.
many times the game wants the heroscript name.
http://www.heroesofmightandmagic.com/he ... ames.shtml
this link has all the hero names. try that, and if its not that, then then its definetly something else. maybe the example in the manual was just a generic one.
Thanks you very much. You got it.myythryyn wrote:what was arthur's name before you customized it?
many times the game wants the heroscript name.
http://www.heroesofmightandmagic.com/he ... ames.shtml
this link has all the hero names. try that, and if its not that, then then its definetly something else. maybe the example in the manual was just a generic one.
So, my hero was Nur. I had changed his name to Arthur both in the hero properties (Space menu) and in properties tree (CTRL+Space menu). I wrote my script with the name "Arthur" and it didn't work.
Now I still use the hero Nur but in hero properties I have changed his name to Arthur (this name appears in game).
AND in the properties tree I have changed his name to Astral, according to the list you have submitted.
In my script I used the name Astral.
It works.
So I'm gonna try a more complicated script.
Oh, I've never heard about it So, Marzhin, you were rightmyythryyn wrote:many times the game wants the heroscript name.
http://www.heroesofmightandmagic.com/he ... ames.shtml
.
-
- Leprechaun
- Posts: 5
- Joined: 18 Oct 2006
SINGLE VS MULTI SCRIPTS
im sorry if this quention was asked and answerred before, maybe i skipped that post,but here it is:
EXACLTY SAME scripts that work fine in single maps , copy-pasted into a multiplayer maps, seem to not work at all, not a single one of them.
both maps are test ones, just one is designed for single , the other for multi as initial setting.
is there any other option/setting that could make those scripts working in multiplayer maps?
ty
EXACLTY SAME scripts that work fine in single maps , copy-pasted into a multiplayer maps, seem to not work at all, not a single one of them.
both maps are test ones, just one is designed for single , the other for multi as initial setting.
is there any other option/setting that could make those scripts working in multiplayer maps?
ty
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Re: SINGLE VS MULTI SCRIPTS
No, I don't think there is anything you can do to make scripts work in a multiplayer map. Nival disabled scripts in multiplay to help prevent cheating.the_teacher wrote:im sorry if this quention was asked and answerred before, maybe i skipped that post,but here it is:
EXACLTY SAME scripts that work fine in single maps , copy-pasted into a multiplayer maps, seem to not work at all, not a single one of them.
both maps are test ones, just one is designed for single , the other for multi as initial setting.
is there any other option/setting that could make those scripts working in multiplayer maps?
ty
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Hello all experts and greets 2 all HOM&M fans!
I have the following problem with my script: I wanted to replace all army of one hero with specified units so I wrote the following code:
unfortunately it behaves strangely (fast, simple example, but in both castles, Haven and Necro, tested heroes had two units in their armies):
- for haven units (I tested 2 first heroes) it looks ok (all added creatures exists), but peasant stays
- for necro units (again, tested with 2 first heroes) I have only 20 scouts and 1 peasant in the army...
can somebody help me? reproduce the effects or show me my mistake?
thnx in advance and welcome
otter
edit: I forgot to write that this script is only used for newly created heroes (bought in tavern or when game was started) so for sure they have no more than 3-4 unit in army..
I have the following problem with my script: I wanted to replace all army of one hero with specified units so I wrote the following code:
Code: Select all
function ReplaceArmy(heroname)
AddHeroCreatures(heroname, 1, 1);--want to make sure that at least one unit exist during cleaning of all units
for i=2,CREATURES_COUNT do -- not i=1 since we want one unit remain to delete it at the end-> make sure hero will not be left w/o units during cleaning
if (GetObjectCreatures(heroname, i) > 0) then
RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));--did GetObjectCre.. instead of big number cause in my version with 'quantity' bigger that actual creatures count script stopped to work so I had to pass exact number of creatures and not even one more..
end;
end;
-- now all units should be cleared except for peasants
AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
RemoveHeroCreatures(heroname, 1, GetObjectCreatures(heroname, 1));
AddHeroCreatures(heroname, CREATURE_WITCH, 15);
AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
AddHeroCreatures(heroname, CREATURE_RIDER, 3);
end;
- for haven units (I tested 2 first heroes) it looks ok (all added creatures exists), but peasant stays
- for necro units (again, tested with 2 first heroes) I have only 20 scouts and 1 peasant in the army...
can somebody help me? reproduce the effects or show me my mistake?
thnx in advance and welcome
otter
edit: I forgot to write that this script is only used for newly created heroes (bought in tavern or when game was started) so for sure they have no more than 3-4 unit in army..
Witam przyjaciela z Polski!
Here's my code:
There is one bug that in my opinion will always happen: when you buy hero with only one type of creatures, one stack with one unit of this creature will not be removed.
This part of my code should remove this bug but it doesn't:
Print command works, but RemoveHeroCreatures command doesn't work in this unique situation. I think it's in-game bug.
.
Here's my code:
Code: Select all
function ReplaceArmy(heroname)
for i=1,91 do
if (GetObjectCreatures(heroname, i) > 0) then
RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));
end;
end;
AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
for i=1,91 do
if (GetObjectCreatures(heroname, i) == 1) then
RemoveHeroCreatures(heroname, i, 1);
print("creature[", i, "] removed");
end;
end;
AddHeroCreatures(heroname, CREATURE_WITCH, 15);
AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
AddHeroCreatures(heroname, CREATURE_RIDER, 3);
end;
Trigger(PLAYER_ADD_HERO_TRIGGER, PLAYER_1, "ReplaceArmy");
This part of my code should remove this bug but it doesn't:
Code: Select all
for i=1,91 do
if (GetObjectCreatures(heroname, i) == 1) then
RemoveHeroCreatures(heroname, i, 1);
print("creature[", i, "] removed");
end;
end;
.
A witam Witam i pozdrawiam
I know about the situation with one unit remaining during clearing, that is why
I added peasants (creatures with number 1), then removed all other creatures (except for peasants - I started my loop from 2), added scouts, removed peasants and added remaining units (remove comments from my code it is not looking clearly right now). In your case you have to loop through all in-game creatures twice so my solution seems to be little faster, but the problem remains: none of these solutions works
If it is in-game bug then I have to live with it. Thanx for your effort.
I know about the situation with one unit remaining during clearing, that is why
I added peasants (creatures with number 1), then removed all other creatures (except for peasants - I started my loop from 2), added scouts, removed peasants and added remaining units (remove comments from my code it is not looking clearly right now). In your case you have to loop through all in-game creatures twice so my solution seems to be little faster, but the problem remains: none of these solutions works
If it is in-game bug then I have to live with it. Thanx for your effort.
Alavis your code works if you put a sleep before the ==1 part so the code would be :
you'll get only 2 bugs :
1- when you hire a hero and you put it in garrison and then exit town(the hero is still in garrison), the game wont find the hero.
2- when you hire a dungeon hero you'll have 21 scouts instead of 20 so you should add :
Code: Select all
function ReplaceArmy(heroname)
for i=1,91 do
if (GetObjectCreatures(heroname, i) > 0) then
RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));
end;
end;
AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
AddHeroCreatures(heroname, CREATURE_WITCH, 15);
AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
AddHeroCreatures(heroname, CREATURE_RIDER, 3);
sleep(1)
for i=1,91 do
if (GetObjectCreatures(heroname, i) == 1) then
RemoveHeroCreatures(heroname, i, 1);
print("creature[", i, "] removed");
end;
end;
end;
1- when you hire a hero and you put it in garrison and then exit town(the hero is still in garrison), the game wont find the hero.
2- when you hire a dungeon hero you'll have 21 scouts instead of 20 so you should add :
Code: Select all
sleep(1)
if (GetObjectCreatures(heroname, 71) == 21) then
RemoveHeroCreatures(heroname, 71, 1);
end;
Last edited by Najibarr on 22 Oct 2006, 18:04, edited 1 time in total.
Hi!
Thanx for that trick with sleep, everything is working now also with my version of this script. It looks like game has some synchronization problems.
anyway:
There is only one loop in it and additionally you can avoid 2nd problem which was mentioned by Najibarr.
Thanx for that trick with sleep, everything is working now also with my version of this script. It looks like game has some synchronization problems.
anyway:
Code: Select all
function ReplaceArmy(heroname)
AddHeroCreatures(heroname, 1, 1);
for i=2,CREATURES_COUNT-1 do
if (GetObjectCreatures(heroname, i) > 0) then
sleep(1);
RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));
end;
end;
AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
RemoveHeroCreatures(heroname, 1, GetObjectCreatures(heroname, 1));
AddHeroCreatures(heroname, CREATURE_WITCH, 15);
AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
AddHeroCreatures(heroname, CREATURE_RIDER, 3);
end;
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
In my Seize the Throne map I have a script that is not working as I intended. I intended the script to display a message when the human player loses his main heroe, make the player lose, and display the message summary.
The script does make the human player lose but then the computer players continue their turns. The player can hit escape to chose game options, like exit to main menue, load, or exit to desktop, but the game summary is not displayed.
I am certain that at some point I did have a script that caused the mission summary to be displayed after the player lost, but I am not certain what I changed.
Perhaps another pair of eyes can find the problem.
function MainHeroAlive (heroname, herokiller)
if heroname == humanmainheroe then
MessageBox('Maps/SingleMissions/Seize The Throne/LoseGame.txt'); --player loses if he loses his first hero pick
Loose ();
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman, "MainHeroAlive");
GOW
The script does make the human player lose but then the computer players continue their turns. The player can hit escape to chose game options, like exit to main menue, load, or exit to desktop, but the game summary is not displayed.
I am certain that at some point I did have a script that caused the mission summary to be displayed after the player lost, but I am not certain what I changed.
Perhaps another pair of eyes can find the problem.
function MainHeroAlive (heroname, herokiller)
if heroname == humanmainheroe then
MessageBox('Maps/SingleMissions/Seize The Throne/LoseGame.txt'); --player loses if he loses his first hero pick
Loose ();
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman, "MainHeroAlive");
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Maybe instead of this
write this:
Maybe it will work now...
.
Code: Select all
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman);
Code: Select all
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman, nil);
.
Who is online
Users browsing this forum: No registered users and 0 guests