Official ScriptUO EasyUO Scripts > Script development tools

TrailMyx's List Handling Subs

(1/24) > >>

TrailMyx:

--- Code: ---;=================================================================
; Script Name: TrailMyx's List Handling Subs
; Author: TrailMyx
; Version: 0.27
; Shard OSI / FS: OSI / FS OK
; Revision Date: 3/12/2008
; Purpose: Take the pain out of managing lists
;
; Subroutines included:
;   TM_CreateList - Creates the list
;   TM_DrawList
;   TM_HideList
;   TM_ReDrawList
;   TM_AddToList
;   TM_DeleteAllItemsInList
;   TM_CopyAllItemsInList
;   TM_DeleteIndexedItemInList
;   TM_DeleteExactItemsInList
;   TM_DeleteExactTagsInList
;   TM_DeleteItemsInList
;   TM_DeleteTagsInList
;   TM_SearchForExactItemInList
;   TM_SearchForExactTagInList
;   TM_SearchForItemInList
;   TM_SearchForTagInList
;   TM_CountExactItemsInList
;   TM_CountExactTagsInList
;   TM_CountItemsInList
;   TM_CountTagsInList
;   TM_AlphabetizeList
;   TM_GetSelectedItem
;   TM_GetSelectedTag
;   TM_GetIndexedItem
;   TM_GetIndexedTag
;   TM_GetListSize
;   TM_MoveSelectedItemDown
;   TM_MoveSelectedItemUp
;
; Requirements:
;
; Locals/Globals:
;   TM_window_list_ , %2 (local)
;
; Special Thanks:
;
;=================================================================
;

--- End code ---

Note: Version 31 saves information to the registry and not a flat file.  However it's much faster.

TrailMyx:
Was just playing with these subs a bit and decided to add something that Khameleon was talking about way back on uocoders.  He was thinking it would be nice to allow for the script to track not only the visible list item, but also an additional piece of data that won't be displayed.  So here's a sample of what I'm talking about:


--- Code: ---set %font_arial MS , #SPC , Ariel
gosub showEUOMenu1
gosub TM_CreateList List Newlist1 4 4 345 289 White WindowText %font_arial 8
set #LPC 100
repeat
  finditem * G_18
  if #FINDKIND <> -1
  {
    event property #FINDID
    str pos #PROPERTY $
    set #STRRES #STRRES - 1
    str left #PROPERTY #STRRES
    gosub TM_AddToList Newlist1 #STRRES #FINDID
    ignoreitem #FINDID
  }
until #FALSE
stop
;--------- EasyUO Menu Designer Code Begin ---------
sub showEUOMenu1
menu Clear
menu Window Title Test
menu Window Color BtnFace
menu Window Size 442 298
menu Show 421 270
return
;--------- EasyUO Menu Designer Code End ---------

--- End code ---

This code will save all incoming items it finds on the ground and places them into the list you can see.  It also makes a note of the #FINDID associated with the item.  You can go back later and do searches on either the "Items" information or the "Tag" information.  Where:

Item = displayable
Tag = non-displayable

So specifically, the syntax to add the item text and tag looks like:


--- Code: ---gosub TM_AddToList Newlist1 #STRRES #FINDID ; added the 3rd argument (the Tag)

--- End code ---

About NODRAW lists:

Normally these subs are meant to replace instances of menu list or menu combo, but there are times when you might want to use a list as a data structure to generally hold information.  For that you can:


--- Code: ---gosub TM_CreateList NODRAW Newlist2 110 10 100 100 White WindowText %font_arial 8

--- End code ---

This will create a list, but not associate it with anything on the screen.  Be sure to have a unique name, i.e. you cannot have a NODRAW list named NewList2 and a Combo List NewList2.
Be looking for version 2.1 of this set of subs.  I'm playing with them now and will post them soon.  Not that anyone uses them, but what the heck.

Khameleon:
I use em :P
I haven't really the time to sit down and write a full blown script in a while... to many annoying variables in the background atm.

Khameleon:
oh Man, I didn't see this update I was about to tear my hair out trying to handle to forms of lists. now this will definitely work.

TrailMyx:
Ya, that sample code makes it pretty clear what will be displayed and what will be tracked.

Navigation

[0] Message Index

[#] Next page

Go to full version