I wrote the script down for you, doing the stuff that I think you meant it to do... I commented each part in detail in the form of a tutorial so that you can learn how each thing is done, and hopefully you can understand better how a script works.
So, here it is, hope you find it useful!
; Well, I don't know how much you know about scripting
; so I'm going to try and keep it as simple as I can for
; the main purpose of this script. If you ever don't understand
; a step I used here, just ask me, or look that name up
; at http://wiki.easyuo.com/ you will find good explanations
; there to most things you can need.
;
; As with any script, let's start by setting the variables
; we're going to use. You start a variable with '%' and you
; can name it whatever you want. Then you just have to know the types
; of each item you need, and set those variables to those types.
; To know an item type, just double click it, and then check your
; EUO window and look up the value of #lobjecttype. This will be
; the item type we're going to set.
;------------------------------------------------------------------
set %yarn NLF_PLF_QLF_ ; there are 3 yarn types, as far as I know, we use _ to set different things to 1 var
set %cotton NFF
set %wool OFF
set %bolt ZZF
set %thread UAG
; Don't worry about the loom and the spinning wheel. We're going to
; be setting them through our menu.
; Menu? That's right, it's always easier for any user to do stuff
; just clicking a menu. So we'll use one.
; Before we get to that, I want to tell you a little about how a sub works.
; I've copied this from another little tutorial I wrote:
;
; " 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). "
;---------------------------------------------------------------
; For this little script, we're going to use individual subs for
; every function we need done. The first sub is the one to generate
; our menu. If you want to take a look at it, scroll down to the
; menu sub (sub menu)
; Now we are going to 'call' the menu, using gosub {sub name}
;----------------------------------------------------------------
gosub menu ;this line here will go to the sub named 'menu', and execute
; all the lines there, until it finds a return, and it will come back
; right here. So once that's all done, the user should be seeing our
; menu on his screen. Now we must know how to work with the menu buttons.
; A good way to do this, is writing separate subs for each menu button
; that is clicked. The system variable #menubutton will hold the information
; on the last button that was clicked in the menu. Before any button is
; pushed, the #menubutton var is going to be N/A. Knowing all that, we can
; write our main loop:
;-------------------------------------------------------------------
;======= Main Loop =======
repeat
if #menubutton <> N/A
gosub #menubutton
until #false
;======= End Loop =======
; So how does this loop work? Let's first understand what it's telling
; us line by line.
; Line 1: if #menubutton <> N/A is exactly what it looks like.
; As soon as the #menubutton var is different from N/A, it will perform the next
; line. Once, a user clicks a button, this will be true. So let's take a look at the next line.
;
; While the #menubutton var is equal to N/A, we're gonna do nothing.
; Now, remember what I told you about how buttons work in a menu?
; So, if we click any button, the #menubutton var will be set to
; that button name. So, once this happens, the #menubutton var
; will be different from N/A and we'll go to the gosub line,
; to go to a sub that
; has the name set to our #menubutton var. In other words, it will go to
; the sub that has the name of the menu button we just clicked.
; Great stuff huh?
;-------------------------------------------------------------------
; Now we have to create a sub for each button that is clicked, with the
; name of the corresponding button name. You can just scroll down to
; the menu sub to find the button names I used. So, let's write the
; sub for when the user clicks the resource_button.
; First we need to think: what do we want to happen once that button
; is clicked? The point of that button is to set your Secure Container,
; where you will put your cotton, wool, etc in. Alright, so let's get
; that done!
;---------------------------------------------------------------------
;======= resource_button sub =======
sub resource_button ; 1
event sysMessage Target your secure ; 2
set #targcurs 1 ; 3
while #targcurs = 1 ; 4
wait ; 5
set %resource #ltargetid ; 6
set #lobjectid #ltargetid ; 7
event macro 17 ; 8
wait 20 ; 9
set #menubutton N/A ; 10
return ; 11
;======= end sub =======
; Ok, I put numbers beside each line for reference. I'm going to quickly
; go through all of them.
; 1) sub { name of the sub }, in this case resource_button,
; this line is where it goes to when we use "gosub { name of the sub }"
; 2) event SysMessage will show a message inside the user's UO window,
; so he will see a msg to target his secure.
; 3) set #targcurs 1 will change that hand cursor into that little
; target thing.
; 4 & 5 ) It will wait while that target thing is active, in other words,
; it will only perform line 6 once you click something.
; 6) After you click something, the target cursor will disappear, and
; we'll go to this line. The id of the thing you clicked will be
; set in the system variable #ltargetid. So this line will set
; our variable %resource to the last target, or the container we clicked.
; 7 and 8) We are going to set #lobjectid to this same value. Why? So that
; we can use the command Event Macro 17, which will "use" the
; item with the id set in the #lobjectid variable. So this will
; open up the user's container.
; 9) wait 20 is just a little wait for the container to be opened
; 10) Remember that our loop will wait until the #menubutton var is different
; than N/A to do stuff. The user had clicked the resource_button to come here
; so, if we just return right now, the script will go into an endless loop
; going to this sub, and back there. So we must set the #menubutton var
; back to N/A before we use the 'return'.
; 11) Finally, everything is done here, and we can return back to the main loop
; to wait for another #menubutton to be clicked. Right on !
;------------------------------------------------------------------------
; Alright, now let's write the subs for the other buttons.
; Let's start with the bolt_button, used for targetting a container
; to put our bolts in. It's pretty similar to the sub we just wrote, so
; let's get to it!
;------------------------------------------------------------------------
;======= bolt_button =======
sub bolt_button
event sysMessage Target a container for you bolts
set #targcurs 1
while #targcurs = 1
wait
set %boltbag #ltargetid
set #menubutton N/A
return
;======= end sub =======
;------------------------------------------------------------------------
; Only difference you should notice here, is that I didn't set to open
; this container. Why, you ask? Because we're just gonna put stuff in it,
; so there's no real need to open it. In fact, it's best to leave it closed
; so that there's no danger of confusing the bolts in our backpack with the
; bolts inside this bag.
;-----------------------------------------------------------------------
; Now let's write the subs to set the loom and the wheel. Same deal
; as we just did so far.
;------------------------------------------------------------------------
;======= loom_button =======
sub loom_button
event sysMessage Target your loom
set #targcurs 1
while #targcurs = 1
wait
set %loomid #ltargetid
set %loomkind #ltargetkind
set #menubutton N/A
return
;======= end sub =======
;======= wheel_button =======
sub wheel_button
event sysMessage Target your spinning wheel
set #targcurs 1
while #targcurs = 1
wait
set %wheelid #ltargetid
set %wheelkind #ltargetkind
set #menubutton N/A
return
;======= end sub =======
;-----------------------------------------------------------------------
; One thing you should notice here is %wheelid and %wheelkind (same for loom)
; This is just to make sure we set the correct kind of target kind when
; we are going to be targetting them in the 'making bolts part'.
; The target kinds are:
; 1) Objects, 2) Ground, 3) Resource
; If you want to know more on that, look it up on the easyuo wiki. :)
; Yes, it's done! Now we just need to create the subs which will perform
; the real intended actions of this script. :D
; The button responsible for this is the start_button, so our original sub
; name is going to be...? You guessed it! sub start_button. Now, before we
; get to that, let's think what we need done, once this button is pressed.
; First thing, is have it check if all the ID's we need have been set,
; otherwise it's not gonna work. Next we should think about what we're gonna
; do with the stuff. So, basically, we need to do the following things:
; - Use all the wool on the spinning wheel and put the yarns in the secure.
; - Use all the cotton on the spinning wheel and put all the thread in the secure
; - Use all the thread on the loom, and put the bolts in the bolt container.
; - Use all the yarn on the loom, and put the bolts in the bolt container.
; Ok, that's basically all we need. So, I think the simplest way to do this
; is using a separate sub for each of these parts, until they are all done.
; And we're going to call them all from the start_button sub. So now we have
; an idea on how this sub is gonna look. So let's write it down:
;----------------------------------------------------------------------------
;======= start_button =======
sub start_button
if %resource = N/A
{
Display You must set your secure
set #menubutton N/A
return
}
if %boltbag = N/A
{
Display You must set your bolt container
set #menubutton N/A
return
}
if %loomid = N/A
{
Display You must set the loom you're using
set #menubutton N/A
return
}
if %wheelid = N/A
{
Display You must set the wheel you're using
set #menubutton N/A
return
}
; alright, the checking part is done. If one of the above
; variables isn't set, it will be N/A. If it's N/A, the #menubutton will
; be set back to N/A and it will return to the main loop, where
; the user can then set his stuff properly. Great! Now let's just write down
; the gosub's we're going to use, in the order we want them to be called.
gosub wool
gosub cotton
gosub thread
gosub yarn
set #menubutton N/A
Display All Done!
return
;======= End Sub =======
;--------------------------------------------------------------------
; Ok, "All Done", YAY, hip hip hoorah \0/! We did it!
;
; ...
; Wait a minute...
; Aren't we forgetting anything?
;
;
; Of course! We have to write the last subs we need for the script to work,
; otherwise we won't have accomplished anything with this. >:(
;------------------------------------------------------------------------
; So, let's start with the wool sub. We basically need it to check for wool
; in the secure, use it on the spinning wheel, and put the thread back in the
; secure. Pfft, piece of cake, let's do that!
;---------------------------------------------------------------------------
;======= wool sub =======
sub wool
repeat
finditem %wool C_ , %resource
set #lobjectid #findid
event macro 17
set %weight #weight ; 1
while #targcurs <> 1
wait
set #ltargetid %wheelid
set #ltargetkind %wheelkind
event macro 22 ; this will perform target last target
while %weight = #weight ; 2
wait
finditem %yarn C_ , #backpackid
for #findindex 1 #findcnt
{
exevent drag #findid #findstack ; #findstack is the amount of the item found in the same stack, so this will drag all the items from the stack
wait 20
exevent dropc %resource ; this will drop the items to the container we set
wait 20
}
finditem %wool C_ , %resource
until #findcnt < 1
return
;======= end sub =======
; This is how I figured would be easy
; to write this, and also easy
; to understand how it works.
; If you want, you can look up more on the
; finditem deal on the easyuo wiki.
; The main thing you should notice here is I use a weight check
; instead of "wait" after targeting the spinning wheel.
; 1) I set %weight to the same value as the #weight system
; var, which holds the char's current weight value.
; 2) Once the yarn is created, it will be put in your backpack.
; The wool was in the secure, so you're weight is sure to increase
; as soon as the ball of yarn is created.
; So once the #weight increases, it won't be equal to %weight var
; anymore, thus, continuing the loop.
; Once the yarn is created, it will drag it to the container. This structure
; I used (for #findindex 1 #findcnt) will move all stacks it finds of
; thread to the secure each time it makes yarn. There are faster ways
; to do this, but this one works, and is easy(ier) to understand! :)
; This sub will be repeated until wool #findcnt < 1, in other words
; once we use up all the wool, it will return to the start_button sub.
;----------------------------------------------------------------------
; Let's write a similar one for the cotton.
;----------------------------------------------------------------------
;======= cotton sub =======
sub cotton
repeat
finditem %cotton C_ , %resource
set #lobjectid #findid
event macro 17
set %weight #weight ; 1
while #targcurs <> 1
wait
set #ltargetid %wheelid
set #ltargetkind %wheelkind
event macro 22 ; this will perform target last target
while %weight = #weight ; 2
wait
finditem %thread C_ , #backpackid
for #findindex 1 #findcnt
{
exevent drag #findid #findstack
wait 20
exevent dropc %resource
wait 20
}
finditem %cotton C_ , %resource
until #findcnt < 1
return
;======= end sub =======
;---------------------------------------------------------------------------
; Alright, now we just need to write the subs for the thread and the yarn to
; be used on the loom! Very similar to these last 2 subs, so let's get started!
;---------------------------------------------------------------------------------
;======= thread sub =======
sub thread
repeat
finditem %thread C_ , %resource
set #lobjectid #findid
event macro 17
while #targcurs <> 1
wait
set #ltargetid %loomid
set #ltargetkind %loomkind
event macro 22 ; this will perform target last target
wait 10
finditem %bolt C_ , #backpackid
for #findindex 1 #findcnt
{
exevent drag #findid #findstack
wait 20
exevent dropc %boltbag
wait 20
}
finditem %thread C_ , %resource
until #findcnt < 1
return
;======= End Sub =======
;----------------------------------
; I've removed the %weight check because it
; can't be used here. Instead I used a simple
; wait. If it's not waiting long enough, we
; can adjust this to whatever we want.
;-----------------------------------------
; Let's do the same thing for the yarn sub
;-----------------------------------------
;======= yarn sub =======
sub yarn
repeat
finditem %yarn C_ , %resource
set #lobjectid #findid
event macro 17
while #targcurs <> 1
wait
set #ltargetid %loomid
set #ltargetkind %loomkind
event macro 22 ; this will perform target last target
wait 10
finditem %bolt C_ , #backpackid
for #findindex 1 #findcnt
{
exevent drag #findid #findstack
wait 20
exevent dropc %boltbag
wait 20
}
finditem %yarn C_ , %resource
until #findcnt < 1
return
;======= End Sub =======
;-------------------------------
; Ok, guess we're done! Now if you check back at the
; start_button sub, you will see that once we return
; from the yarn sub, the script will display All Done
; and halt, meaning that all our bolts where made and are
; in the secure. Our at least they should be :)
;-----------------------------------------------------
; Guess this is it, I didn't have the time to test this,
; since my wife is yelling at me already, but the idea
; surely is correct. Hope that be reading this, you can
; get a good enough idea to how to write this stuff on your
; own!
;-------------------------------------------------------
; Below you can check out the menu sub too.
; Well, I hope you found this useful.
; Cheers!
; frneo
;------------------------------------------------------
;======= Menu Sub =======
sub menu
menu Clear
menu Window Title Sardorn's Bolt'em
menu Window Color BtnFace
menu Window Size 132 145
menu Font Transparent #true
menu Font Align Right
menu Font Name Arial
menu Font Size 8
menu Font Style
menu Font Color WindowText
menu Font Transparent #false
menu Font Align Left
menu Text EUOLabel1 12 24 Set Resource
menu Text EUOLabel2 12 44 Set Bolt Bag
menu Text EUOLabel3 12 64 Set Loom
menu Text EUOLabel4 12 84 Set Wheel
menu Button resource_button 84 20 27 21 set
menu Button bolt_button 84 40 27 21 set
menu Button start_button 24 108 75 25 Start
menu Button loom_button 84 60 27 21 set
menu Button wheel_button 84 80 27 21 set
menu Show
return
;======= End Sub =======
I couldn't test it, because my wife is already yelling at me, but I think it should work properly. The idea behind it is sure to be correct though, so if needed, you can adjust this to make it fully work and turn it more to your liking!
You can also try and add a counter to this later, or any other feature you think will be nice to have...
Hope you can find this useful!
neo