Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Tue Feb 10, 2009 7:06 pm   

Auto Alias Maker and F-Key enumerator (MUME)
 
[warn] fixed a bug


NUM - Writes and displays variables for F-Key enabled focus (Called by POP, LDD, TKK)
POP - Automatically writes Tabs and Player Alias
LDD - Assigns leader from last alias created or on %1 input, use 'no' to remove.
TKK - Assigns tank from last alias created or on %1 input, use 'no' to remove.
NIXI - Removes tabs and alias based on last failed POP alias or accepts alias name.
NIXDIR - Deletes the entire Assists|GroupAlias collection folder.
@akapref - DB of controlling values.

NUM (enumeration and display)

A. Can insert unaliased player names into F-Key position. Useful in focus statements instead of making alias in the crush
B. Can swap player's name position in F-Key numbering
C. Prepares F-Keys with player names so when they are pressed the 'ffocus' variable is assigned.

NUM [anything] - Clears the displays in manual mode.
NUM [2] [string] - Inserts 'string' into the second position. Limited to number of positions used plus one
NUM [1] [4] - Swaps 'F-Key string 1' and 'F-Key string 4'. Wont work if the first parameter is larger then the second.

In my case 'string' is a player name, but NUM strings can be stand alone common targets if you want to use the ffocus variable.

Values in the akapref DB affecting NUM:

lock = 0 When called by POP, LDD, and TKK, displays alias names in a list. Assigns variables used by f-keys. Overwrites inserts and swaps.
lock = 1 Manual, type NUM [#] [string] to build a list of F-Key focus values. Keep inserts and swaps.

shownum directs the display output.
shownum = 0 No display
shownum = 1 Print on screen
shownum = 2 Print in a status window
shownum = 3 Print on screen and in a status window.

fkeymax determines how many of the F-Keys are used in these processes.
fkeymax = 12 How many of the F-Keys to use for player names.

sh_focus is simply a message you would see when you press an assigned F-Key
sh_focus = 1 (This text is in the F-Key macros rather then the NUM script.)

If the number of your aliases have gotten larger then the value of 'akapref fkeymax', those display on screen in grey, but not in the status window.

NUMPR Called by NUM, this Prints a formatted list of player data related to F-Keys. It is not stand alone but subbed for editing.

Enumeration is based upon the unused "@mygroup" string list, followed by last entry in akadb to first entry, but prioritizing the Leader and Tank variables

Priorities if any exist:

1. @leader (has title)
2. @tank (has title)
3. @MyGroup (if any = player|player|player)
4. last to first entry in akadb

Notes:

If you wish the change the leader title text in the NUMPR script it occurs many times as "[Leader]" and "[L]". Deleting them outright will cause the %format() function to fail. @MyGroup is for my untested trigger, but you can use it to overwrite auto-numbering.

If you swap and used multiple alias for the same player those alias name correspond but display systematically still.

The code includes 12 F-Key macros. Those would conflict with other, previous F_Key macros you have in settings.

POP (alias recorder)

POP [alias_name] [Player] - Literal suggestion for alias name.
POP [Player] - Truncates Player name to create the alias.

Values in the akapref DB affecting POP:

length = 2 Will truncate the player name whatever this number is set, and use it as the alias name.

prompt = 1 Opens the prompt if the alias you try to make is already defined.
prompt = 0 If you dislike the focus change (or perhaps want to run a batch alias script from a trigger) you can set this to 0. A previously defined alias will still fail with the recommended warnings.

action = assist Use any function or string for this value. As I wrote this for MUME, action is set to 'assist' creating 'assist Nostradamus' in an alias named NO by typing POP Nostradamus. This can be changed on the fly. If the akapref key 'action' is later set with a value of 'rescue' (#ADDKEY akapref action rescue). A NO alias will then 'rescue Nostradamus'

The following is for F-Key use:

Code:
#ALIAS NUM {#class Assists|GroupAlias;#var tm_skittles "";#var tm_loop "";#var tm_solati "";#var tm_switch1 "";#var tm_switch2 "";#var tm_form1fr "";#var tm_spacer "";#var tm_akatemp "";#var tm_allyup "";#var tm_dexit "";#if (%match( %1, %w)) {#if (0 == %match( %2, %d)) {#var tm_final ""} {#sh bad input;#co coral}};#if (%isnumber( %1) == 0 and %db( @akapref, lock) == 0) {#var tm_final ""};#loopdb @akadb {#if (%isnumber( %1) == 0) {#var tm_loop %additem( %val, @tm_loop)};#addkey tm_akatemp %val %key};#if (%isnumber( %1)) {#if (%1 > 0 and %eval( (%numitems( @tm_final) + 1) >= %1)) {#if (%match( "%2", %w)) {#if (%ismember( %proper( %2), @tm_final)) {#var tm_final %delitem( %proper( %2), @tm_final)};#loop %eval( %numitems( @tm_final) + 1) {#if (%1 == %i) {#var tm_skittles %additem( %proper( %2), @tm_skittles)};#var tm_skittles %additem( %item( @tm_final, %i), @tm_skittles)}} {#if (%isnumber( %2)) {#if (%2 > 0 and %eval( %numitems( @tm_final) >= %2)) {#var tm_switch1 %item( @tm_final, %1);#var tm_switch2 %item( @tm_final, %2);#loop %numitems( @tm_final) {#if (%1 == %i) {#var tm_skittles %additem( @tm_switch2, @tm_skittles)} {#if (%2 == %i) {#var tm_skittles %additem( @tm_switch1, @tm_skittles)} {#var tm_skittles %additem( %item( @tm_final, %i), @tm_skittles)}}}} {#sh {insuffient data};#co coral}}}} {#sh {insuffient data};#co coral}} {#if (%db( @akapref, lock) == 0) {#loop %numitems( @tm_loop),1 {#var tm_skittles %additem( %item( @tm_loop, %i), @tm_skittles)};#if (%numitems( @mygroup) > 0) {#loop %numitems( @my_group) {#var tm_skittles %delitem( %item( @my_group, %i), @tm_skittles)};#loop %numitems( @my_group),1 {#var tm_skittles %push( %item( @my_group, %i), @tm_skittles)}};#if (!%null( @leader)) {#if (%ismember( @leader, @tm_skittles)) {#var tm_skittles %delitem( @leader, @tm_skittles)};#var tm_skittles %push( @leader, @tm_skittles)};#if (!%null( @tank)) {#if (%ismember( @tank, @tm_skittles)) {#var tm_skittles %delitem( @tank, @tm_skittles)};#var tm_solati %pop( tm_skittles);#var tm_skittles %push( @tank, @tm_skittles);#if (!%null( @tm_solati)) {#var tm_skittles %push( @tm_solati, @tm_skittles)}}}};#if (%null( %item( @tm_skittles, %numitems( @tm_skittles)))) {#delnitem tm_skittles %numitems( @tm_skittles)};#if (%numitems( @tm_skittles) > 0) {#var tm_final "";#var tm_final @tm_skittles};#exec numform_pr;#unvar tm_dexit;#unvar tm_akatemp;#unvar tm_allyup;#unvar tm_switch1;#unvar tm_switch2;#unvar tm_solati;#unvar tm_loop;#unvar tm_skittles;#unvar tm_form1fr;#unvar tm_spacer;#class 0} "Assists|Friends"
#ALIAS numform_pr {#if (%numitems( @tm_final) > 0) {#case @akapref.display {#sh " "} {#stw {""} {Shared} {TMSTWin};#stw {%cr} {Shared} {TMSTWin}} {#sh " ";#stw {""} {Shared} {TMSTWin};#stw {%cr} {Shared} {TMSTWin}} {#noop};#loop @akapref.length {#if (%db( @akapref, lock) == 1) {#var tm_spacer %concat( "-", @tm_spacer)} {#var tm_spacer %concat( "?", @tm_spacer)}};#forall @tm_final {#if (%iskey( @tm_akatemp, %i)) {#if (%ismember( %db( @tm_akatemp, %i), @tm_allyup)) {#var tm_dexit 0;#loopdb @akadb {#if (%val == %i) {#if (%ismember( %key, @tm_allyup) = 0) {#add tm_dexit 1;#if (@tm_dexit == 1) {#var tm_allyup %additem( %key, @tm_allyup)}}}}} {#var tm_allyup %additem( %db( @tm_akatemp, %i), @tm_allyup)}} {#var tm_allyup %additem( @tm_spacer, @tm_allyup)}};#loop %numitems( @tm_final) {#if (%i > @akapref.fkeymax) {#if (@akapref.display == 1 or @akapref.display == 3) {#if (%len( %item( @tm_final, %i)) > 12) {#var tm_form1fr %concat( %left( %item( @tm_final, %i) %i, 9), "...")} {#var tm_form1fr %item( @tm_final, %i)};#sh %format( "   &3s &-12s &-3s &-6s", "F--", @tm_form1fr, " - ", %item( @tm_allyup, %i));#co darkslategray}} {#var %concat( "friend", %i) %item( @tm_final, %i);#if (@akapref.display > 0) {#if (%len( %item( @tm_final, %i)) > 12) {#var tm_form1fr %concat( %left( %item( @tm_final, %i) %i, 9), "...")} {#var tm_form1fr %item( @tm_final, %i)};#case @akapref.display {#if (%item( @tm_final, %i) == @leader) {#sh %format( "   &3s &-12s &-6s &-6s", %concat( "F", %i), @tm_form1fr, %item( @tm_allyup, %i), ~[Leader~]);#co lightseagreen} {#if (%item( @tm_final, %i) == @tank) {#sh %format( "   &3s &-12s &-6s &-6s", %concat( "F", %i), @tm_form1fr, %item( @tm_allyup, %i), ~[Tank~]);#co lightseagreen} {#sh %format( "   &3s &-12s &-6s", %concat( "F", %i), @tm_form1fr, %item( @tm_allyup, %i));#co lightseagreen}}} {#if (%item( @tm_final, %i) == @leader) {#STW + {%format( " &-12s &-3s &-3s &3s ", @tm_form1fr, %item( @tm_allyup, %i), %concat( "F", %i), ~[L~])}} {#if (%item( @tm_final, %i) == @tank) {#STW + {%format( " &-12s &-3s &-3s &3s ", @tm_form1fr, %item( @tm_allyup, %i), %concat( "F", %i), ~[T~])}} {#STW + {%format( " &-12s &-3s &-3s", @tm_form1fr, %item( @tm_allyup, %i), %concat( "F", %i))}}}} {#if (%item( @tm_final, %i) == @leader) {#if (!%null( @leader)) {#STW + {%format( " &-12s &-3s &-3s &3s ", @tm_form1fr, %item( @tm_allyup, %i), %concat( "F", %i), ~[L~])};#sh %format( "   &3s &-12s &-6s &-6s", %concat( "F", %i), @tm_form1fr, %item( @tm_allyup, %i), ~[Leader~]);#co lightseagreen}} {#if (%item( @tm_final, %i) == @tank) {#if (!%null( @tank)) {#STW + {%format( " &-12s &-3s &-3s &3s ", @tm_form1fr, %item( @tm_allyup, %i), %concat( "F", %i), ~[T~])};#sh %format( "   &3s &-12s &-6s &-6s", %concat( "F", %i), @tm_form1fr, %item( @tm_allyup, %i), ~[Tank~]);#co lightseagreen}} {#STW + {%format( " &-12s &-3s &-3s", @tm_form1fr, %item( @tm_allyup, %i), %concat( "F", %i))};#sh %format( "   &3s &-12s &-6s", %concat( "F", %i), @tm_form1fr, %item( @tm_allyup, %i));#co lightseagreen}}}}}};#if (@akapref.display == 1 or @akapref.display == 3) {#sh " "}} {#if (@akapref.lock == 1) {#sh " ";#if (@akapref.display == 2 or @akapref.display == 3) {#sh " ...";#co coral;#stw {""} {Shared} {TMSTWin};#stw {%cr} {Shared} {TMSTWin}}}}} "Assists|Friends"
#ALIAS PRINTNUM {#class Assists|GroupAlias;#var tm_keepval "";#var tm_keepval %db( @akapref, lock);#addkey akapref lock 1;NUM;#addkey akapref lock @tm_keepval;#unvar tm_keepval GroupAlias;#class 0} "Assists|Friends"
#KEY F1 {#var ffocus @friend1 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend1}} "Assists|Friends"
#KEY F10 {#var ffocus @friend10 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend10}} "Assists|Friends"
#KEY F11 {#var ffocus @friend11 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend11}} "Assists|Friends"
#KEY F12 {#var ffocus @friend12 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend12}} "Assists|Friends"
#KEY F2 {#var ffocus @friend2 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend2}} "Assists|Friends"
#KEY F3 {#var ffocus @friend3 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend3}} "Assists|Friends"
#KEY F4 {#var ffocus @friend4 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend4}} "Assists|Friends"
#KEY F5 {#var ffocus @friend5 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend5}} "Assists|Friends"
#KEY F6 {#var ffocus @friend6 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend6}} "Assists|Friends"
#KEY F7 {#var ffocus @friend7 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend7}} "Assists|Friends"
#KEY F8 {#var ffocus @friend8 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend8}} "Assists|Friends"
#KEY F9 {#var ffocus @friend9 {_nodef} {Shared};#if (@akapref.sh_focus == 1) {#sh "Focus: "@friend8}} "Assists|Friends"


The following is for group and player alias control, it also has the db akapref which wont print F-Keys in it's current lock=1 value:

Code:
#ALIAS LDD {#class Assists|GroupAlias;#if (!%null( %1)) {#if (%lower( %1) == "no") {#var leader "";#sh {leader removed.};#co seagreen;#if (@akapref.lock == 0) {#T+ Friends;NUM}} {#var leader %proper( %1);#sh {@leader is Leader};#co seagreen;#if (@akapref.lock == 0) {#T+ Friends;NUM}}} {#if (%null( @lastsel)) {#sh {insufficient data};#co coral} {#var leader @lastsel;#sh {@leader is Leader};#co seagreen;#if (@akapref.lock == 0) {#T+ Friends;NUM}}};#class 0} "Assists"
#ALIAS NIXDIR {#sh " ";#sh DELETE GROUPALIAS FOLDER?;#co firebrick;#sh DELETE GROUPALIAS FOLDER?;#co coral;#IF (%yesno( "Do You Really Want to Delete the Folder?")) {#DELCLASS Assists|GroupAlias;#sh Deleted.;#co lightseagreen;#sh " ";#if (@akapref.display > 1) {#stw {""} {Shared} {TMSTWin}}} {#sh Cancel;#co coral}} "Assists"
#ALIAS NIXI {#class Assists|GroupAlias;#if (%1) {#loopdb @akadb {#if (%Proper( %1) == %val) {#var id_nix %concat( %key, "|", %val)};#if (%ismember( %proper( %1), @id_nix)) {#sh {To Delete: %upper( %item( @id_nix, 1)) for assist %proper( %item( @id_nix, 2))};#co coral;#IF (%yesno( "Do you want to delete the displayed alias and tab?")) {#unal %item( @id_nix, 1) GroupAlias;#untab %item( @id_nix, 2) GroupAlias;#delkey akadb %item( @id_nix, 1);#if (@akapref.lock == 0) {#sh {%item( @id_nix, 1) and tab deleted. Update NUM}} {#sh {%item( @id_nix, 1) and tab deleted.}};#unvar id_nix GroupAlias} {#sh canceled;#co coral}}}} {#if (%numitems( @id_nix) == 2) {#sh {To Delete: %item( @id_nix, 1) for assist %proper( %item( @id_nix, 2))};#co coral;#IF (%yesno( "Do you want to delete the displayed alias and tab?")) {#unal %item( @id_nix, 1) GroupAlias;#untab %item( @id_nix, 2) GroupAlias;#delkey akadb %item( @id_nix, 1);#if (@akapref.lock == 0) {#sh {%item( @id_nix, 1) and tab deleted. Update NUM}} {#sh {%item( @id_nix, 1) and tab deleted.}};#unvar id_nix GroupAlias} {#sh canceled;#co coral}} {#sh insufficient data;#co coral}};#Class 0} "Assists"
#ALIAS POP {#class Assists|GroupAlias;#if (!%null( %2)) {#var keepsel %trim( %2) {_nodef} {GroupAlias}};#if (%null( @keepsel)) {#if (!%null( %1)) {#var keepsel %trim( %1);#var cksela %left( @keepsel, %db( @akapref, length))}} {#if (!%null( %1)) {#var cksela %trim( %1)} {#var cksela %left( @keepsel, %db( @akapref, length))}};#if (%null( @keepsel)) {#sh {The ~Pop alias recorder uses inputs or the player name from the speed menu. ~GroupOptions for help};#co orange} {#var keepsel %proper( @keepsel);#var cksela %upper( @cksela);#if (%defined( @cksela)) {#sh " ";#if (%iskey( @akadb, @cksela)) {#sh {Failed. @cksela defined. Used for player %db( @akadb, @cksela)};#co firebrick;#var id_nix %concat( @cksela, "|", %db( @akadb, @cksela))} {#sh {Failed. @cksela defined. Not a player alias.};#co firebrick};#if (%db( @akapref, prompt) == 1) {#sh {Prompting for '%db( @akapref, action) @keepsel'. Cancel to remove @cksela as '%db( @akapref, action) %db( @akadb, @cksela)'};#co orange;#prompt prsela "Alias Name For Assist Player?"};#if (!%null( @prsela)) {#var prsela %upper( @prsela);#if (!%defined( @prsela)) {#EXEC {%concat( "#ALIAS ", @prsela, " {#EXEC ", "%db( @akapref, action)", " ", @keepsel, "}")};#sh {New alias @prsela assigned as '%db( @akapref, action) @keepsel'};#co seagreen;#tab @keepsel;#addkey akadb @prsela @keepsel;#var lastsel @keepsel;#unvar id_nix {GroupAlias};#if (@akapref.lock == 0) {#T+ Friends;NUM}} {#sh x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x;#co darkslategray;#sh " ";#if (%iskey( @akadb, @prsela)) {#sh {Failed. @prsela defined. Used for player %db( @akadb, @prsela)};#co firebrick;#sh " ";#sh {NIXI will remove @prsela as '%db( @akapref, action) %db( @akadb, @prsela)'};#co orange;#var id_nix %concat( @prsela, "|", %db( @akadb, @prsela))} {#sh {Failed. @prsela defined. Not a player alias.};#co firebrick}}} {#sh " ";#sh {NIXI will remove @cksela as 'assist %db( @akadb, @cksela)'};#co orange}} {#EXEC {%concat( "#ALIAS ", @cksela, " {#EXEC ", "%db( @akapref, action)", " ", @keepsel, "}")};#sh {New alias @cksela assigned as '%db( @akapref, action) @keepsel'};#co seagreen;#tab @keepsel;#addkey akadb @cksela @keepsel;#var lastsel @keepsel;#unvar id_nix {GroupAlias};#if (@akapref.lock == 0) {#T+ Friends;NUM}}};#unvar prsela GroupAlias;#unvar cksela GroupAlias;#unvar keepsel {GroupAlias};#class 0} "Assists"
#ALIAS TKK {#class Assists|GroupAlias;#if (!%null( %1)) {#if (%lower( %1) == "no") {#var tank "";#sh {Tank removed.};#co seagreen;#if (@akapref.lock == 0) {#T+ Friends;NUM}} {#var tank %proper( %1);#sh {@tank is Tank};#co seagreen;#if (@akapref.lock == 0) {#T+ Friends;NUM}}} {#if (%null( @lastsel)) {#sh {insufficient data};#co coral} {#var tank @lastsel;#sh {@tank is Tank};#co seagreen;#if (@akapref.lock == 0) {#T+ Friends;NUM}}};#class 0} "Assists"
#VAR akapref {prompt1length2actionassistlock1display3fkeymax5sh_focus1} {_nodef} "Assists"


EDIT:

The POP alias also uses a variable called keepsel. I should add this menu item. You can right click on player names to make alias.

Code:
#MENU {POP alias %selword} {#class Assists|GroupAlias;#var keepsel %selword;PopUp;#class 0} "Assists"
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Tue Feb 17, 2009 6:03 pm   
 
Some of these functions needed a command line db set which I was reluctant to workaround early on. My interpretation of command line vs. settings input variables became a little strident due to differences I found.

I named this alias SETS.

Use: SETS --- display all keys and vals
Use: SETS [key] [val] --- eg. SETS lock 0 - unlocks (automates) the enumeration

Code:
#sh " "
#if (%1) {
  #if (!%null( %1)) {
    #if (%iskey( @akapref, %1)) {
      #addkey akapref %1 "%-2"
      #sh Key %1 set to %db( @akapref, %1)
      #co seagreen
      } {
      #sh Key not found.
      #co firebrick
      }
    } {
    #sh " "Values of akapref quoted here for convenience.
    #co coral
    #sh "-------------------------------------------------"
    #co coral
    #loopdb @akapref {
      #sh %format( "   &-12s &-6s", %key, %string( %val))
      #co coral
      }
    }
  } {
  #sh " "Values of akapref quoted here for convenience.
  #co coral
  #sh "-------------------------------------------------"
  #co coral
  #loopdb @akapref {
    #sh %format( "   &-12s &-6s", %key, %string( %val))
    #co coral
    }
  }
#sh " "



Code:
#ALIAS SETS {#sh " ";#if (%1) {#if (!%null( %1)) {#if (%iskey( @akapref, %1)) {#addkey akapref %1 "%-2";#sh Key %1 set to %db( @akapref, %1);#co seagreen} {#sh Key not found.;#co firebrick}} {#sh " "Values of akapref quoted here for convenience.;#co coral;#sh "-------------------------------------------------";#co coral;#loopdb @akapref {#sh %format( "   &-12s &-6s", %key, %string( %val));#co coral}}} {#sh " "Values of akapref quoted here for convenience.;#co coral;#sh "-------------------------------------------------";#co coral;#loopdb @akapref {#sh %format( "   &-12s &-6s", %key, %string( %val));#co coral}};#sh " "} "Assists"


EDIT: found "%-2" was more universal then %2
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net