You must be logged in to post messages.
Please login or register

Modding and Scripting
Moderated by Yeebaagooon, TAG

Hop to:    
Welcome! You are not logged in. Please Login or Register.16 replies
Age of Mythology Heaven » Forums » Modding and Scripting » RMS Debugging
Bottom
Topic Subject:RMS Debugging
Mr_Sardonicus
Mortal
posted 12 January 2003 02:55 PM EDT (US)         
When I went through the Random Map Help file document, I thought I ran across a line I could add to my RM that would help me debug problems.

I've gone back through the document and cannot find it. Can someone tell me what it is and how to use it? I mean, do you have to code it so it looks for a specific variable?

Thanks,
-Mr.S

AuthorReplies:
The King of Cheese
Mortal
posted 12 January 2003 03:21 PM EDT (US)     1 / 16       
Make a new file in your Age of Mythology\startup folder called user.cfg. Then put in it the line:

"debugRandomMaps"

without quotes.


  • >> LKS_Cheeselord >>
  • Proud member of LKS. Click here to join.
  • Member of Arcane Studios, DGDN, and LKSware
  • PROJECTS: Magic Rugs - Cheese Giant - Anim Editor
  • Fear the power of CHEESE!
  • M0nTy PyTh0n
    Mortal
    posted 12 January 2003 03:34 PM EDT (US)     2 / 16       
    I guess this is the easiest way to enable the debugger:

    1. Create a shortcut for your 'aom.exe' on your desktop.
    2. Select the shortcut and right mouse click on it. Then select 'properties'. Change the first edit box, called 'source' into:

    "<your path>\Age of Mythology\aom.exe" +debugRandomMaps
    (don't forget the " quotes)

    3. Then start the game by clicking on the shortcut, and RMS debugging is enabled.

    When you load your RMS and it failed, you get some lines like:

    C:\(or whatever)Programs\Microsoft Games\Age of Mythology\RM\YourMapFile.xs(XXXX) : XS: Error YYYY: <error explanations>

    XXXX is the line where your RMS failed,
    YYYY is the internal error code (you don't need it),
    <error explanations> describes the error.

    This should help, good luck

    [This message has been edited by M0nTy PyTh0n (edited 01-12-2003 @ 04:04 PM).]

    Matei
    Mortal
    posted 12 January 2003 04:07 PM EDT (US)     3 / 16       
    When debugging, you can use Step Over and Step Into to jump over lines or go into the function being called on the line you're at and see how your code executes there. On the Call Stack you can see which functions called the one you're currently inside of, as well as the value of every variable.

    Once you enable debugRandomMaps, you can also open the scenario editor, click New, set the map type to your script, and check Start Under Debugger; this starts debugging at the very start of the Main function, not just when an error occurs.

    Also, when an error occurs, press Run several times to jump over it so the script finishes, otherwise you'll be left with a blank screen when you close the debugger.


    Programmer on 0 A.D., author of Norse Wars, co-author of Fort Wars.
    Mr_Sardonicus
    Mortal
    posted 12 January 2003 06:39 PM EDT (US)     4 / 16       
    Thanks for all the useful information. I'll give it a go, and see if I can get my map working.

    Thanks to everyone.
    -Mr.S

    Pascal9872
    Mortal
    posted 13 January 2003 11:06 AM EDT (US)     5 / 16       
    I just wish the debugger, would still run when you have syntax errors. That is my biggest problem is messing up the syntax. It would be nice if you could edit syntax errors on the fly while it is trying to parse the script.

    Guide to Debugging RMS
    Download my RMS here
    Help improve RMS reviewing here
    A monk I need a monk.
    I thought therefore I was.
    nidhogg13
    Banned
    posted 13 January 2003 06:28 PM EDT (US)     6 / 16       
    Im not sure what you mean, but if you minimize AoM, you can edit the files and then just reload it...
    Matei
    Mortal
    posted 13 January 2003 09:33 PM EDT (US)     7 / 16       
    You can keep AoM in window mode at 640x480 or 800x600 and switch between it and Notepad very quickly when editing.

    Programmer on 0 A.D., author of Norse Wars, co-author of Fort Wars.
    Mr_Sardonicus
    Mortal
    posted 14 January 2003 00:07 AM EDT (US)     8 / 16       
    Well, I thought I had a handle on this but am stuck.

    Are there any documents that give me a better idea about what error messages mean? Are there any xml programming books that I could review to help with my coding or is the random map coding so unique, no generic xml programming books would help?

    My code reads as follows:

    string GetLandType(int Environment=0)

    The debugger reports four errors in this line, the first of which being:

    Expected '=' and found '(' (you must initialize all variables to a literal or const value)

    I've tried all iterations of adding and '=' sign and rearranging the line that I can think of and still get anywhere from 4 to 7 errors.

    Thanks for anything you can offer.
    -Mr.S

    M0nTy PyTh0n
    Mortal
    posted 14 January 2003 01:00 AM EDT (US)     9 / 16       
    What is "GetLandType"? A function? And if yes, I would avoid functions with return value "string", better "void" or "bool" or "int".

    A tutorial for RMS (with terrain and unit type lists) you find here.
    A list for the TechID's you find here.
    If you need anything else, also have a look into the
    "aom random map help file.rtf" and "aom ai script help file.rtf", located in the '\\Age of Mythology\doc\' folder.


    M0nTy_PyTh0n
    RM Scripter - Utility Programmer - Music/Sound Composer/Creator
    HYENA STUDIOS
    Also on YouTube and MySpace
    Partner of Tsunami Studios - Sound and Music Composer
    All rights reserved.
    Mr_Sardonicus
    Mortal
    posted 14 January 2003 11:47 AM EDT (US)     10 / 16       
    Hi MOnTy

    GetLandType is a variable I'm trying to set to randomly specify an rmTerrainInitialize. I originally asked this on the Scenario Design forum. I should have submitted my entire chunk of code instead of one line out of context.

    I'm trying to randomly set the season in which my RM takes place. The suggestion on the other forum was to enter my function like this.


    string GetLandType(int Environment=0) {
    int env=Environment;
    if (env=0) env = rmRandInt(1,5) // RANDOM TYPE
    if (env==1) return("SnowA"); // WINTER
    else if (env==2) return("SavannahA"); // SPRING
    else if (env==3) return("GrassA"); // SUMMER
    else if (env==4) return("SnowGrass25"); // FALL
    else if (env==5) return("DirtA"); // HELL
    }

    void main() {
    int Environment = rmRandInt(1,5); // RANDOMLY SELECT AN ENVIRONMENT
    rmTerrainInitialize(GetLandType(Environment));
    }


    I'll start looking through the tutorial for RMS that you suggest and the ai script document.

    Thanks,
    -Mr.S

    Pascal9872
    Mortal
    posted 14 January 2003 12:59 PM EDT (US)     11 / 16       
    I believe you need something like this

    string avar = GetLandType.....

    GetLandType I am assuming is a function, so something needs to be set equal to it when you see string.

    My point was that the blasted compiler will not load if there is a syntax error. It just says map failed to load or something like that. If there is a syntax error ( 99% of my mistakes and probably the same for most people) it will fail to parse the script and you never even get into the debugger.

    So you need to then load another map under the compiler and look through to see what stopped your script from being parsed.

    What I meant was the debugger should open whether the script has syntax errors or not, so you can see what the syntax errors are and fix them.


    Guide to Debugging RMS
    Download my RMS here
    Help improve RMS reviewing here
    A monk I need a monk.
    I thought therefore I was.
    M0nTy PyTh0n
    Mortal
    posted 14 January 2003 01:13 PM EDT (US)     12 / 16       
    1. GetLandType is a function(!) with return value 'string' and input variable 'int'.
    2. 'rmTerrainInitialize(GetLandType(Environment))' uses a function in a AOM/RMS build-in function ('rm...'), which is not good. I'm afraid you can only use constant variables in 'rm...' function.
    3. Even more, 'string functions' are bad, since the program does not know how much memory to allocate for 'string'. So, better use 'int' or 'void'.
    4. In your main function you choose 'Environment' random from 1-5. In your 'GetLandType' function you have a case for 'Environment=0' which will never occur. You also don't need to randomize twice!

    My advice:(corrected)

    /*01*/ void MakeTerrainType(int AreaID, int idx=0) {
    /*02*/ string str="GrassA";
    /*03*/ if (idx==1) str="SnowA"; // WINTER
    /*04*/ else if (idx==2) str="SavannahA"; // SPRING
    /*05*/ else if (idx==3) str="GrassA"; // SUMMER
    /*06*/ else if (idx==4) str="SnowGrass25"; // FALL
    /*07*/ else if (idx==5) str="DirtA"; // HELL
    /*08*/ rmSetAreaTerrainType(AreaID,str);
    /*09*/ }
    /*10*/
    /*11*/ void main() {
    /*12*/ int Environment = rmRandInt(1,5); // RANDOMLY SELECT AN ENVIRONMENT
    /*..*/ rmTerrainInitialize("land,4"); // or rmTerrainInitialize("water",0);
    /*..*/ //...
    /*..*/ //... Define your basic area MyMap (whole map)...
    /*..*/ MakeTerrainType(MyMap,Environment);
    /*..*/ ...
    /*..*/ }

    For Pascal9872:
    If your debugger does not open in that case, you have not activated it! You do NOT do this by just clicking on the debugger checkbox. It's explained above how to activate it.


    M0nTy_PyTh0n
    RM Scripter - Utility Programmer - Music/Sound Composer/Creator
    HYENA STUDIOS
    Also on YouTube and MySpace
    Partner of Tsunami Studios - Sound and Music Composer
    All rights reserved.

    [This message has been edited by M0nTy PyTh0n (edited 01-14-2003 @ 09:14 PM).]

    Mr_Sardonicus
    Mortal
    posted 14 January 2003 07:51 PM EDT (US)     13 / 16       
    Hi MOnTy,
    Well, the 'void' is tripping me up now.

    For testing, I placed your 14 lines of code into the Mediterranean.xs files at the line where it originally read:

    /*27*/ rmTerrainInitialize("GrassDirt25");

    I'm assuming that is where it would be placed, but have tried moving it to the top as well and still get errors.

    The debugger now reports "invalid symbol lookup for 'void'" on the new line 27.

    Ya know, I've done tons of HTML coding and a little XML for work, but I'm ready to throw in the towel with these RMs.

    Sorry to be a pest but I'm just not getting it.
    -Mr.S

    M0nTy PyTh0n
    Mortal
    posted 14 January 2003 08:46 PM EDT (US)     14 / 16       
    Ops, I just saw:

    "rmTerrainInitialize( string baseTerrain, float height): Initializes the terrain to the base type and height.
    Specifies the base terrain to use for a map. If set to water, sea type needs to be defined. Initial terrain is usually grass, sand, snow or water ..."

    ... from the AOM RMS readme!!!
    Use this function when you call "rmSetAreaTerrainType(...)" and replace "rmTerrainInitialize".

    I made some RMS startup templates. You find them here as Blank Maps.


    M0nTy_PyTh0n
    RM Scripter - Utility Programmer - Music/Sound Composer/Creator
    HYENA STUDIOS
    Also on YouTube and MySpace
    Partner of Tsunami Studios - Sound and Music Composer
    All rights reserved.

    [This message has been edited by M0nTy PyTh0n (edited 01-14-2003 @ 09:17 PM).]

    Matei
    Mortal
    posted 14 January 2003 09:37 PM EDT (US)     15 / 16       

    Quote:

    rmTerrainInitialize(GetLandType(Environment));


    You have to specify the height too, that's probably the problem.

    There's nothing at all wrong with string-returning functions or functions used as arguments to rm... functions. The system works very nicely . See my Norse Wars map for a *lot* of uses of functions as well as many advanced RMS features (the link to the download's in my signature, below).


    Programmer on 0 A.D., author of Norse Wars, co-author of Fort Wars.
    Pascal9872
    Mortal
    posted 15 January 2003 11:31 AM EDT (US)     16 / 16       

    Quote:

    For Pascal9872:
    If your debugger does not open in that case, you have not activated it! You do NOT do this by just clicking on the debugger checkbox. It's explained above how to activate it.

    So adding the line to user.cfg does not do this, I actually need to add it to the command line. Is that what you are saying? I will try that, thanks.


    Guide to Debugging RMS
    Download my RMS here
    Help improve RMS reviewing here
    A monk I need a monk.
    I thought therefore I was.
    You must be logged in to post messages.
    Please login or register

    Hop to:    

    Age of Mythology Heaven | HeavenGames