[H5 EDITOR] Troubleshooting topic
ok ill need help with this script too. so far, ive only dealt with single triggered events, that only happen once. like this one im working on...
function lvl10reward ()
if GetHeroLevel ("heroname") == 10 then
AddHeroCreatures("heroname", creatureID, #);
MessageBox("Maps/SingleMissions/test/reward1.txt");
Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
end;
end;
Trigger (HERO_LEVELUP_TRIGGER, "heroname", "lvl10reward" );
which works, but i want there to be a lvl 20 reward, and a lvl 30 reward.
how do you reuse the same trigger over again?
i tried removing the line
Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
but then the rewards didnt trigger at all.
whats the correct syntax, format?
function lvl10reward ()
if GetHeroLevel ("heroname") == 10 then
AddHeroCreatures("heroname", creatureID, #);
MessageBox("Maps/SingleMissions/test/reward1.txt");
Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
end;
end;
Trigger (HERO_LEVELUP_TRIGGER, "heroname", "lvl10reward" );
which works, but i want there to be a lvl 20 reward, and a lvl 30 reward.
how do you reuse the same trigger over again?
i tried removing the line
Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
but then the rewards didnt trigger at all.
whats the correct syntax, format?
Try changing first line of code in function lvl10reward () to this:
.
Code: Select all
if mod(GetHeroLevel("heroname"), 10) == 0 then
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
myythryyn wrote: function lvl10reward ()
if GetHeroLevel ("heroname") == 10 then
AddHeroCreatures("heroname", creatureID, #);
MessageBox("Maps/SingleMissions/test/reward1.txt");
Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
end;
end;
Trigger (HERO_LEVELUP_TRIGGER, "heroname", "lvl10reward" );
which works, but i want there to be a lvl 20 reward, and a lvl 30 reward.
how do you reuse the same trigger over again?
i tried removing the line
Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
but then the rewards didnt trigger at all.
whats the correct syntax, format?
I think "nil" wil prevent the function from triggering more than once.Trigger( HERO_LEVELUP_TRIGGER, "heroname", nil);
Try something like:
function lvl10reward ()
if GetHeroLevel ("heroname") == 10 then
AddHeroCreatures("heroname", creatureID, #);
MessageBox("Maps/SingleMissions/test/reward1.txt");
elseif GetHeroLevel ("heroname") == 20 then
Whatever
elseif ("heroname") == 30 then
Whatever
end; --you don't need ends for the elseif statements
Trigger( HERO_LEVELUP_TRIGGER, "heroname");
end;
end;
Trigger (HERO_LEVELUP_TRIGGER, "heroname", "lvl10reward" );
I have not tried this so I can't guarentee it will work, but give it a try if you are still having trouble with it.
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."
ok i think im almost done my map and ready to post it. i just want to do one more thing. i read on page 6 of this post pitsu's instructions on how to make custom made loading screens. but im just not sure i understand the instructions completely.
can anyone help clarify the exact step to making a custom made loading screen?
i took a screenshot, resized it to a 1024 1024 BMP file, then used this program called DXTbmp to convert it to a DDS file. im assuming its still 1024 1024
this is the part i dont quite understand
<?xml version="1.0" encoding="UTF-8"?>
<Texture>
<SrcName href="/filename.tga"/>
<DestName href="/filename.dds"/>
<Type>REGULAR</Type>
<ConversionType>CONVERT_TRANSPARENT</ConversionType>
<AddrType>CLAMP</AddrType>
<Format>TF_DXT1</Format>
<Width>1024</Width>
<Height>1024</Height>
<MappingSize>0</MappingSize>
<NMips>1</NMips>
<Gain>0</Gain>
<AverageColor>0</AverageColor>
<InstantLoad>true</InstantLoad>
<IsDXT>false</IsDXT>
<FlipY>false</FlipY>
<StandardExport>true</StandardExport>
<UseS3TC>false</UseS3TC>
</Texture>
where, and how do i run this code? do i put this code directly in the HOMM script editor, but change filename.dds to my filename?
or do i run this code somewhere else?
where do i put my new resized DDS file? in HOMMV/maps folder?
then the code above finds it and converts it for me?
ok thxs for any help with this.
can anyone help clarify the exact step to making a custom made loading screen?
i took a screenshot, resized it to a 1024 1024 BMP file, then used this program called DXTbmp to convert it to a DDS file. im assuming its still 1024 1024
this is the part i dont quite understand
<?xml version="1.0" encoding="UTF-8"?>
<Texture>
<SrcName href="/filename.tga"/>
<DestName href="/filename.dds"/>
<Type>REGULAR</Type>
<ConversionType>CONVERT_TRANSPARENT</ConversionType>
<AddrType>CLAMP</AddrType>
<Format>TF_DXT1</Format>
<Width>1024</Width>
<Height>1024</Height>
<MappingSize>0</MappingSize>
<NMips>1</NMips>
<Gain>0</Gain>
<AverageColor>0</AverageColor>
<InstantLoad>true</InstantLoad>
<IsDXT>false</IsDXT>
<FlipY>false</FlipY>
<StandardExport>true</StandardExport>
<UseS3TC>false</UseS3TC>
</Texture>
where, and how do i run this code? do i put this code directly in the HOMM script editor, but change filename.dds to my filename?
or do i run this code somewhere else?
where do i put my new resized DDS file? in HOMMV/maps folder?
then the code above finds it and converts it for me?
ok thxs for any help with this.
yeah, I am on expert level in expressing myself in a confusing waymyythryyn wrote: i read on page 6 of this post pitsu's instructions on how to make custom made loading screens. but im just not sure i understand the instructions completely.
The code goes into a text file. But the simplest is to open your map in editor, go to "map properties tree" and make a new reference file for the PWLPicture line. The file you generated, has the forementioned code in it. But you have to manually edit your dds file name into it. So, close the editor and unpack h5m. Find the file that you just created in editor and write your dds file name into its code. You may also remove the " <SrcName href="/"/> "line. Finally, place the dds file itself into the same directory and pack it all back to a proper zip/h5m file.where, and how do i run this code? do i put this code directly in the HOMM script editor, but change filename.dds to my filename?
or do i run this code somewhere else?
where do i put my new resized DDS file? in HOMMV/maps folder?
then the code above finds it and converts it for me?
Hopefully theat was a bit clearer.
ok i need help with another script
i think its just a matter of logic that i need help with.
im trying to link three events to one trigger. i used the "elseif" to have two events linked to one trigger, but i cant get three to work.
one event happens in month one, another month two, and another in week 2, day 3
function attack (heroname)
local day;
local week;
local month;
day = GetDate(MONTH);
week = GetDate(WEEK);
month = GetDate(MONTH);
if month == 2 then
DeployReserveHero("hero1", 21, 21, 0);
OpenCircleFog(21, 21, 0, 5, PLAYER_1);
MoveCamera(21, 21, 0, 50, 0, 0, 0);
SetAIPlayerAttractor( "town", PLAYER_7, 2);
MessageBox("Maps/SingleMissions/test/help1.txt");
AddObjectCreatures("town", 48, 20)
AddObjectCreatures("town", 44, 30)
AddObjectCreatures("town", 51, 5)
AddObjectCreatures("town", 50, 15)
elseif month == 3 then
DeployReserveHero("hero2", 21, 21, 0);
OpenCircleFog(21, 21, 0, 5, PLAYER_1);
MoveCamera(21, 21, 0, 50, 0, 0, 0);
MessageBox("Maps/SingleMissions/test/help1.txt");
AddObjectCreatures("town", 48, 20)
AddObjectCreatures("town", 44, 30)
AddObjectCreatures("town", 51, 5)
AddObjectCreatures("town", 50, 15)
elseif week == 2
and day == 3 then
DeployReserveHero("hero3", 21, 21, 0);
OpenCircleFog(21, 21, 0, 5, PLAYER_1);
MoveCamera(21, 21, 0, 50, 0, 0, 0);
MessageBox("Maps/SingleMissions/test/help1.txt");
AddObjectCreatures("town", 48, 20)
AddObjectCreatures("town", 44, 30)
AddObjectCreatures("town", 51, 5)
AddObjectCreatures("town", 50, 15)
end;
end;
Trigger (NEW_DAY_TRIGGER, "attack" );
the first two events happen, but not the third.
what is the correct logic statement, or syntax i need?
i think its just a matter of logic that i need help with.
im trying to link three events to one trigger. i used the "elseif" to have two events linked to one trigger, but i cant get three to work.
one event happens in month one, another month two, and another in week 2, day 3
function attack (heroname)
local day;
local week;
local month;
day = GetDate(MONTH);
week = GetDate(WEEK);
month = GetDate(MONTH);
if month == 2 then
DeployReserveHero("hero1", 21, 21, 0);
OpenCircleFog(21, 21, 0, 5, PLAYER_1);
MoveCamera(21, 21, 0, 50, 0, 0, 0);
SetAIPlayerAttractor( "town", PLAYER_7, 2);
MessageBox("Maps/SingleMissions/test/help1.txt");
AddObjectCreatures("town", 48, 20)
AddObjectCreatures("town", 44, 30)
AddObjectCreatures("town", 51, 5)
AddObjectCreatures("town", 50, 15)
elseif month == 3 then
DeployReserveHero("hero2", 21, 21, 0);
OpenCircleFog(21, 21, 0, 5, PLAYER_1);
MoveCamera(21, 21, 0, 50, 0, 0, 0);
MessageBox("Maps/SingleMissions/test/help1.txt");
AddObjectCreatures("town", 48, 20)
AddObjectCreatures("town", 44, 30)
AddObjectCreatures("town", 51, 5)
AddObjectCreatures("town", 50, 15)
elseif week == 2
and day == 3 then
DeployReserveHero("hero3", 21, 21, 0);
OpenCircleFog(21, 21, 0, 5, PLAYER_1);
MoveCamera(21, 21, 0, 50, 0, 0, 0);
MessageBox("Maps/SingleMissions/test/help1.txt");
AddObjectCreatures("town", 48, 20)
AddObjectCreatures("town", 44, 30)
AddObjectCreatures("town", 51, 5)
AddObjectCreatures("town", 50, 15)
end;
end;
Trigger (NEW_DAY_TRIGGER, "attack" );
the first two events happen, but not the third.
what is the correct logic statement, or syntax i need?
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Try this instead:myythryyn wrote:
elseif week == 2
and day == 3 then
Otherwise, you can probably do this:elseif GetDate (DAY) == 17 then
whatever
GOWelseif (week == 2
and day == 3 ) then
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."
thxs GOW, elseif GetDate (DAY) == 17 then
worked, i didnt know the game counted days that way.
im now trying to work with variables and more logic.
im trying to set up a series of events that happens after each hero that is deployed from the above script is killed. i thought i could use variables, but my attempts so far have failed.
i have to use the PLAYER_REMOVE_HERO_TRIGGER
this is what i was going to do...
function attack (heroname)
local variable1
local variable2
local variable3
if day == 2 then
DeployReserveHero("hero", 21, 21, 0);
varible1 == 1
elseif day == 8 then
DeployReserveHero("hero2", 21, 21, 0);
varible2 == 1
elseif day == 17 then
DeployReserveHero("hero3", 21, 21, 0);
varible3 == 1
end;
end;
Trigger (NEW_DAY_TRIGGER, "attack" );
function defeatattack (heroname)
local variable1
local variable2
local variable3
if (IsHeroAlive ("hero1") == no
and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible1 == 0 -- this will reset the varible so the above statement wont be true again thus the above message wont show again either
elseif (IsHeroAlive ("hero2") == no
and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible2 == 0
elseif (IsHeroAlive ("hero3") == no
and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible3 == 0
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
the problem im trying to prevent with variables, is that if hero1 dies so IsHeroAlive == no, and the message is shown for his death, and then hero2 dies afterwards, so his IsHeroAlive== no and his message is shown, the first message that is shown after the death of hero1 will also be shown, since hero1 is also dead. both statements will be true. and i have no control in which order the player will kill the enemies.
then if hero3 dies after the first two die, then all three messages will shown. so this is what i thought i could do, varibles are bolded....
but this so far is not working.....
ok thxs for any help
worked, i didnt know the game counted days that way.
im now trying to work with variables and more logic.
im trying to set up a series of events that happens after each hero that is deployed from the above script is killed. i thought i could use variables, but my attempts so far have failed.
i have to use the PLAYER_REMOVE_HERO_TRIGGER
this is what i was going to do...
function attack (heroname)
local variable1
local variable2
local variable3
if day == 2 then
DeployReserveHero("hero", 21, 21, 0);
varible1 == 1
elseif day == 8 then
DeployReserveHero("hero2", 21, 21, 0);
varible2 == 1
elseif day == 17 then
DeployReserveHero("hero3", 21, 21, 0);
varible3 == 1
end;
end;
Trigger (NEW_DAY_TRIGGER, "attack" );
function defeatattack (heroname)
local variable1
local variable2
local variable3
if (IsHeroAlive ("hero1") == no
and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible1 == 0 -- this will reset the varible so the above statement wont be true again thus the above message wont show again either
elseif (IsHeroAlive ("hero2") == no
and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible2 == 0
elseif (IsHeroAlive ("hero3") == no
and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible3 == 0
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
the problem im trying to prevent with variables, is that if hero1 dies so IsHeroAlive == no, and the message is shown for his death, and then hero2 dies afterwards, so his IsHeroAlive== no and his message is shown, the first message that is shown after the death of hero1 will also be shown, since hero1 is also dead. both statements will be true. and i have no control in which order the player will kill the enemies.
then if hero3 dies after the first two die, then all three messages will shown. so this is what i thought i could do, varibles are bolded....
but this so far is not working.....
ok thxs for any help
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
First, you left semicolons out in these lines:myythryyn wrote:
function defeatattack (heroname)
local variable1
local variable2
local variable3
if (IsHeroAlive ("hero1") == no
and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible1 == 0 -- this will reset the varible so the above statement wont be true again thus the above message wont show again either
elseif (IsHeroAlive ("hero2") == no
and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible2 == 0
elseif (IsHeroAlive ("hero3") == no
and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible3 == 0
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
Secondly, you are not comparing the same thing to different values, so use different if statements rather than if-ifelse. See if this works instead:varible1 == 0
varible2 == 0
varible3 == 0
if (IsHeroAlive ("hero1") == no and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible1 == 0; -- this will reset the varible so the above statement wont be true again thus the above message wont show again either
end;
if (IsHeroAlive ("hero2") == no and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible2 == 0;
end;
if (IsHeroAlive ("hero3") == no and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible3 == 0;
end;
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."
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Are you sure you put in the beginning part of the script too? I just redid the middle part with the conditionals. Since you say you're getting a lost function error, maybe it is missing the function declaration line?myythryyn wrote:darn, the new scipt doenst work, i get the "lost function" error three times.
the three different events do not happen after the death of the three heroes.
any other ideas?
function defeatattack (heroname)
local variable1;
local variable2;
local variable3;
if (IsHeroAlive ("hero1") == no and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible1 == 0; -- this will reset the varible so the above statement wont be true again thus the above message wont show again either
end;
if (IsHeroAlive ("hero2") == no and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible2 == 0;
end;
if (IsHeroAlive ("hero3") == no and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible3 == 0;
end;
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
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."
All the names of the variablen are misspelled in the if statements:
GOW and MY wrote: if (IsHeroAlive ("hero1") == no and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible1 == 0; -- this will reset the varible so the above statement wont be true again thus the above message wont show again either
end;
if (IsHeroAlive ("hero2") == no and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible2 == 0;
end;
if (IsHeroAlive ("hero3") == no and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
varible3 == 0;
end;
O.
yeah, it was just a rough draft of the script so there were errors
like "variable1 == 1", should be "variable1 = 1", the game complained otherwise.
but no luck so far. this is what i have
function defeatattack (heroname)
local variable1;
local variable2;
local variable3;
if (IsHeroAlive ("hero1") == no and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt);
variable1 = 0;
end;
if (IsHeroAlive ("hero2") == no and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable2 = 0;
end;
if (IsHeroAlive ("hero3") == no and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable3 = 0;
end;
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
but the three events still dont happen.
one thing i was wondering, when you have strings for values, do you need them to be in " "?
im using EnableAI("hero", false) but the game always complains about false not being a global value or somehthing like that. the function still seems to work anyways, but maybe it should be EnableAI("hero", "false")?
and maybe i should use this
if (IsHeroAlive ("hero3") == "no" and variable3 == 1)
thats all i can think of, otherwise i have no idea why its not working.
like "variable1 == 1", should be "variable1 = 1", the game complained otherwise.
but no luck so far. this is what i have
function defeatattack (heroname)
local variable1;
local variable2;
local variable3;
if (IsHeroAlive ("hero1") == no and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt);
variable1 = 0;
end;
if (IsHeroAlive ("hero2") == no and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable2 = 0;
end;
if (IsHeroAlive ("hero3") == no and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable3 = 0;
end;
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
but the three events still dont happen.
one thing i was wondering, when you have strings for values, do you need them to be in " "?
im using EnableAI("hero", false) but the game always complains about false not being a global value or somehthing like that. the function still seems to work anyways, but maybe it should be EnableAI("hero", "false")?
and maybe i should use this
if (IsHeroAlive ("hero3") == "no" and variable3 == 1)
thats all i can think of, otherwise i have no idea why its not working.
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Are you using the script name for the heroes? That is the only other thing I can think of.myythryyn wrote:yeah, it was just a rough draft of the script so there were errors
function defeatattack (heroname)
local variable1;
local variable2;
local variable3;
if (IsHeroAlive ("hero1") == no and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt);
variable1 = 0;
end;
if (IsHeroAlive ("hero2") == no and variable2 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable2 = 0;
end;
if (IsHeroAlive ("hero3") == no and variable3 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable3 = 0;
end;
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
I haven't used IsHeroAlive. Maybe we aren't using it properly.
PLAYER_REMOVE_HERO_TRIGGER triggers whenever a hero is dismissed or dies so try this instead of using IsHeroAlive:
--define these wherever you are defining your variables, like the first few lines of the script page.
variable1 = 1;
variable2 = 1;
variable3 = 1;
Edit:function defeatattack (heroname)
--"hero1"**script name**
if (heroname == "hero1" and variable1 == 1) then
MessageBox("Maps/SingleMissions/test/test.txt);
variable1 = 0;
end;
--"hero2"**script name**
if (heroname == "hero2" and variable2 ==1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable2 = 0;
end;
--"hero3"**script name**
if (heroname == "hero3" and variable3 ==1) then
MessageBox("Maps/SingleMissions/test/test.txt");
variable3 = 0;
end;
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7);
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7, "defeatattack" );
I think strings must be in quotes, but true and false are not strings. You will see that those show up in blue.one thing i was wondering, when you have strings for values, do you need them to be in " "?
im using EnableAI("hero", false) but the game always complains about false not being a global value or somehthing like that. the function still seems to work anyways, but maybe it should be EnableAI("hero", "false")?
and maybe i should use this
if (IsHeroAlive ("hero3") == "no" and variable3 == 1)
thats all i can think of, otherwise i have no idea why its not working.
Edit2: If that still doesn't work, break up the function into three different functions, each dealing with only one heroe.
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."
AFAIK it is "false" or "nil" not "no". Additionally, one could try:
The command should return you "true" or "false" and an additional "false == false" control might not be necessary. Although it most likely won't ruin the script either.
What more can be are , as GoW mantioned, using other names than the hard-coded hero names. And not talking about any personal experience, but is this line "Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7); " correct? No "nil" or function name after PLAYER_7 ?
Code: Select all
if IsHeroAlive ("hero1") and variable1 == 1 then
What more can be are , as GoW mantioned, using other names than the hard-coded hero names. And not talking about any personal experience, but is this line "Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7); " correct? No "nil" or function name after PLAYER_7 ?
In assignments (string= "somestring") and comparisons (string == "somestring") only string values can and must be enclosed in quotes. Numerical, and Boolean values are never in quotes. Comparisons always return a Boolean value. Boolean (true/false) are not written in quotes. You use true or false. Some languages allow for alternatives like: yes/no, 1/0, IsTrue(expression), IsFalse(expression). To be safe though, always stick with true or false.
You defined the variables variablen local. Therefore they will always evaluate to false. Erase all the local declarations and move them to the top of the entire script so they become global. Also if the variablen are only 1 or 0, change the assignment variablen = 1 to, variablen = true.
Consider the following:
is shorthand for
Make the following changes to your script:
This makes the function scalable so it doesent need to know how many heroes there are. You supply that information in the (global) variables array.
About the triggers. I think that to be sure you remove the trigger you must include a nil parameter where you normally would specify the function name. In addition I believe I read in the documentation that the Human player is always PLAYER_1. Thus:
Note: Setting the value to nil destroys the variable or parameter and frees the memory alloctaed to it. Local variables are (or should be) automatically destroyed at the end of their containing code block, and thus not available outside their scope.
It seems this topic is slowly becoming a tutorial in programming and that may be a bit out of scope for this forum, not to say out of topic. The nature of declarations, assignments, comparisons, scope and types are very basic concepts. If you do not have this knowledge you should consider learning a little elementary programming skills. I am sure you can find some free web based tutorials of you do a search.
That being said, I dont mind giving pointers. I am not really a professional though . Also, it is hard give accurate advice without knowing all of your script so there are no guarantees. My comments are based on some degree of guesswork.
You defined the variables variablen local. Therefore they will always evaluate to false. Erase all the local declarations and move them to the top of the entire script so they become global. Also if the variablen are only 1 or 0, change the assignment variablen = 1 to, variablen = true.
Consider the following:
Code: Select all
if <expression> then ...
if not <expression> then ...
Code: Select all
if <expression> == true then ...
if <expression> == false then ...
Code: Select all
-- on the top of script
variables; -- this makes variables global
heroes; -- this makes heroes global
heroes = {heroname1, heroname2, heroname3 ... }; -- You must use IngameName (scriptnames) here
...
-- somewhere else:
variables[1] = true;
variables[2] = true;
variables[3] = true;
...
-- Function defeatattack:
function defeatattack () -- The parameter heroname is never specified anyway.
local hero;
local i;
for i = 1, length(variables), 1 do -- Iterates through the variables array
hero = heroes[i];
if not IsHeroAlive(hero) and variables[i] then
MessageBox("Maps/SingleMissions/test/test.txt");
variables[i] = false;
end;
end;
end;
About the triggers. I think that to be sure you remove the trigger you must include a nil parameter where you normally would specify the function name. In addition I believe I read in the documentation that the Human player is always PLAYER_1. Thus:
Code: Select all
Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_1, nil); -- REMOVES trigger
Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_1, "defeatattack" ) -- SETS trigger
It seems this topic is slowly becoming a tutorial in programming and that may be a bit out of scope for this forum, not to say out of topic. The nature of declarations, assignments, comparisons, scope and types are very basic concepts. If you do not have this knowledge you should consider learning a little elementary programming skills. I am sure you can find some free web based tutorials of you do a search.
That being said, I dont mind giving pointers. I am not really a professional though . Also, it is hard give accurate advice without knowing all of your script so there are no guarantees. My comments are based on some degree of guesswork.
O.
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
"nil" would make the script function only once. All that is necessary is the player ID.Pitsu wrote:.
And not talking about any personal experience, but is this line "Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_7); " correct? No "nil" or function name after PLAYER_7 ?
Quoting the manual, and I have use a trigger like this in my map to determine when the main human heroe dies using nothing but the player ID as the parameter. The last script I posted *should* work, as it follows the same pattern I used to implement mine.
GOWfor PLAYER_ADD_HERO_TRIGGER and PLAYER_REMOVE_HERO_TRIGGER – the player’s ID
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."
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Nothing used in any part of the mapmaking process is beyond the bounds of discussion here. We can all use our expertise and trials and errors to figure out whatever needs to be figured out.Othmaar wrote: It seems this topic is slowly becoming a tutorial in programming and that may be a bit out of scope for this forum, not to say out of topic. The nature of declarations, assignments, comparisons, scope and types are very basic concepts. If you do not have this knowledge you should consider learning a little elementary programming skills. I am sure you can find some free web based tutorials of you do a search.
That being said, I dont mind giving pointers. I am not really a professional though . Also, it is hard give accurate advice without knowing all of your script so there are no guarantees. My comments are based on some degree of guesswork.
As you know, programing involves debuging too and it is often helpful to have another pair of eyes look at the problem because we as human beings tend to get in a certain mindset that can make it difficult to see what is under our very nose.
It is fortunate that we have an active and helpful mapmaking guild here. We are learning much more from each other than from the tutorials.
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."
Who is online
Users browsing this forum: No registered users and 1 guest