[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.
User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 25 Feb 2008, 13:18

ransomdl wrote:I am attempting to write a script into the Player Castle script tab to provide resources on a given day of the week to Player_1 and the script written reads as follows:

function Time_event()
if(GetDate(DAY_OF_WEEK)==5)then;
GivePlayerResource(PLAYER_1,GOLD,1000);
GivePlayerResource(PLAYER_1,SULFER,10);
end;

When playing the game, the script does not provide the resource to Player_1. Any suggestions of what I am doing wrong.

randsomdl
@ransomd

First, this code belongs in the Map Properties Script tab/(Edit Script), not in the castle's script tab.

Second, you absolutely must enable the console and look at the console screen when you open your map in the game. If follow this suggestion, you will see that your code generates an error. (I made a test map where your code is the only code in the script.)

This error is why your function does not grant the resources. Basically, the game is not even executing your script so the function does not get called. I will admit that the error codes can sometimes be cryptic, but they usually give you a clue as to the nature of the problem.

Third, you absolutely must figure out what is wrong with your code, fix it and compile it over and over again until it the game will compile it without error. If you follow this suggestion, you will find that your code has several problems:
  • 1) The parenthesis ==5) is misplaced.
    2) Your if statement has a colon after the then.
    3) Your if statement lacks an end; statement.
    4) The GivePlayerResource() function does not exist.
When all fixed, it should look something like this:

Code: Select all

	function Time_event()
	if GetDate(DAY_OF_WEEK) == 5 then
		SetPlayerResource(PLAYER_1,GOLD,1000);
		SetPlayerResource(PLAYER_1,SULFER,10);
	end;
end;
However, even though it compiles without error, it still will not give the player the resources as you desire because it lacks a triggering function. One way to provide a trigger is this:

Code: Select all

function Time_event()
	if GetDate(DAY_OF_WEEK) == 5 then
		SetPlayerResource(PLAYER_1,GOLD,1000);
		SetPlayerResource(PLAYER_1,SULFER,10);
	end;
end;
	Trigger(NEW_DAY_TRIGGER, "Time_event");
This code works fine, but it does what you tell it to do, not what you want it to do. The problem is that it sets the players gold to 1000, instead of adding 1000 to the player's current amount. So, you will have to set the player's gold stock to the current amount plus 1000. Here is a simplified version of a function from my current map in progress that does something similar to what you're trying to do:

Code: Select all

function withdrawYes()
	local pGold = GetPlayerResource(PLAYER_1, GOLD);

	if bankAccount >= 1000 then
		pGold = pGold + 1000
		bankAccount = bankAccount - 1000
		SetPlayerResource(PLAYER_1, GOLD, pGold);
		Play2DSound( "/Sounds/_(Sound)/Interface/Ingame/Buy.xdb#xpointer(/Sound)");	
	  else
		MessageBox(path.."notEnoughActtGold.txt", "");	
	end;
end;
I hope this long winded explanation helps.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 25 Feb 2008, 16:13

rdeford,

Thank you for your quick response. I will retry the script as you have suggested. I am new to the Script writing and the manual and other guides provide some information, but it is not sufficient to learn much about writing scripts.

Why does the town/castle have a tab for Script, if the script needs to be placed in the map properties Script?

Thank you again for your help.

ransomdl
ransomdl
Warlock

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 25 Feb 2008, 23:48

ransomdl wrote:rdeford,

Thank you for your quick response. I will retry the script as you have suggested. I am new to the Script writing and the manual and other guides provide some information, but it is not sufficient to learn much about writing scripts.

Why does the town/castle have a tab for Script, if the script needs to be placed in the map properties Script?

Thank you again for your help.

ransomdl
@ ransomdl

You cannot learn scripting from the official documentation. Download The Basics of Heroes V Scripting by Pitsu from here:
https://www.celestialheavens.com/567

I used this guide to get started in scripting and I am extremely grateful for its existence. It has a few errors, and it has not yet been revised for TOTE, but, even so, 98% of it is pure gold.

As for the castle tab for Script, I am not sure what it is used for, or if it even has a use. I'm saying that it's the case here, but I've found that there are unused parameters in some of the objects in H5. I have yet to put any scripting code anywhere but in the main map properties script.

I think it would be a big help for you if you downloaded a map that has some simple scripting in it to see how things are done. For example, my map The Virgin of Ponce, Episode 1, Avenge Lady Linda, was my first map and the script is pretty simple and easy to follow.

BTW, you can use any part of any of my scripts in your own map.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 26 Feb 2008, 01:24

rdeford,

Thank you for the information regarding "The Basics of Heroes V Scripting" by Pitsu. I will download this file and see what I can learn.

I have extracted a number of the scripts from maps in both Hof and Tote and have found them very complex and a bit overwhelming. I would like to download the map you have completed, The Virgin of Ponce, but where would I go to get this map?

Additionally, you mentioned in your first response about enabling the "console", and I haven't a clue what the "console" is or how to enable the console. Are there any specific directions how to enable the "console" and where I can get the specifics of the proceedure?

I appreciate your help.

ransomdl
ransomdl
Warlock

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 26 Feb 2008, 03:15

ransomdl wrote:rdeford,

Thank you for the information regarding "The Basics of Heroes V Scripting" by Pitsu. I will download this file and see what I can learn.

I have extracted a number of the scripts from maps in both Hof and Tote and have found them very complex and a bit overwhelming. I would like to download the map you have completed, The Virgin of Ponce, but where would I go to get this map?

Additionally, you mentioned in your first response about enabling the "console", and I haven't a clue what the "console" is or how to enable the console. Are there any specific directions how to enable the "console" and where I can get the specifics of the proceedure?

I appreciate your help.

ransomdl
@ransomdl
You can download any of my maps from this web site, Celestial Heavens. From the home page, simply click on the Maps link (left side under Downloads), then do a Search with redeford as the author.

The Scripting guide by Pitsu tells you how to enable the console. Just adapt it a little if you're using the ToTE editor so you modify the correct profile. Unfortunately, the editor cannot check your scripting code. Do not even try to use its checking capability; all but a few of the errors it reports are false alarms. So, you have to open your map with the game itself and let the game compile your script. The game's compiler will print all its errors on the console screen. Also, the print() script function will print on the console screen, which means you can embed print() statements in your script to help you debug it. Oh, and you can enter cheat codes with the console to let you cheat while playing the game.
Last edited by rdeford on 26 Feb 2008, 18:48, edited 1 time in total.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 26 Feb 2008, 16:23

rdeford,

Thank you. I have downloaded the map from the referenced site, but have not looked at the script yet.

I made the changes in the Tote game version in the "autoexec_a2.cfg" file in the Profiles folder and the "input_a2.cfg" file in the Profiles Folder/default_profile folder as defined in the process for enabling the console from pitsu in the scripting guide.

After opening the game and allowing for the start-up of the script, I pressed the key `/~ (above the Tab key) and nothing happens. The console display does not come up.

What did I miss or not do? Did I make the changes in the correct folder and the correct files or are there other files I need to make changes?

ransomdl
ransomdl
Warlock

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 26 Feb 2008, 18:38

ransomdl wrote:rdeford,

Thank you. I have downloaded the map from the referenced site, but have not looked at the script yet.

I made the changes in the Tote game version in the "autoexec_a2.cfg" file in the Profiles folder and the "input_a2.cfg" file in the Profiles Folder/default_profile folder as defined in the process for enabling the console from pitsu in the scripting guide.

After opening the game and allowing for the start-up of the script, I pressed the key `/~ (above the Tab key) and nothing happens. The console display does not come up.

What did I miss or not do? Did I make the changes in the correct folder and the correct files or are there other files I need to make changes?

ransomdl
@ ransomdl
I assume you checked your spelling and capitalization, and went over the steps to ensure you followed them correctly.

So, about the only thing left is to make sure that you use the correct profile when you start the game and load your map. In other words, the console will only appear for the specific profile you modified the config file for. For example, I created a new profile named "Tester" and modified its profile per the instructions in the Guide. Then, when I am testing a map (as opposed to playing a map) I enter the game using the Tester profile. That way, my saved games for my test map do not mess up my saved games for whatever map I am playing for fun under one of my game-playing profiles. Anyway, I'll bet you are not using the same profile as the one you modified the config file for.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 26 Feb 2008, 19:56

rdeford,

Thanks, I double checked the spelling, spacing and marks that I entered to make sure they followed pitsu instructions for enabling the console, but it did not work.

I did not add the command line;(bind show_console'`') originally into the "user_a2.cfg" file, only to the "input_a2.cfg" file. Could this have been the reason that the console would not open?

Therefore, do you mean that I should create a seperate duplicate "user file" in the "default_profile folder" referenced as "tester" with the same change to add the following command:
bind show_console'`' to a "tester_a2.cfg" file (which is a duplicate of the "user_a2cfg" file in this same folder).

Then, as I understand, when playing the game enter "tester" into the play as name space to ativate the console.

pitsu did not mention changing any other files except the "input_a2.cfg" file and the "autoexec_a2.cfg" file in the instructions to enable the console.

I am not exactly sure if I have understood this process yet. Please let me know if I have properlay comprehended your input

ransomdl
ransomdl
Warlock

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 26 Feb 2008, 23:36

ransomdl wrote:rdeford,
I did not add the command line;(bind show_console'`') originally into the "user_a2.cfg" file, only to the "input_a2.cfg" file. Could this have been the reason that the console would not open?
No. You did it right. You don't modify the user_a2.cfg file.

ransomdl wrote:Therefore, do you mean that I should create a seperate duplicate "user file" in the "default_profile folder" referenced as "tester" with the same change to add the following command:
bind show_console'`' to a "tester_a2.cfg" file (which is a duplicate of the "user_a2cfg" file in this same folder).
No. I mean you should launch the game and click Single User.

The next screen has a window over on the left that shows you the name of your current profile with a big CHANGE button next to it. Click the CHANGE button.

You'll get a Change Profile screen. Enter a name (e.g., Tester) into the field and click the CREATE button. Go ahead and select this new profile, and exit the game.

Now, go into your ... My Documents\My Games\Heroes of Might and Magic V - Tribes of the East\Profiles directory and you will see a new folder with the name Tester. Open it and you will find a input_a2.cfg file. That's the config file for the Tester profile. That's the profile you need to add the bind show_console'`' to.

Now, go back and launch the game. Select Single Player again, and make sure that Tester is the selected profile. Open your map and the console should work when you press the '-key (the one above TAB).
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 27 Feb 2008, 03:51

rdeford,

I made the changes you suggested and set up a user "tester", then went to the My Games folder and added the command: bindshow_console'`' after the command: bind enter_pressed 'NUM_ENTER' into the "input.cfg" file. When I opened the game using the "tester" user name and waited for the map to open up, I then pressed the '-key, but the console did not appear.

Then, I rechecked the "autoexec.cfg" file in the Profiles folder to make sure if the following string that I added to the "autoexec.cfg" file was entered according to pitsu instructions. The string entered is:

setvar dev_console_password = schwinge-des-todes

and it was placed as the last line in the "autoexec.cfg" file. My question is
should this string be entered as the very last entry after the following string that reads:

exec profiles\start.cfg

or should it be after the last entry string before the last section which is entitled "Startup".

I have tried it both ways and have not had any success opening the console. Any thoughts?

ransomdl
ransomdl
Warlock

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 27 Feb 2008, 15:06

ransomdl wrote:rdeford,

I made the changes you suggested and set up a user "tester", then went to the My Games folder and added the command: bindshow_console'`' after the command: bind enter_pressed 'NUM_ENTER' into the "input.cfg" file. When I opened the game using the "tester" user name and waited for the map to open up, I then pressed the '-key, but the console did not appear.

Then, I rechecked the "autoexec.cfg" file in the Profiles folder to make sure if the following string that I added to the "autoexec.cfg" file was entered according to pitsu instructions. The string entered is:

setvar dev_console_password = schwinge-des-todes

and it was placed as the last line in the "autoexec.cfg" file. My question is
should this string be entered as the very last entry after the following string that reads:

exec profiles\start.cfg

or should it be after the last entry string before the last section which is entitled "Startup".

I have tried it both ways and have not had any success opening the console. Any thoughts?

ransomdl
@ransomdl

Gee what drag, having all this trouble. I am sorry.

I think you are modifying the wrong autoexec file. Assuming you are using ToTE, the name of the file should be autoexec_a2.cfg. It is found on my machine under this path:

C:\Program Files\Ubisoft\Heroes of Might and Magic V - Tribes of the East\Profiles\C:\Program Files\autoexec_a2.cfg.

For your reference, the last few lines in my autoexec_a2.cfg file look like this:

Code: Select all

//============================================================================
// Startup
exec profiles\map-aliases.cfg
exec profiles\start.cfg
setvar dev_console_password = schwinge-des-todes 
Other than this idea, I can't see anything else wrong with what you've done. Have hope; we are getting close. I can feel it in my bones.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 27 Feb 2008, 17:14

rdeford,

I agree, this is becoming a real drag and I am sorry for pestering you with this problem.

I have double checked again and found the following:

Path: C:\Program Files\Ubisoft\Heroes of Might and Magic V - Tribes of the East\Profiles\autoexec_a2.cfg

The last of the code strings reads as follows:

//===========================================================================
// Startup
exec profiles\map-aliases.cfg
exec profiles\start.cfg
setvar dev_console_password = schwinge-des-todes

The other file modified follows the following path:
C:\Users\randsomdl\Documents\My Games\Heroes of Might and Magic V - Tribes of the East\Profiles\tester\input_a2.cfg

The code strings reads as follows:

// general
bind jd_button_0 'ESC'
bind jd_button_0 'ENTER'
bind jd_button_0 'NUM_ENTER'
bind jd_button_0 'E'
bind esc_pressed 'ESC'
bind enter_pressed 'ENTER'
bind enter_pressed 'NUM_ENTER'
bind show_console'`'

Although I think everything is correct, when I open the game, select Single Player, select tester (for user), select the game to play, select "Create", then the game starts to load, then press any button command, game starts and then I press the `-key above the Tab key and then nothing happens. The console does not open even if I press the `-key repeatedly or hold it down for a few seconds, nothing happens.

So now I am totally frustrated. Thanks for your help.

randsomdl
ransomdl
Warlock

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 27 Feb 2008, 19:16

ransomdl wrote:rdeford,

I agree, this is becoming a real drag and I am sorry for pestering you with this problem.

So now I am totally frustrated. Thanks for your help.

randsomdl
@randsomdl -- Ah ha! I have it!

In the input_a2.cfg file you typed:

Code: Select all

bind show_console'`' 
But you are missing a space! I haven't actually tried it without the space on my machine, but I'm pretty darn sure it must be typed like this:

Code: Select all

bind show_console '`' 
Try it and keep me posted. Don't worry about pestering me. It is one of my passions to have more people doing scripted H5 maps. My reward will be seeing you post a new map to the CH archives.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 27 Feb 2008, 21:00

rdeford,

Hooray! It worked. Unbelievable how such a small thing like a space can make all the difference in the world for a programming operation.

Thank you for staying patient with me. Hopefully, I will learn in my old age how to write some script that is useful. I have made maps and campaigns before with Heroes IV, where in many ways, the commands were easier with that editor to utilize the available set of commands and without having to write programming script. But, I will learn this scripting also in time and with patience.

Best wishes,

ransomdl
ransomdl
Warlock

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Re: trigger

Unread postby ransomdl » 05 Mar 2008, 17:00

[quote="Pitsu"]

[color=blue]Indeed you cannot have more than one trigger associated to an event. Whenever a new day starts or a hero is removed, an specified object is touched or any other event occurs two scripts may not run simultaneously. [/color]

Pitsu,

Downloaded your map "Ruinsindesert" and I have played, but can't finish.

I have defeated all armies except Player_3 hero "Maahir", whom I cannot find. Also, for some reason, when I enter the Player_3 part of the map, I get the text message regarding choosing between life and death, but nothing triggers the choice. Therfore, the Phoenix and/or Death Knights do not become available and remain blocked. Looking at your script in map editor it indicates that "Maahir" is to be sent to xy coordinates (93, 8, 0), but this does not happen.

Do you have any thoughts or suggestions on this problem. What am I not doing correctly?

ransomdl
ransomdl
Warlock

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1848
Joined: 22 Nov 2005

Re: trigger

Unread postby Pitsu » 05 Mar 2008, 17:23

ransomdl wrote:
Do you have any thoughts or suggestions on this problem. What am I not doing correctly?

ransomdl
Hi,

First, you are probably quite lucky to get that far. The map was made during one of the early patches and later patches and expansion packs have changed this a bit. Under HoF the map is nearly unplayable.

Actually, if i remember myself correctly the phoenixes and knights will be blocked, but you can teleport (instant travel) next to them. Once you do so, you have made your choice and the other stack disappears. Does it work for you not? Have you already defeated the blue player (your southern neighbour)?
Avatar image credit: N Lüdimois

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Re: trigger

Unread postby ransomdl » 05 Mar 2008, 21:35

[quote="Pitsu"][quote="ransomdl"]

[color=blue]Actually, if i remember myself correctly the phoenixes and knights will be blocked, but you can teleport (instant travel) next to them. Once you do so, you have made your choice and the other stack disappears. Does it work for you not? Have you already defeated the blue player (your southern neighbour)?[/quote][/color]
Pitsu,

Thanks for the reply. I am actually playing the game in TotE and have really enjoyed your great work. You have developed a great story line and made a very challenging map.

I think you are probably right about the teleport using "instant travel" and I will try that. According to your script, "Maahir" and the map editor, gets teleported from the underground area that is not accessable to the location xy(93, 8, 0) which is just east of the Player_3 castle at xy (116, 11, 0). But this doesn't happen. My concern is even though I take either the Death Knights or the Pheonix and go after Player_2 and defeat them, that I am then left with and outstanding Player_3 "Maahir" that I can't defeat to end the game.

Any further thoughts on this? I appreciate your help.

ransomdl
ransomdl
Warlock

BBird28
Lurker
Lurker
Posts: 2
Joined: 06 Mar 2008

Unread postby BBird28 » 06 Mar 2008, 15:22

I asked this quesion at AOH,but couldn't get a respose. Has anyone had success adding missions to a user campaign using the campaign editor in ToTE? When i try to add a mission(map) to a campaign, as in the instructions, i get only a blank pull down menu. I'm thinking the campaign part of the editor doesn't recognize the map files for some reason or they need to be in a different diectory. I've tried putting custom maps in every directory i think the editor would look for them in, but no luck so far. Any help on this would be appreciated, even if it's a definitive reply that the campaign edtor doesn't work. Thanks.

User avatar
PhoenixReborn
Round Table Hero
Round Table Hero
Posts: 2014
Joined: 24 May 2006
Location: US

Unread postby PhoenixReborn » 06 Mar 2008, 15:26

I have no idea what I'm talking about but this might help. The file has to be .h5c

BBird28
Lurker
Lurker
Posts: 2
Joined: 06 Mar 2008

Unread postby BBird28 » 06 Mar 2008, 20:46

Thanks for the input, but it didnt work. I'm pretty sure the campain editor is supposed to create the .h5c file. I did figure out how to make a user campaign with new maps (or mix/match official) by cannibalizing the official campaigns. With H5/HoF/ToTE full installed you could string together 60 maps. It doesn't delete the official campaigns but temporarily overwrites them as a mod. If folks are interested I'll write a walkthrough for my workaround. I got the impression at AOH that no one cares.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 0 guests