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

ereinion

Member
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?
 

heeheehee

Developer
Staff member
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.
 

ckb

Minion
Staff member
something like this:

PHP:
	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
 

Theraze

Active member
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);
 
Top