Page 1 of 1

Request: simple script example

Posted: Fri Aug 11, 2006 4:50 am
by CubeBox
Greetings!

Could it be possible to get a simple script example?
Im sure that many new scripters are in need of this.

How to do this?

By doubleclicking item A it asks for item B.
If item B is valid => Destroys item A and B => Creates item C in backpack.

Thanks in advance.

Posted: Fri Aug 11, 2006 6:40 am
by Austin
Item A needs a use script set in its itemdesc.cfg.

An example of that script..

Code: Select all

use uo;

CONST B_OBJTYPE := 0x1234;
CONST C_OBJTYPE := 0xABCD;

program UseScript(mobile, item_a)
     SendSysMessage(mobile, "Target item B");
     var item_b := Target(mobile);
     if ( item_b.objtype != B_OBJTYPE )
          SendSysMessage(mobile, "Cancelled.");
          return 0;
     endif

     var item_c := CreateItemInBackPack(mobile, C_OBJTYPE, 1);
     if ( item_c.errortext )
          SendSysMessage(mobile, "Unable to create item_c ->"+item_c.errortext);
          return 0;
     endif
     
     DestroyItem(item_a);
     DestroyItem(item_b);

     return 1;
endprogram