Author Topic: Help with script, am I heading int he right direction  (Read 9183 times)

0 Members and 1 Guest are viewing this topic.

Offline BlacklistedTopic starter

  • Jr. Member
  • **
  • Posts: 75
  • Activity:
    0%
  • Reputation Power: 2
  • Blacklisted has no influence.
  • Respect: +13
  • Referrals: 0
    • View Profile
Re: Help with script, am I heading int he right direction
« Reply #15 on: August 11, 2011, 03:07:57 PM »
0
I finished the script and its working like a charm.
I changed the menu layout and some of the if statments so I could dump just one type of item without the script asking me to set the other types of bags.

I,d like to add a move all button would I just be able to make a sub with the line
Code: [Select]
;======= Move miscellaneous  Sub =======
sub movemisc
repeat
finditem %gems %reagents %ingredients %misc  C_ , %lootbag
exevent drag #findid #findstack
wait 10
exevent dropc %miscbag
wait 10
until #findcnt < 1
Display All Done!
return
;======= End Sub =======


Here is a fully working version of the script.

;----------------------------------------------------
; First off, we should start the script by setting the
; variables we're going to use. As you know, standard
; variables always start with '%'. So let's set the ones
; we're going to use!
;----------------------------------------------------
set %gems HVF_UVF_FVF_EVF_OVF_VUF_GVF_RVF_BVF_VVF_NVF_ZVF_UWS_AXS_TWS_VWS_GXS_ZWS_FXS_WWS_
set %reagents KUF_JUF_KZF_JZF_MZF_WZF_RZF_SZF_DUF_TZF_UZF_YZF_IUF_NZF_JIY_OZF_GUF_
set %ingredients KZGB_EZGB_DZGB_TDHB_SDHB_TCHB_UDHB_HDHB_ICHB_MBHB_XYGB_VWS_YCHB_XCHB_RDHB_ZIY_AZGB_TKR_YWS_NDHB_ZYGB_JZGB_UKR_IDHB_JDHB_WCHB_WWS_XWS_WKR_YYGB_MD_UCHB_QDHB_
;Add youe own item types here on the next line
set %misc XVH_
;-------------------------------------------------------------
; I just copied the gems and reagents types from the code you
; posted on SUO. Saved me some time! :)
; Now, even though we're going to use the menu to define
; the bags' id's, we should start the script off by setting
; the vars we're going to use to N/A. This has two basic
; purposes:
; First one is so that the user sees the bags N/A in the menu,
; making it easier for him to realize he has to set the bags.
; You should always think on ways to make the script more
; intuitive for people who will be using it.
; Remember, not every person who is going to use your script
; is gonna be a rocket scientist! :))
; Second purpose is so that we can put a check to see if the bag
; has been set or not in the menu, before the script starts
; doing it's job of moving items.
; So let's get those N/A's going!
; (actually, if you don't specify the vars, they will be 'set'
; automatically to N/A, but I've wrote it like this
; to ilustrate better what I'm trying to show you! :)
;-------------------------------------------------------------
set %lootbag N/A
set %gemsbag N/A
set %regsbag N/A
set %ingredientsbag N/A
set %miscbag N/A

;--------------------------------------------------
; Next, the most basic yet very important thing you should
; know is how subs work. You always use 'gosub subname'
; to go to a sub, however, you should only get out
; of a sub using 'return'. This will take you
; back to where the sub was called in the
; first place (the gosub line).
;
; The example we're gonna see now shows this
; clearly. We're gonna generate the menu for the
; user. We'll use a sub for that!
; So first things first.
;-----------------------------------------------------
gosub menu ; This line here will take you to the sub called
; 'menu'. If you scroll down you can find this sub, and
; you'll notice the last line of it being 'return'.
; So that return will take us back exactly here, where
; we used the 'gosub' command.
;----------------------------------------------------
; Ok, so now our pretty little menu should be built, and the
; user should be seeing it right now! YAY! \0/
; Now, we have to make the script wait here until the
; user clicks something to do whatever the hell he wants
; to have the script do for him. We're going to write
; a little loop to do this. Read this loop carefully
; to see how it works.
;----------------------------------------------------

repeat
if #menubutton = setloot_button
   {
   gosub setloot
   set #menubutton N/A
   }
if #menubutton = setgems_button
   {
   gosub setgems
   set #menubutton N/A
   }
if #menubutton = setregs_button
   {
   gosub setregs
   set #menubutton N/A
   }
if #menubutton = setingredients_button
   {
   gosub setingredients
   set #menubutton N/A
   }
if #menubutton = setmisc_button
   {
   gosub setmisc
   set #menubutton N/A
   }
if #menubutton = moveregs_button
   {
   if %regsbag <> N/A && %lootbag <> N/A
      {
      gosub moveregs
      set #menubutton N/A
      }
   }
   
if #menubutton = movegems_button
   {
   if %gemsbag <> N/A && %lootbag <> N/A
      {
      gosub movegems
      set #menubutton N/A
      }
   }
if #menubutton = moveingredients_button
   {
   if %ingredientsbag <> N/A && %lootbag <> N/A
      {
      gosub moveingredients
      set #menubutton N/A
      }
   }
if #menubutton = movemisc_button
   {
   gosub movemisc
   set #menubutton N/A
   }
until
;--------------------------------------------------
; Ok, our main loop is done. When the user clicks
; a button, we can see that in the #menubutton
; var. Things you should notice here:
; 1) If a button is pressed, you will go to a sub
;    which will perform what the button suggests.
;    Also, you will set the #menubutton var back to
;    N/A so that you don't keep looping like crazy
;    the same sub over and over.
; 2) If the person tries to use the move subs
;    without having set the ID's of the bags first,
;    the script will warn them about it, and go back
;    to the loop to wait for the bag id's to be set.
;----------------------------------------------------
; I guess now that this is done, we can start building the
; rest of our subs! Let's start with the sub to set
; our loot bag!
;------------------------------------------------------

;======= Set Loot Bag Sub =======
sub setloot
event SysMessage Target your loot bag ; event SysMessage will display a msg inside you client for you
      set #targcurs 1 ;sets the little target cursor on
      while #targcurs = 1 ; while #targcurs = 1, so while the target cursor is on, it will wait
      wait
      set %lootbag #ltargetid ; once the bag is clicked, we will set it's id
      set #lobjectid #ltargetid ; here we will set the last object to the id of the last target, in this case, our loot bag
      event macro 17 ; event macro 17 is 'Use Last Object', so this will open our loot bag
      menu Edit EUOEdit1 84 44 57 %lootbag
      wait 20
return
;======= End Sub =======

;--------------------------------------------------------
; Noticed the line 'menu Edit EUOEdit1 84 44 57 %lootbag' there?
; This will update the Edit Box for the lootbag in the menu,
; which will now show the id of our dear lootbag!
; Great stuff! Now we're gonna do almost the same thing for
; our other two bags. The difference is, we're not gonna want to open them.
; Why, do you ask? Simply because it would make this more complicated.
; So it's best to leave bags we're going to put stuff IN closed, while
; the bags we're going to get stuff FROM should remain open.
; So, let's do this now!
;---------------------------------------------------------

;======= Set Gems Bag Sub =======
sub setgems
event SysMessage Target your gems bag
      set #targcurs 1
      while #targcurs = 1
      wait
      set %gemsbag #ltargetid
      set #lobjectid #ltargetid
      event macro 17
      menu Edit EUOEdit2 84 72 57 %gemsbag
return
;======= End Sub =======

;======= Set Regs Bag Sub =======
sub setregs
event SysMessage Target your regs bag
      set #targcurs 1
      while #targcurs = 1
      wait
      set %regsbag #ltargetid
      set #lobjectid #ltargetid
      event macro 17
      menu Edit EUOEdit3 84 104 57 %regsbag
return
;======= End Sub =======

;======= Set set ingredients Sub =======
sub setingredients
event SysMessage Target your ingredients bag
      set #targcurs 1
      while #targcurs = 1
      wait
      set %ingredientsbag #ltargetid
      set #lobjectid #ltargetid
      event macro 17
      menu Edit EUOEdit4 330 44 57 %ingredientsbag
return
;======= End Sub =======

;======= Set set ingredients Sub =======
sub setmisc
event SysMessage Target your miscellaneous  bag
      set #targcurs 1
      while #targcurs = 1
      wait
      set %miscbag #ltargetid
      set #lobjectid #ltargetid
      event macro 17
      menu Edit EUOEdit5 330 72 57 %miscbag
return
;======= End Sub =======

;--------------------------------------
; Piece of cake right? Now, we should write up
; the move subs. So lets get it done!
;----------------------------------------

;======= Move Regs Sub =======
sub moveregs
repeat ; it will repeat whatever is written here, until the condition on the 'until' line is met
finditem %reagents C_ , %lootbag ; this will look for the reagents inside you're lootbag
exevent drag #findid #findstack ; #findstack will hold the amount of reagents in each stack
wait 10
exevent dropc %regsbag ; this line will drop the regs inside your regs bag
wait 10
until #findcnt < 1 ; if you can't find any more items, it will stop repeating!
Display All Done!
return
;======= End Sub =======

;======= Move Gems Sub =======
sub movegems
repeat
finditem %gems C_ , %lootbag
exevent drag #findid #findstack
wait 10
exevent dropc %gemsbag
wait 10
until #findcnt < 1
Display All Done!
return
;======= End Sub =======

;======= Move ingredients Sub =======
sub moveingredients
repeat
finditem %ingredients C_ , %lootbag
exevent drag #findid #findstack
wait 10
exevent dropc %ingredientsbag
wait 10
until #findcnt < 1
Display All Done!
return
;======= End Sub =======

;======= Move miscellaneous  Sub =======
sub movemisc
repeat
finditem %misc C_ , %lootbag
exevent drag #findid #findstack
wait 10
exevent dropc %miscbag
wait 10
until #findcnt < 1
Display All Done!
return
;======= End Sub =======


;--------------------------------------
; Ok, we should be set now! If no mistake was
; made while writing, this little script
; should do what we expect from it!
; Let's hit play and find out! :))
;--------------------------------------
; Below you can check out the menu sub.
;--------------------------------------


;======= Menu Sub =======
sub menu
menu Clear
menu Window Title Blacklisted's MoveLoot
menu Window Color BtnFace
menu Window Size 442 250
menu Font Transparent #true
menu Font Align Right
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Style
menu Font Color WindowText
menu Font Transparent #false
menu Font Align left
menu Text EUOLabel1 12 44 Loot Bag ID:
menu Text EUOLabel2 12 72 Gems Bag ID:
menu Text EUOlabel3 210 44 Ingrediants Bag ID:
menu Text EUOlabel4 210 72 Miscellaneous Bag ID:
menu Text EUOLabel5 12 104 Regs Bag ID:
menu Text EUOLabel6 12 144 Move gems to bag:
menu Text EUOLabel7 12 172 Move regs to bag:
menu Text EUOLabel8 210 144 Move ingredients to bag:
menu Text EUOLabel9 210 172 Move Miscellaneous to bag:
menu Button setloot_button 148 44 43 25 Set
menu Font BGColor Window
menu Edit EUOEdit1 84 44 57 %lootbag
menu Font BGColor BtnFace
menu Button setgems_button 148 72 43 25 Set
menu Font BGColor Window
menu Edit EUOEdit2 84 72 57 %gemsbag
menu Font BGColor BtnFace
menu Button setregs_button 148 100 43 25 Set
menu Font BGColor Window
menu Edit EUOEdit3 84 104 57 %regsbag
menu Font BGColor BtnFace
menu Button setingredients_button 390 44 43 25 Set
menu Font BGColor Window
menu Edit EUOEdit4 330 44 57 %ingredientsbag
menu Font BGColor BtnFace
menu Button setmisc_button 390 72 43 25 Set
menu Font BGColor Window
menu Edit EUOEdit5 330 72 57 %miscbag
menu Font BGColor BtnFace
menu Button movegems_button 150 144 43 25 Go
menu Button moveregs_button 150 172 43 25 Go
menu Button moveingredients_button 390 144 43 25 Go
menu Button movemisc_button 390 172 43 25 Go
  menu Show 421 270
return
;======= End Sub =======

;----------------------------------------------
; Well, I hope this could point you in the right
; direction to start writing your own scripts!
; I know we can get overwhelmed sometimes, when
; we try to read huge pages of things we
; still don't understand very well. So I hope
; this has maked things a little simpler for you!
; Cheers,
;
; frneo
;------------------------------------------------
; End Script
;------------------------------------------------


Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: Help with script, am I heading int he right direction
« Reply #16 on: August 11, 2011, 03:13:19 PM »
0
I don't think it would really work that exact way you wrote it.

Imho, its best to make the button go into each individual move sub at a time, in a sequence.

Something like this:

if #menubutton = moveall
   {
   gosub move1
   gosub move2
   gosub move3
   ....
   set #menubutton N/A
   }
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline BlacklistedTopic starter

  • Jr. Member
  • **
  • Posts: 75
  • Activity:
    0%
  • Reputation Power: 2
  • Blacklisted has no influence.
  • Respect: +13
  • Referrals: 0
    • View Profile
Re: Help with script, am I heading int he right direction
« Reply #17 on: August 11, 2011, 03:18:23 PM »
0
AHH I see, I need to start thinking more simpler :) thanks

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: Help with script, am I heading int he right direction
« Reply #18 on: August 11, 2011, 05:31:28 PM »
0
Ah, one more thing I noticed... If you do use each movesub like I told you, in a sequence, remember to remove the "Display All Done!" part from the subs, and add them to the specific button part you're using, outside of the sub...

So the sub would be sth like:

Code: [Select]
sub movedas
repeat
finditem %das C_ , %lootbag
exevent drag #findid #findstack
wait 10
exevent dropc %miscbag
wait 10
until #findcnt < 1
return

and the menu check part sth like this:

Code: [Select]
if #menubutton = moveall
   {
   gosub movedas
   gosub movedas2
   gosub movedas3
   ....
   set #menubutton N/A
   Display All Done!
   }
If you don't do this, it will keep displaying a message after each individual sub ends, which isn't very nice for the user I guess ! :D
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline BlacklistedTopic starter

  • Jr. Member
  • **
  • Posts: 75
  • Activity:
    0%
  • Reputation Power: 2
  • Blacklisted has no influence.
  • Respect: +13
  • Referrals: 0
    • View Profile
Re: Help with script, am I heading int he right direction
« Reply #19 on: August 11, 2011, 05:38:01 PM »
0
Yeah i saw that when i ran it, ive posted the final version in the submit your script section :)

Tags: