Results 1 to 5 of 5

Thread: How do I access the record from the 5-parameter version of maximize()?

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    593

    Default How do I access the record from the 5-parameter version of maximize()?

    According to the wiki, I can get a record of the maximizer results by using the five parameter version of the function. Trying "ash maximize("fites, -tie, switch tot, switch disembodied", 0, 1, true, true)" in the cli supports this, printing the contents of the record returned.

    However if I want to only print parts of the results, I am a bit unsure about what I'd do. I tried doing stuff like "record r = maximize(...)" for then being able to loop over the contents, but that seems to be an invalid syntax. Can someone please give me a pointer on what I'd need to do in order to store the record in a variable which I can then manipulate? Or am I going about this in entirely the wrong way?

  2. #2
    Developer
    Join Date
    Aug 2009
    Posts
    2,960

    Default

    item_drops_array was the first built-in function (or one of the first) to return an array. There's a code sample on that wiki page that you should hopefully be able to repurpose.

    edit: namely, you should be able to directly iterate over the result, without storing it to an intermediate value.

  3. #3
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    906

    Default

    something like this:

    PHP Code:
        foreach ii,rr in maximize("muscle",999,2,true,false) {
            
    musnum my_buffedstat($stat[Muscle]);
            if (
    musnum 487+monster_level_adjustment()) {
                print(
    rr.command,"blue");
                if ( !
    contains_text(rr.command,"eat") && !contains_text(rr.command,"drink") && !contains_text(rr.command,"chew") && !contains_text(rr.command,"summon") && !contains_text(rr.command,"concert") ) {
                    if (
    user_confirm(rr.display,5000,true)) { cli_execute(rr.command); }
                }
            }
        } 
    I use this in a script to maximize muscle using potions available

  4. #4
    Senior Member
    Join Date
    Dec 2008
    Posts
    593

    Default

    Oh, that's some really handy info! Thanks a ton for pointing me in the right direction :-)

  5. #5
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,749

    Default

    This is from months ago, but here's how I used it in TheSea for increasing noncombats.
    Code:
    				foreach it,entry in maximize("-combat, -tie", 0, 0, true, false) if (entry.score > 0 && entry.skill != $skill[none] && turns_per_cast(entry.skill) > 0) use_skill(max(1, ceil(my_adventures().to_float() / turns_per_cast(entry.skill))), entry.skill);
    				foreach it,entry in maximize("-combat, -tie", 0, 0, true, false) if (entry.score > 0 && entry.command.index_of("uneffect ") == 0 && turns_per_cast(entry.effect.to_skill()) > 0) cli_execute(entry.command);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •