Itemdesc Hook

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Unfaithful
Neophyte Poster
Posts: 38
Joined: Mon Jun 11, 2007 1:35 pm

Itemdesc Hook

Post by Unfaithful »

it is possible to change color of displayed text over item when i 1xClick Left mouse button ? ( without tooltip)
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

You can use singleclick packethook.

http://packets.polserver.com/index.php? ... acket=0x09.
Unfaithful
Neophyte Poster
Posts: 38
Joined: Mon Jun 11, 2007 1:35 pm

Post by Unfaithful »

but there is nothing about item color...could u show me some example of it?
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Yessir.

You are right, I explained poorly.

We are using method where we first hook the singleclick and collect some data from object the player clicked. After that we send player a PrintTextAbovePrivate() with modified content. More optimal way would be creating and sending text packet instead of making core do it, but that's not part of this tuto.

Example of uopacket.cfg and singleclick.src below.

:singleclick:uopacket (.cfg)

Code: Select all

Packet 0x09
{
  Length            5
  ReceiveFunction	singleclick:singleclickhook
}

:singleclick:singleclick (.src)

Code: Select all

use uo;

program singleclick ( )
   print("Hooking singleclickpacket");
   return 1;
endprogram

exported function singleclickhook( who, byref packet )
    // Packet contains only the serial
    var object := SystemFindObjectBySerial(packet.GetInt32(1));
    
    if (object.isa(POLCLASS_ITEM))
        // So player clicked an item. Change text color to item's color.
        // Of course color can be anything, this is just an example.

        var color := object.color;
        
        PrintTextAbovePrivate(object, object.desc, who, _DEFAULT_TEXT_FONT, color);

        // --> player clicks green axe, he/she will get 'an axe' with green color.
        
        // Return 1 so core won't react.
        return 1;
    endif

    // If it was not an item, core will do.
    return 0;

endfunction
Code is mostly pseudo, but should give you the idea.
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

This sound like a different way to handle tooltips.
See the megacliloc packethook. Since it's in html format, you can change the colour of the text.
Unfaithful
Neophyte Poster
Posts: 38
Joined: Mon Jun 11, 2007 1:35 pm

Post by Unfaithful »

thx this is exactly what i want
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

You can also change color displaying above things in the "send speech" packet. http://packets.polserver.com/index.php? ... acket=0x1C
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

POL is soooo versatile!!!
Post Reply