Request: simple script example

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
CubeBox
New User
Posts: 6
Joined: Thu Jul 13, 2006 10:44 pm

Request: simple script example

Post 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.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post 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

Post Reply