(H5:HoF) MessageBox Complex Messages?

Maps and the art of mapmaking.
DaytonaDude
Leprechaun
Leprechaun
Posts: 9
Joined: 02 Jul 2007
Location: Florida, USA

(H5:HoF) MessageBox Complex Messages?

Unread postby DaytonaDude » 03 Jul 2007, 18:09

Docs say that:

Code: Select all

--Also supported complex messages, example: 

MessageBox( { "format.txt"; gold = 100, gems = 200, name = "somename.txt" }, "MyCallback" );

--This feature can be used by adding <value> variables to the messagebox main text file.
...but I've yet to get it to work. Anyone able to use the <value> thing succesfully?

My code:

Code: Select all

MessageBox({"Maps/SingleMissions/testMap/loseGold.txt";gold=30});
My text file: "You have lost <gold> gold!"

... straight from the doc example. :| All it does is show a message box with "You have lost__gold!" (without the __)

Anyone?

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

Unread postby rdeford » 03 Jul 2007, 18:57

It looks like the problem is in the format of your text file to me. Here is a working example of a text file from my own map:

Code: Select all

"I've got <value=numSlaves> fine mistresses for sale this week. But,you gotta buy 'em as a set, which is going to cost you <value=gold> gold. Do you want to buy them?"

Notice that the format is: <value=xxx>

where xxx is name of a variable that is to be passed from the calling function. (In other words, I think "You have lost <value=gold> gold!" should work for you, but I haven't actually run a test on my end.)

To complete the example, the calling function from my script is a HOF QuestionBox, but it works the same way as the simpler MessageBox. It looks like this:

Code: Select all

QuestionBox({path.."sellSlaves.txt"; numSlaves = slaverSlaves, gold = slaveCost}, "slaveBuyYes", "slaveBuyNo");
Notice the correspondence between the the variables being passed by the calling function (numSlaves and gold) and the variable names (numSlaves and gold) in the text file.

BTW, you should be able to use hard-coded numbers in the calling function like you are trying to do instead variable values like I did.

Side Note: in my QuestionBox code, I store the Resource path in a global variable (path) and use the Lua concatenation operator (..) to create the path for the "sellSlaves.txt" file.
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

DaytonaDude
Leprechaun
Leprechaun
Posts: 9
Joined: 02 Jul 2007
Location: Florida, USA

Unread postby DaytonaDude » 03 Jul 2007, 19:05

Beautiful, tyvm!

<value=variableName>, hehe. Guess I missed that in the docs?

Thanks Again :D

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

Unread postby rdeford » 03 Jul 2007, 19:46

Guess I missed that in the docs?
Nope! It is not in the docs per se because they were written for programmers not ordinary folks like you and me. The docs say: "This feature can be used by adding <value> variables to the questionbox main text file."

This terse explanation is clear to an experienced programmer, I guess, but it completely mislead me. I had to patiently play map after map until I found one that used this feature, then I looked at the script to see how it was done.
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
Drax
Leprechaun
Leprechaun
Posts: 10
Joined: 21 Jun 2006
Location: Texas
Contact:

Cant get messages with parameter to display.

Unread postby Drax » 13 Jul 2007, 01:19

Well I am an experienced programmer and its all confusing to me. I have the following in my "GotnMages.txt resource file

You have trained <value=level_mages> new mages.

And below is what is in the script, but I get no display at all, nothing! What am I missing here? Help.

MessageBox({path.."GotnMages.txt"; level_mages = 5});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Imagination is more important than intelligence.' - Albert Einstien

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

Unread postby rdeford » 13 Jul 2007, 02:42

The code looks okay to me off the top of my head. You're using HOF with the 2.1 patch, right? I seem to recall someone saying that the complex MessageBox didn't work before that. (I.e., just the simple MessageBox without variables worked.) Also, if you haven't already done so, enable the test console so you can see errors. If you are using HOF 2.1 and getting no display, then I'll bet you're getting an error of some kind. The scripting guide Pitsu wrote and put on this web site tells how to enable the console.

Also, check the value you are setting the path variable to. It must be the complete, path but without the filename. Here is what one of my initialization statements looks like:

Code: Select all

path = "Maps/SingleMissions/theApprentice/";
Also, if you saved your map under a different file name, then you may have forgotten to update the value you're setting path to.

When I get a chance tomorrow morning, I'll check your code in a test map on my end to see what I can do with it.
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
Drax
Leprechaun
Leprechaun
Posts: 10
Joined: 21 Jun 2006
Location: Texas
Contact:

Path is fine but Im on 1.05

Unread postby Drax » 13 Jul 2007, 09:04

The pathing is fine. It is working in dozens of other messages and QuestionBox commands, I just cant get results trying the parameter passing. From what you say it may not work because I am on the 1.05 release. I don't have the Hammers expansion yet.
How do you use the console, (In detail, please) I heard someone else mention watching errors but I have never done it.
Thanks for the response.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Imagination is more important than intelligence.' - Albert Einstien

Neckie
Peasant
Peasant
Posts: 67
Joined: 05 Oct 2006
Location: Quebec, Canada

Unread postby Neckie » 13 Jul 2007, 13:27

How do you use the console, (In detail, please) I heard someone else mention watching errors but I have never done it.
Thanks for the response.
Adding string
setvar dev_console_password = schwinge-des-todes
as the last line of autoexec.cfg file.
Under
My Documents/My Games/Heroes of Might and Magic V/Profiles
find input.cfg file and add
bind show_console ‘`’
right after the line saying
bind enter_pressed ‘NUM_ENTER’.
In case of having Hammers of Fate expansion you need to edit
input_a1.cfg. (A different key might be needed for non-english
keyboards).
In game you should now be able to enter the console by pressing `
(the key above TAB).
Console shows you many things about the game, including error
messages for faulty scripts.
This is from Pitsu HV scripting guide
The pathing is fine. It is working in dozens of other messages and QuestionBox commands, I just cant get results trying the parameter passing. From what you say it may not work because I am on the 1.05 release. I don't have the Hammers expansion yet.
See my post : http://deep.phpwebhosting.com/~paradox/ ... wtopic=708

The reason it doesn't work is because you don't have HoF.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 0 guests