ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: tekhnolyze on July 26, 2011, 06:40:08 PM

Title: The MultiFlute 0.5
Post by: tekhnolyze on July 26, 2011, 06:40:08 PM
This is my first complete script that I think might be good enough to share with others. What it does is simple: its a menu that allows you to easily switch between each of your flutes of renewal (or other slayer/superslayer) and a GM instrument. My bard carries a full set of six flutes of renewal and a single GM-crafted instrument, which is the setup this script was written for. It could be adapted for other instrument sets as well, if necessary.

Instructions:
When you first start the script, you'll be prompted to set your instruments. This setup will store your instruments permanently so it only has to be done one time. Remember though, if you replace an instrument (your GM crafted one breaks for example), you'll have to run through the instrument setup again to register the new instrument. Also, the script does not yet differentiate between the different slayer types, so its up to you to choose the correct ones. The script will not correct it for you. If you mistakenly select the wrong instrument during setup, restart the script and do it again.

The Current Instrument line only tells you what instrument you most recently selected in the menu. So, if you manually use an instrument instead of choosing it through the script, that line will not update to reflect the change. You'll have to reselect an instrument in the menu for it to show a change.

Once this is done (or skipped), you'll be at the main menu, where you just select which instrument you want to use and it will automatically switch over to that instrument for you.

What this script does not do:
1) use any bard skills for you
2) prevent the loss/breakage of an instrument

Future changes that I plan to implement:
1) a counter that tells you how many uses are left on your current instrument
2) a failsafe to prevent you from using a flute of renewal when it gets down to one remaining use
3) an automatic continuous area peace toggle
4) possibly add in extra options for a single miscellaneous slayer instrument.

Anyway, this is my first real, solid script, and as far as I could tell its the only one that does what it does.

Dying to get some feedback whether good or bad, so tell me what you think and any suggestions to improve it would be GREAT!
Title: Re: The MultiFlute 0.5
Post by: gimlet on July 26, 2011, 09:36:56 PM
Nice idea!
Title: Re: The MultiFlute 0.5
Post by: onlyindreams on July 27, 2011, 12:32:35 AM
Interesting! I'll give it a run next time I use my discorder!
Title: Re: The MultiFlute 0.5
Post by: Cerveza on July 27, 2011, 02:51:27 AM
Nice job on your first contribution.

As always, there is room for improvement.

Initevents is not longer needed.

The "flow" is a bit erratic. Please take a look at the tutorials, especially script flow to see what I mean.

You really shouldn't be using gosubs to move around in a script the way you are, and when you DO gosub into a sub you should ALWAYS use return to get back to the point in the script where you "came from".

Here's an example:

Code: [Select]
1 - repeat
2 - gosub do_this
3 - gosub do_that
4 - until #false

6 - sub do_this
7 - stuff
8 - return

10 - sub do_that
11 - more stuff
12 - and more stuff
13 - return

Line 1 and 4 are a pair, repeat will continue to do everything between it and the next until, and then check the until statement to see if it's #TRUE. If it IS true then the condition is met and the script will continue past it. In our case, by setting the until to #FALSE we ensure it will NEVER be true. Thus making it a good main loop that will loop forever.

Line 2 and 3 are the gosubs. They will direct the script to immediately find a matching sub and execute whats inside.

Lines 6-8 are the first sub. Line 2 will execute and the script will skip down to line 6 and perform anything after the sub until it hits a return, in our case the return is line 8.

At this point you can start to see script flow. Using the numbers (which you would NOT use in a script, just for this posts purposes) the flow of this script is:

1-2-6-7-8-3-10-11-12-13-4

That pattern would continuously repeat itself.

Once you get that down, then you can use some condition stuff to determine if you even need to go to the sub routine.

Like if you need to cure a poison:

if C in #charStatus ; means you are poisoned
  gosub CURE

So if there is NO C in your #charStatus (not poisoned) it will NOT execute the next line.

Take a minute or 20 to read through the tutorials. I think you'll pick right up on improvements you could make to your MultiFlute right away! I even have some ideas about combining your sub routines ;) see anytime you use code in a script that is *really* similar, there is usually a way to reuse the same sub routine.
Title: Re: The MultiFlute 0.5
Post by: Cerveza on July 27, 2011, 03:53:37 AM
Another quick thing...

display ok IMPORTANT!!! LONG LINE OF STUFF

You can break that into separate lines by putting in the $ char. That will end one line and begin another.

This line is way too long. It just goes on forever. But there are good stopping points.

Changed to

This line is way too long.$It just goes on forever.$But there are good stopping points.

Becomes

This line is way too long.
It just goes on forever.
But there are good stopping points.

I'd recommend breaking up that super long line into shorter segments using $

****************************

I see you are using * variables, which isn't bad but they are used more commonly in scripts which send info to other scripts through the registry. A better variable for a stand alone script like yours would be %

set *arachnid #ltargetid

should be

set %arachnid #ltargetid

You really should only use the * variables if you want interaction between scripts, not like this script which runs alone.
Title: Re: The MultiFlute 0.5
Post by: tekhnolyze on July 27, 2011, 04:01:52 AM
Another quick thing...

display ok IMPORTANT!!! LONG LINE OF STUFF

You can break that into separate lines by putting in the $ char. That will end one line and begin another.

I'll add that in. I wanted to break it up but I couldn't figure out how to do it, so had to stick with the long line.

Quote
I see you are using * variables, which isn't bad but they are used more commonly in scripts which send info to other scripts through the registry. A better variable for a stand alone script like yours would be %

I use * because I want the instrument setup to be saved between uses of the script so they don't have to be reset every time you open it. Is there a different way to do this? AFAIK % variables clear after the script is stopped.
Title: Re: The MultiFlute 0.5
Post by: Cerveza on July 27, 2011, 04:43:34 AM
It's not a problem to use the * variables. If everyone did, you would have one cluttered registry though.

To resolve that issue, consider a later version that would automate the flute finding for you ;)

Spoiler: show
Read up on event property and #property
Title: Re: The MultiFlute 0.5
Post by: tekhnolyze on July 27, 2011, 09:56:20 AM
It's not a problem to use the * variables. If everyone did, you would have one cluttered registry though.

To resolve that issue, consider a later version that would automate the flute finding for you ;)

Spoiler: show
Read up on event property and #property


I tried to go this route, but I couldn't figure out how to correctly parse the output. Best I could do is the manual selection I used. If you could point me to a sub that would either work in its place or that I could adapt to fit my needs, it'd be fantastic :) I looked, but couldn't find anything. Didn't see any good tutorials on parsing either.
Title: Re: The MultiFlute 0.5
Post by: UOMaddog on July 27, 2011, 03:00:51 PM
I must admit I have not run the script because I'm writing this from my laptop.

First, I must say that I love the idea of this script. As I was reading it, I was trying to envision it and when I was reading your future additions an idea popped into mind! The menu could look like the picture below:

(http://dl.dropbox.com/u/6629297/bardmenu.png)

Anytime an instrument was used up (or could not be found in the pack because it was removed), the script would attempt to find another one. If it failed, the button turns red (and either not able to be selected or if clicked, defaults to a GM instrument). If it does find one, it updates the button to show how many uses are remaining on that particular instrument (and maybe in a future one, could scan all instruments and show a total number of uses for all instruments in the pack, though it would consume a lot more in terms of resources).

Just some ideas to throw out there!!

Good luck and I'll test it when I'm completely back up and running!
Title: Re: The MultiFlute 0.5
Post by: tekhnolyze on July 29, 2011, 03:30:50 PM
When I replace the gosub mainmenu lines with return at the set of subs at the bottom where it switches the instrument, it returns to the top of the script rather than to sub mainmenu. I'm not really seeing why
Title: Re: The MultiFlute 0.5
Post by: Endless Night on November 02, 2011, 08:12:42 PM
Script moved to script debug.
(If you disagree with the move please pm me.)
Thank you for the script submission

This script generated quiet a bit of interest .. I would recommend that you finish it and get that first script contribution under your belt.
Title: Re: The MultiFlute 0.5
Post by: tekhnolyze on November 14, 2011, 12:02:30 PM
Script moved to script debug.
(If you disagree with the move please pm me.)
Thank you for the script submission

This script generated quiet a bit of interest .. I would recommend that you finish it and get that first script contribution under your belt.


Took a bit of a UO break and put this on the back burner. But I'm back for now so I'll be finishing it soon
Title: Re: The MultiFlute 0.5
Post by: Khameleon on November 16, 2011, 05:12:43 PM
This Script actually has given me some insight, not only for bards but for switching Spell Books on mages... Now only if EUO was up I would have started to write something tonight.
Title: Re: The MultiFlute 0.5
Post by: DPeterson on November 26, 2011, 09:16:57 AM
Here's a bit of code to get ya moving in the right direction so you don't have to target your flutes every time.

Code: [Select]
  finditem PGP c_ , #backpackid
  for #findindex 1 #findcnt
  {
     event property #findid
     if arachnid in #property
       set !slayer1 #findid
     if elemental in #property
       set !slayer2 #findid
     if demon in #property
       set !slayer3 #findid
     if reptile in #property
       set !slayer4 #findid
     if repond in #property
       set !slayer5 #findid
     if undead in #property
       set !slayer6 #findid
  }
Title: Re: The MultiFlute 0.5
Post by: Crome969 on November 26, 2011, 10:43:25 AM
Here's a bit of code to get ya moving in the right direction so you don't have to target your flutes every time.

Code: [Select]
  finditem PGP c_ , #backpackid
  for #findindex 1 #findcnt
  {
     event property #findid
     if arachnid in #property
       set !slayer1 #findid
     if elemental in #property
       set !slayer2 #findid
     if demon in #property
       set !slayer3 #findid
     if reptile in #property
       set !slayer4 #findid
     if repond in #property
       set !slayer5 #findid
     if undead in #property
       set !slayer6 #findid
  }
The Idea is not bad, what i miss, why only flutes? what is with my regular slayer tools?
Title: Re: The MultiFlute 0.5
Post by: Khameleon on November 26, 2011, 12:19:20 PM
the idea behind this idea got me thinking... and this is what I came up with...

Link (http://www.scriptuo.com/index.php?topic=8931.0)
Title: Re: The MultiFlute 0.5
Post by: DPeterson on November 26, 2011, 01:15:28 PM
Here's a bit of code to get ya moving in the right direction so you don't have to target your flutes every time.
The Idea is not bad, what i miss, why only flutes? what is with my regular slayer tools?

It is probably in the other part of my script where I scan for other slayers.  I only posted the flute part to give him help.  Also, heres a handy way to organize all your spawn into types for ease of use later.  Will allow you to scan by slayer type, slayer difficulty, non slayer, and all spawn.  Very helpfull when looking for monsters for provoking.

Code: [Select]
  set !people
  set !forms
  set !summons

  set !nonSlayer1 yab_p_ki_ud_qd_vgb_n_pe_se_to_po_rb_ub ; easy non spell
  set !nonSlayer2 uc_mc_md_je                            ; easy spell
  set !nonSlayer3 db_kqb                                 ; medium non spell
  set !nonSlayer4 r_eb_wd_fd                             ; medium spell
  set !nonSlayer5 is_me_dd_bd_ej_ed_ri_cj_i              ; hard
  for !do 5 1
  {
    if !do = 5
      set !allNonSlayers !nonSlayer5
    else
      set !allNonSlayers !allNonslayers , _ , !nonSlayer . !do
  }
 
  ; Arachnid Slayer
  set !11 empty
  set !12 empty
  set !13 empty
  set !14 empty
  set !15 empty
  ; Elemental Slayer
  set !21 empty
  set !22 empty
  set !23 empty
  set !24 empty
  set !25 dd_bd_ej_ed_ri_cj
  ; Demon Slayer
  set !31 empty
  set !32 uc
  set !33 empty
  set !34 fd
  set !35 me
  ; Reptile Slayer
  set !41 empty
  set !42 empty
  set !43 empty
  set !44 empty
  set !45 empty
  ; Repond Slayer
  set !51 empty
  set !52 empty
  set !53 empty
  set !54 empty
  set !55 is     ; human
  ; Undead Slayer
  set !61 empty
  set !62 empty
  set !63 empty
  set !64 r_eb_wd  ; lichlord,lichlord
  set !65 empty
 
  for !do 1 6
  {
    for !it 5 1
    {
      if !do = 1 && !it = 5
        set !allSpawn !15
      else
      {
        set !combo !do , !it
        set !allSpawn !allSpawn , _ , ! . !combo
      }
      if !it = 5
      {
        set !combo !do , !it
        set ! . !do ! . !combo
      }
      else
      {
        set !combo !do , !it
        set ! . !do ! . !do , _ , ! . !combo
      }
    }
  }