ScriptUO

Scripting Resources & Utilities => OEUO => OpenEUO Scripting Chat => Topic started by: BadManiac on October 16, 2010, 08:41:43 PM

Title: First steps. Message box and display item ID/Type
Post by: BadManiac on October 16, 2010, 08:41:43 PM
Here are my first few steps in LUA land. I've coded a lot of languages so the syntax is pretty easy, code will get prettier with time. Just need to get as fluent with the new UO.dll interace as I am with the old EUO client functions and variables...

Any comments?
Code: [Select]
function Display(type, msg)
  MsgBox = Obj.Create("TMessageBox")
  MsgBox.Title = 'Message'
  if type == "OK" then
    MsgBox.Button = 0
    MsgBox.Icon = 4
  else if type == "YESNO" then
    MsgBox.Button = 4
    MsgBox.Icon = 2
  end end
  MsgBox.Default = 0
  return MsgBox.Show(msg)
end

function FindItem(fid)
  cnt = UO.ScanItems(true)
  i = 0
  while i < cnt do
    id,type = UO.GetItem(i)
    if id == fid then break end
    i = i + 1
  end
  return type
end
    
--Main
repeat
  Display("OK", "Please target the item you wish to ID")
  UO.TargCurs = true
  while UO.TargCurs == true do wait(100) end
  findtype = FindItem(UO.LTargetID)
until Display("YESNO", "Item ID: " .. UO.LTargetID .. " | Item Type: " .. findtype .. "\n\nID Another Item?") == 7
Title: Re: First steps. Message box and display item ID/Type
Post by: Toptwo on October 17, 2010, 07:06:51 AM
Hey BM...I am beta testing this now and it seems to work great with one exception...you have to push play everytime you want to ID something. Is there any way to make this like TM's findinfo1.txt where the window will stay up and let you just keep clicking different things rather then having to close the mini window everytime you get 1 id, then having to hit play each time...if that makes sense..

but it is working like a million bucks...I am chugging along happily finding ID's :)  Thanks!!!!!
Title: Re: First steps. Message box and display item ID/Type
Post by: BadManiac on October 17, 2010, 09:23:38 AM
Yeah just slap a "while true" around the main body. I'll do that and change the message box to an ok/cancel so you can stop it.

Now how do you read the return from a message box?...
Title: Re: First steps. Message box and display item ID/Type
Post by: Endless Night on October 17, 2010, 02:42:02 PM
Code: [Select]
function msgbox()
    return 5 , 6 ,7
end

x,y,z = functions msgbox()
print(x..y..z)

above will print 567
Title: Re: First steps. Message box and display item ID/Type
Post by: BadManiac on October 17, 2010, 03:20:27 PM
Yeah but how do you read which button was pressed in the message box?
Title: Re: First steps. Message box and display item ID/Type
Post by: Endless Night on October 17, 2010, 03:28:52 PM
return MsgBox.Show(msg)

Add the return infrom of your show function this will return the value from msgbox to the calling function

result =Display(type, msg)
Title: Re: First steps. Message box and display item ID/Type
Post by: Adenocard on October 17, 2010, 07:20:09 PM
--Main
Display("OK", "Please target the item you with to ID")
UO.TargCurs = true
while UO.TargCurs == true do wait(100) end
findtype = FindItem(UO.LTargetID)



 Typo... " Please target the item you wish to ID" 


 Sorry I can't help myself sometimes.
Title: Re: First steps. Message box and display item ID/Type
Post by: BadManiac on October 18, 2010, 02:40:21 PM
Updated:
Fixed the typo and made it loop until you hit "No" on the ID message box.
Title: Re: First steps. Message box and display item ID/Type
Post by: NObama on October 18, 2010, 09:14:30 PM
This is the version of the same concept I posted on 14 Oct.  Fun little project to cut our teeth...I'll miss Guadah's Item Finder and I wanted a replacement for use and nostalgia.

http://www.scriptuo.com/index.php?topic=6298.0