Script request for welcome packages

Hi again

2 problems-
line 133: there's a missing ; before the } at the end

it still doesn't run properly even with the above corrected
here's the error message
Fetching WelcomePackages.txt...
Unexpected error, debug log printed.
Sending welcome package to torellina
Level: 0 - Runs: 0 - Mainstat: none
it then sent an empty kmail to torellina who is incidentally at level 25 and has 24 ascensions.

I've attached the debug log in case it helps...

Thanks
 

Attachments

Last edited:
This should take care of a couple of problems that I didn't see when I copied from the test script to this one:

  • Apparently you found the missing ; (I forgot to check after adding the meat in the packages ^^).
  • Veracity provided a little bit of code to trim spaces around a player's name, mine didn't work as expected.
  • I wasn't putting everything in lowercase before comparing names inputted and names found on the clan roster.
  • A little logic error was fixed in my test script but stayed in the version I posted.
  • I completely failed at using Zarqon's vprint()... now that I finally understood how to use it, the script should stop when it encounters an error.

I also started playing with verbosity settings (different messages appear depending on your zlib verbosity setting). You can change the verbosity by doing zlib verbosity = 4 in the gCLI.

The default is 3. Set it at 4 if you want to see what the script is doing (while you are tying it out), 3 for normal output (once you are sure it doesn't do anything stupid), and 1 for quiet mode.

We're getting there!
 

Attachments

Newish version.
  • Data is checked when loaded, in some measure.
  • A package can now contain 0 items.
  • If a player in the list inputed doesn't receive a package, print a message, keep sending to other players, and print a summary.
 

Attachments

Last edited:
I finally got your data file. I forgot to mention that you couldn't have anything other than the data in those (no comments etc..).
 
Revision 8340 will no longer generate a stack trace when reading bad data via file_to_map. Instead, it will tell you why the data was bad and actually print the bad line from the file.

It also fixes a bug with reading nested records (which was not your issue).
 
Thanks Veracity, this should make things easier.

By nested records, did you mean records containing aggregates? If so, I was glad to see it worked, and now I'm wondering what the bug was.

EDIT:

"If there is insufficient data to fill a nested record, do not replace the nested record with a null. Leave it filled with defaults."

if I had a stat myRecord.mainstat for example, if nothing is specified in the data file, $stat[none] is stored there? What was the previous behavior?
 
Last edited:
This is a nested record:

Code:
record abc
{
    int a;
    record
    {
        int x;
        int y;
    }
};

You can read those into a map from a data file containing 4 fields: the map index, an integer for a, an integer for x, and an integer for y. If you give fewer fields, no problem: we fill them with defaults. The bug was if your file had two fields, we'd clobber the nested (unnamed) record.

That was not your problem. Your program was doing something I was surprised worked: you were filling in fields one at a time - by field name. The problem came when a bad field name was in the data file. Here is my test program and test data which I used to reproduce the error from the debug logs:

Code:
record package
{
  int [item] itemList;
  int meat;
};

package [ int ] map;

file_to_map( "test.txt", map );

foreach key, val in map
{
  print( "key = " + key );
  foreach it, num in val.itemlist
  {
    print( "    it = " + it + " num = " + num );
  }
  print( "    meat = " + val.meat );
}

and

Code:
3	itemlist	gimlet	3
3	itemlist	gnocchetti di Nietzsche	2
3	itemlist	newbiesport tent	1
3	meat	36
3	bogus	100
 
Ok, so the error didn't come from the comment part of the WelcomePackages.txt Bloviator was using. Maybe a tab turned into a space? All columns must be separated by tabs, or else they will be considered as a bogus entry like Veracity described.

EDIT:
Your program was doing something I was surprised worked: you were filling in fields one at a time - by field name.
I build the map of records, used map_to_file(), found out it worked, and got the structure the data file had to obey.
 
Last edited:
Newest NDY scripts. Removes the sturdy Crimbo crate as a gift (they're getting expensive). Addresses the L16 and higher with no ascensions bug. Adds a text copy of the welcome letter.
 

Attachments

Last edited:
Back
Top