Author Topic: First steps. Message box and display item ID/Type  (Read 5794 times)

0 Members and 1 Guest are viewing this topic.

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
First steps. Message box and display item ID/Type
« on: October 16, 2010, 08:41:43 PM »
0
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
« Last Edit: October 18, 2010, 02:42:36 PM by BadManiac »

Offline Toptwo

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #1 on: October 17, 2010, 07:06:51 AM »
0
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!!!!!
« Last Edit: October 17, 2010, 07:20:51 AM by Toptwo »
The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #2 on: October 17, 2010, 09:23:38 AM »
0
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?...

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #3 on: October 17, 2010, 02:42:02 PM »
0
Code: [Select]
function msgbox()
    return 5 , 6 ,7
end

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

above will print 567
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #4 on: October 17, 2010, 03:20:27 PM »
0
Yeah but how do you read which button was pressed in the message box?

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #5 on: October 17, 2010, 03:28:52 PM »
0
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)
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Adenocard

  • Full Member
  • ***
  • Posts: 143
  • Activity:
    0%
  • Reputation Power: 2
  • Adenocard has no influence.
  • Gender: Female
  • Respect: +18
  • Referrals: 4
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #6 on: October 17, 2010, 07:20:09 PM »
0
--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.

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #7 on: October 18, 2010, 02:40:21 PM »
0
Updated:
Fixed the typo and made it loop until you hit "No" on the ID message box.
« Last Edit: October 18, 2010, 02:53:36 PM by BadManiac »

Offline NObama

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: First steps. Message box and display item ID/Type
« Reply #8 on: October 18, 2010, 09:14:30 PM »
0
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

Tags: