ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Blacklisted on August 10, 2011, 07:33:18 AM

Title: Help with script, am I heading int he right direction
Post by: Blacklisted on August 10, 2011, 07:33:18 AM
Hi
Could i ask some advice on a script I'm trying to write.

While gathering loot to train imbueing I was getting fed up of dragging the gems and regs out of my pack by hand.
so I wanted to make a script that would pull the gems and regs out and seperate them into different containers, I can get the differant chests to open but im confused when it comes to moving the loot and and how to make the script first check for gems, move the gems then once there are no gems left move onto checking for regs and moving those. once I get that working I can work on adding user defined items. I have looked over some of the scripts already posted for ideas on how to solve it but I'd rather work it out rather than just plagiarise another scripters work.


Code: [Select]
;=================================================================
; Script Name: Blacklisted's MoveLoot
; Author: Blacklisted
; Version: 1.0
; Shard OSI
; Revision Date: 10/8/2011
; Purpose: To move loot into seperate containers
; Globals: None
;=================================================================

SET %Gems HVF_UVF_FVF_EVF_OVF_VUF_GVF_RVF_BVF_VVF_NVF_ZVF_
SET %Reagents KUF_JUF_KZF_JZF_MZF_WZF_RZF_SZF_DUF_TZF_UZF_YZF_IUF_

mainloop:

  gosub SelectLootBag:
  gosub SelectGemBag:
  gosub SelectRegBag:
  gosub OpenLootBag:
  gosub OpenGemBag:
  gosub OpenRegBag:
  gosub GetGems:
  gosub GetRegs:
  gosub MoveGems:
  gosub MoveRegs:
 
return


sub SelectLootBag:
display Please Select Your Loot Bag$
 set #targcurs 1
  target
  targetloop:
  if #targcurs = 1
    {
    goto targetloop:
    }
  set %LootBag #ltargetid
  wait 5
return

sub SelectGemBag:
display Please Select Your Gem Bag$
 set #targcurs 1
  target
  targetloop1:
  if #targcurs = 1
    {
    goto targetloop1:
    }
  set %GemBag #ltargetid
  wait 5
return

sub SelectRegBag:
display Please Select Your Reg Bag$
 set #targcurs 1
  target
  targetloop3:
  if #targcurs = 1
    {
    goto targetloop3:
    }
  set %RegBag #ltargetid
  wait 5
return

sub OpenLootBag:
  set #nextcposx 100
  set #nextcposy 600
  set #lobjectid %LootBag
  event macro 17
  wait 20
return

sub OpenGemBag:
  set #nextcposx 300
  set #nextcposy 600
  set #lobjectid %GemBag
  event macro 17
  wait 20
return

sub OpenRegBag:
  set #nextcposx 500
  set #nextcposy 600
  set #lobjectid %RegBag
  event macro 17
  wait 20
return

sub GetGems:
findItem %Gems C_ , %GemBag
repeat
 gosub MoveGems
until  #findKind = -1
set #lobjectID #findID
set #ltargetKind 1
Title: Re: Help with script, am I heading int he right direction
Post by: camotbik on August 10, 2011, 07:55:34 AM
Take a look at your script. It doesnt contain some returns, and the loop isnt working. Why? + In the end of the sub you add: which isn't req.  Look up these topics

http://www.scriptuo.com/index.php?board=17.0


Code: [Select]
SET %Gems HVF_UVF_FVF_EVF_OVF_VUF_GVF_RVF_BVF_VVF_NVF_ZVF_
SET %Reagents KUF_JUF_KZF_JZF_MZF_WZF_RZF_SZF_DUF_TZF_UZF_YZF_IUF

gosub setup
gosub move_gems
gosub move_regs
halt

sub setup
  event SysMessage Target your loot bag
  set #targcurs 1
  while #targcurs <> 0
    wait 1
  set %Lootbag #ltargetid
  
  event SysMessage Target your gem bag
  set #targcurs 1
  while #targcurs <> 0
    wait 1
  set %GemBag #ltargetid
  
  event SysMessage Target your reg bag
  set #targcurs 1
  while #targcurs <> 0
    wait 1
  set %RegBag #ltargetid
return

sub move_gems
  finditem %Gems C_ , %Lootbag
  if #findcnt > 0
  {
    for #FINDINDEX 1 #FINDCNT
    {
      Exevent Drag #findid #findstack
      Exevent Dropc %GemBag
      wait 10
    }
  }
return

sub move_regs
  finditem %Reagents C_ , %Lootbag
  if #findcnt > 0
  {
    for #FINDINDEX 1 #FINDCNT
    {
      Exevent Drag #findid #findstack
      Exevent Dropc %RegBag
      wait 10
    }
  }
return

By the way, you could use ScriptUO to check your script on bugs with the "syntax error check" button.
http://www.scriptuo.com/index.php?action=downloads;sa=view;id=3

e.g. your script
Code: [Select]
Method count: 56
Command count: 56
*** Pass 1 - Label accounting:
*** Warning - GOSUB getregs: - Line 23 has no matching SUBroutine
*** Warning - GOSUB movegems: - Line 24 has no matching SUBroutine
*** Warning - GOSUB moveregs: - Line 25 has no matching SUBroutine
*** Warning - GOSUB movegems - Line 96 has no matching SUBroutine
*** Warning - GOTO targetloop: - Line 37 has no matching tag
*** Warning - GOTO targetloop1: - Line 50 has no matching tag
*** Warning - GOTO targetloop3: - Line 63 has no matching tag
Subroutine labels = 7
Tag labels = 4
4 Code block(s).
7 Warnings(s) encountered.
*** Pass 2 - Execution [SYNTAXCHECK]
Title: Re: Help with script, am I heading int he right direction
Post by: Cerveza on August 10, 2011, 08:14:38 AM
Here's a little suggestion to camotbik's suggestion:

Code: [Select]
event SysMessage Target your loot bag
set #targcurs 1
while #targcurs <> 0
wait 1
set %Lootbag #ltargetid
set #lobjectID %Lootbag
event macro 17
wait 5

Added the last three lines which will set the bag to last object, then use last object - opening the bag.
Title: Re: Help with script, am I heading int he right direction
Post by: Blacklisted on August 10, 2011, 11:42:38 AM
Thanks alot guys im going to attempt to add in a menu and made more items like scrolls and imbuing ingredients.
could you give me a quick run down of the "return" actully mean's. and also is it ok to have the "event system message" I think I read on easyuo somewhere GM's may be able scan your journel.
thanks
Title: Re: Help with script, am I heading int he right direction
Post by: Cerveza on August 10, 2011, 11:55:55 AM
It's time you found the tutorials here :)
Title: Re: Help with script, am I heading int he right direction
Post by: camotbik on August 10, 2011, 01:02:04 PM
I think I read on easyuo somewhere GM's may be able scan your journel.

Lolz, give us the link.
btw, this comand is client sided so gm - even if they would scan your journal - would't see it.
Title: Re: Help with script, am I heading int he right direction
Post by: Neo on August 10, 2011, 08:24:13 PM
Hi Blacklisted! I wrote the script down for you, to do the stuff you wanted it to do, with comments, in the form of a tutorial. This script should be fully functional, and also, it's an easy to read tutorial so that you can understand everything that each line of code does. I hope you can find this useful to help give you a push in the right direction to start learning how to script.

So, here it is:
Code: [Select]
;----------------------------------------------------
; 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_
set %reagents KUF_JUF_KZF_JZF_MZF_WZF_RZF_SZF_DUF_TZF_UZF_YZF_IUF_
;-------------------------------------------------------------
; 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

;--------------------------------------------------
; 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 = moveregs_button
   {
   if %regsbag <> N/A && %lootbag <> N/A
      {
      gosub moveregs
      set #menubutton N/A
      }
   else
      {
      Display You must set up each bag first
      set #menubutton N/A
      }
   }
if #menubutton = movegems_button
   {
   if %gemsbag <> N/A && %lootbag <> N/A
      {
      gosub movegems
      set #menubutton N/A
      }
   else
      {
      Display You must set up each bag first
      set #menubutton N/A
      }
   }
until #false ; thank you cerveza! :)

;--------------------------------------------------
; 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
      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
      menu Edit EUOEdit3 84 104 57 %regsbag
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 =======

;--------------------------------------
; 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 221 225
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 12 104 Regs Bag ID:
menu Text EUOLabel4 12 144 Move regs to bag:
menu Text EUOLabel5 12 172 Move gems 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 104 43 25 Set
menu Font BGColor Window
menu Edit EUOEdit3 84 104 57 %regsbag
menu Font BGColor BtnFace
menu Button moveregs_button 124 144 43 25 Go
menu Button movegems_button 124 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 made things a little simpler for you!
; Cheers,
;
; frneo
;------------------------------------------------
; End Script
;------------------------------------------------
Just copy this to your EUO. You will find detailed explanations on (almost) everything the code is meant for, and I tried to keep it as simple as possible.

I gave you a few explanations on the use of the menu too.

(http://img809.imageshack.us/img809/5081/blacklistedmenu.jpg)

If you have any questions, just ask and I'll get back to you as soon as possible.

Hope this helps! :)

Cheers!
Title: Re: Help with script, am I heading int he right direction
Post by: Cerveza on August 11, 2011, 03:42:04 AM
I think I read on easyuo somewhere GM's may be able scan your journel.

Lolz, give us the link.
btw, this comand is client sided so gm - even if they would scan your journal - would't see it.

It's hidden in a section called Scripting Tutorials (http://www.scriptuo.com/index.php?board=17.0)
Title: Re: Help with script, am I heading int he right direction
Post by: Blacklisted on August 11, 2011, 04:12:50 AM
Thanks frneo, Cerveza & camotbik :)
I'm going to go over it today and spend some time on the tutorials also. I guess i was trying to run before I could walk.
Thanks for taking the time frneo for explaining how each part works it helped  alot im adding other items to the script and ill post up the finished script.
Title: Re: Help with script, am I heading int he right direction
Post by: Cerveza on August 11, 2011, 05:10:26 AM
ewwww... just noticed that frneo uses a goto loop... icky dude!

replace

loop:
with
repeat

and replace

goto loop
with
until #false
Title: Re: Help with script, am I heading int he right direction
Post by: Goliath on August 11, 2011, 05:14:20 AM
I know you may be learning how to script which is aweseom, but have you considered using TMs Advanced Claw looting script?  When I am doing the spawn I use that one and it works great :D  It is crazy advanced and customizable!
Title: Re: Help with script, am I heading int he right direction
Post by: Neo on August 11, 2011, 06:23:36 AM
ewwww... just noticed that frneo uses a goto loop... icky dude!

replace

loop:
with
repeat

and replace

goto loop
with
until #false
:(

I remember reading this on another post of yours, lol...

That you're totally against using goto...

Does goto really influence how the script works in a bad way?

Or is it just plain aesthetics?

Thank you for the input Cerveza! :)

Cheers!
Title: Re: Help with script, am I heading int he right direction
Post by: Neo on August 11, 2011, 06:51:34 AM
Thanks frneo, Cerveza & camotbik :)
I'm going to go over it today and spend some time on the tutorials also. I guess i was trying to run before I could walk.
Thanks for taking the time frneo for explaining how each part works it helped  alot im adding other items to the script and ill post up the finished script.

You're welcome! :)
I'm glad I could help!

If you have any questions on this new version of yours, feel free to ask!

Title: Re: Help with script, am I heading int he right direction
Post by: Cerveza on August 11, 2011, 06:56:02 AM
One thing is that goto's aren't supported in OEUO, so transitioning scripts that have goto in them over won't work until something is put in place to rewrite them in a script.

Another thing is that they can confuse beginner scripters and cause headaches to advanced scripters.

Post (http://www.scriptuo.com/index.php?topic=523.0)
Post (http://www.scriptuo.com/index.php?topic=4340.0)

There's really no reason to ever use a goto in a script.


Title: Re: Help with script, am I heading int he right direction
Post by: Neo on August 11, 2011, 07:06:57 AM
One thing is that goto's aren't supported in OEUO, so transitioning scripts that have goto in them over won't work until something is put in place to rewrite them in a script.

Another thing is that they can confuse beginner scripters and cause headaches to advanced scripters.

Post (http://www.scriptuo.com/index.php?topic=523.0)
Post (http://www.scriptuo.com/index.php?topic=4340.0)

There's really no reason to ever use a goto in a script.



Well, thanks for this!

Didn't know there was such prejudice against goto's in general!

From now on, I'm gonna try to write my stuff without using goto's! Even if it's just for the fun of it!

EDIT: Changed the tutorial script using repeat, and also updated my weapon crafter removing gotos ! :)

Title: Re: Help with script, am I heading int he right direction
Post by: Blacklisted on August 11, 2011, 03:07:57 PM
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
;------------------------------------------------

Title: Re: Help with script, am I heading int he right direction
Post by: Neo on August 11, 2011, 03:13:19 PM
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
   }
Title: Re: Help with script, am I heading int he right direction
Post by: Blacklisted on August 11, 2011, 03:18:23 PM
AHH I see, I need to start thinking more simpler :) thanks
Title: Re: Help with script, am I heading int he right direction
Post by: Neo on August 11, 2011, 05:31:28 PM
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
Title: Re: Help with script, am I heading int he right direction
Post by: Blacklisted on August 11, 2011, 05:38:01 PM
Yeah i saw that when i ran it, ive posted the final version in the submit your script section :)