ScriptUO

Scripting Resources & Utilities => OEUO => OpenEUO Scripting Chat => Topic started by: NObama on October 14, 2010, 09:38:57 PM

Title: Formatting Message Boxes
Post by: NObama on October 14, 2010, 09:38:57 PM
Following what I could understand of EN's tutorial, I've crafted the following beginnings of a replacement to Guadah's Item ID Finder:

Code: [Select]
--
--Functions
--
function ENs_GetItemTypeFromItemID(nItemID)
  local nThisType = nil
  local nCnt = UO.ScanItems(true) -- visible only
  local nIndex = 0
  while nIndex < nCnt and nThisType == nil do
    local nID,nType,nKind,nContID,nX,nY,nZ,nStack,nRep,nCol = UO.GetItem(nIndex)
    if nID == nItemID then nThisType = nType end
    nIndex = nIndex + 1
    end
  return nThisType
end

function DetermineItemID(sMessage) --stolen from EN, like most of my stuff
  UO.LTargetKind = 1 -- object
  UO.ExMsg(UO.CharID  , sMessage)  -- Message above character
  UO.TargCurs = true    -- make a target cursor
  while UO.TargCurs == true do  wait(10) end     -- wait until something is clicked (ie notarget cursor)
  UO.LObjectID = UO.LTargetID    -- set last object to the object clicked
  return  UO.LTargetID  -- set the return value .. the itemid clicked
end

function msgbox(default, prompt, title, button, icon)
  -- Function By Traegon's, Link: http://www.easyuo.com/forum/viewtopic.php?p=376784#376784
  if icon == nil then icon = 2 end
  if default == true then default = 1 else default = 0 end
 
  ConfirmDialog = Obj.Create("TMessageBox")
  ConfirmDialog.Title = title
  ConfirmDialog.Button = button
  ConfirmDialog.Icon = icon
  ConfirmDialog.Default = default
  return ConfirmDialog.Show(prompt)
end

function MessageBox(sPrompt, sTitle, sType)
  if sType == 'OK'    then  return msgbox(true, sPrompt, sTitle, 0,4) end
  if sType == 'YESNO' then  return msgbox(true, sPrompt, sTitle, 4,3) end
end

--
--Script begin
--
repeat
  local nMysteryItem = DetermineItemID('Target the item you wish to ID:')
  local nItemType = ENs_GetItemTypeFromItemID(UO.LTargetID)
  local nResult = MessageBox( 'Item Type is: ' .. nItemType .. '.  Identify another item?', 'NObama was here', 'YESNO')
until nResult == 7 --no

Run it.  See the message box?  How can I do the following:

1 - Add carriage returns to the output, so I can have multiple lines of information displayed in an easy-to-read format?
2 - How can I parse out actual names of items?

My thought is to display something along these lines:

Item Type Is:  XXXX
Item Name Is:  XXXX
.
.
.

What say you, smart people?
Title: Re: Formatting Message Boxes
Post by: Scrripty on October 14, 2010, 10:25:50 PM
That works good.  Something you might want to do, is add a way to select what client you want to run the script on.  Very easy, also, if you use TM's finditem, you can return either EUO or OEUO item types and ids I believe... I haven't used it but I think he has that ability in there... might be a nice feature to return both.
Title: Re: Formatting Message Boxes
Post by: TrailMyx on October 14, 2010, 10:54:45 PM
Here's the version with both OEUO and EUO numbers: Remember to save this to a file!!!

Code: [Select]
dofile("tm_subs_collection8.lua")
---------------------------------------------------------------
function CheckHotKey()
  if getkey("f1") and getkey('alt') then
    return true
  end
  return false
end
---------------------------------------------------------------
targetkey = false
repeat
  if CheckHotKey() then
    UO.TargCurs = true
    UO.LTargetKind = 1
    while UO.TargCurs == true do end
    print(UO.LTargetID)
    count, temp = TM_FindItemsByID(UO.LTargetID)
    if count > 0 then
      print("--------------------------------")
      print(string.format("FINDID = %d, in EUO = %s", temp[1].findid, TM_IDtoEUO(temp[1].findid)))
      print(string.format("findtype = %d in EUO = %s", temp[1].findtype, TM_IDtoEUO(temp[1].findtype)))
      print(string.format("findkind = %d", temp[1].findkind))
      print(string.format("contid = %d", temp[1].findid))
      print(string.format("findx = %d", temp[1].findx))
      print(string.format("findy = %d", temp[1].findy))
      print(string.format("findz = %d", temp[1].findz))
      print(string.format("findstack = %d", temp[1].findstack))
      print(string.format("findrep = %d", temp[1].findrep))
      print(string.format("findcol = %d", temp[1].findcol))
      print(string.format("name = %s", temp[1].name))
      print(string.format("property = %s", temp[1].property))
    end
  end
until false  
Title: Re: Formatting Message Boxes
Post by: Endless Night on October 15, 2010, 07:42:12 AM
Nice Script Nobamma

Carridge return is character 13.  as in:  string.char(13)

so try this no idea what will happen

Quote
local nResult = MessageBox( 'Item Type is: ' .. nItemType .. '.'..string.char(13)..' Identify another item?', 'NObama was here', 'YESNO')
Title: Re: Formatting Message Boxes
Post by: NObama on October 16, 2010, 06:46:53 AM
string.char(13) works.  Thanks EN.  Still working on the rest.
Title: Re: Formatting Message Boxes
Post by: Endless Night on October 16, 2010, 06:52:04 AM
string.char(13) works.  Thanks EN.  Still working on the rest.

your welcome.. your picking it up fast.
Title: Re: Formatting Message Boxes
Post by: NObama on October 16, 2010, 07:16:59 AM
Then TM comes along and posts the master sub for what I'm stumbling toward...

 :P
Title: Re: Formatting Message Boxes
Post by: Scrripty on October 16, 2010, 08:02:57 AM
I told you it's easy if you just play with it didn't I? :)
Title: Re: Formatting Message Boxes
Post by: NObama on October 18, 2010, 09:15:02 PM
I told you it's easy if you just play with it didn't I? :)


Dirty.