Working with Pol097 & Pol098 at least, probably if you change the += in the script it will work with 096 aswell. And remove the realm parameters I suppose it can work with Pol095 too.
Code: Select all
use uo;
use os;
use file;
program textcmd_createmultiuoa( who, filename )
if ( !filename )
SendSysMessage( who, "Usage: .createmultiuoa <nameofthefile>." );
return 0;
endif
filename := filename + ".uoa";
SendSysMessage( who, "Target the center point." );
var trg := TargetCoordinates( who );
if ( !trg )
SendSysMessage( who, "Cancelled." );
return 0;
endif
SendSysMessage( who, "Target the upper left corner." );
var up := TargetCoordinates( who );
if ( !up )
SendSysMessage( who, "Cancelled." );
return 0;
endif
SendSysMessage( who, "Target the lower right corner." );
var low := TargetCoordinates( who );
if ( !low )
SendSysMessage( who, "Cancelled." );
return 0;
endif
var area := ListObjectsInBox( up.x, up.y, -128, low.x, low.y, 127, trg.realm );
var items := array;
var num := 0;
foreach item in area
if ( item.IsA( POLCLASS_ITEM ) )
items.append( CInt( item.graphic ) + " " + CInt( item.x - trg.x ) + " " + CInt( item.y - trg.y ) + " " + CInt( item.z) + " 1" );
num += 1;
endif
Sleepms( 2 );
endforeach
items := { "6 version", "1 template id", "-1 item version", num + " num components" } + items;
var file := WriteFile( filename, items );
if (file)
SendSysMessage( who, "Done. " + num + " components added." );
else
SendSysMessage( who, "Error: " + file );
endif
endprogram