Kisa Flexible Lists

From Tenebrae
Revision as of 00:52, 16 December 2017 by Kisaiya (talk | contribs)
Jump to navigation Jump to search

This code was designed because I (Kisaiya) am terrible at keeping track of what items I need to buy for my character(s). So, I wrote a code to keep it all organized! You can use this though, for lists of any type!

Big thanks to Whiteout for the hep with the code!

Examples

Quick References

+mynotes
Kisaiya's Ability Notes! 
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|# |ABILITY             |NOTES                                               |
|1 |Ability 1           |Notes notes notes notes                             |
|2 |Ability 2           |Notes notes notes notes                             |
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-

Shopping List

+shop
Kisaiya's Shopping List! 
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|# |Item                                     |Price          |Crafter        |
|1 |Item 1-----------------------------------|1234 gp--------|Test-----------|
|2 |Item 2-----------------------------------|1234 gp--------|Test-----------|
|3 |Item 5-----------------------------------|1234 gp--------|---------------|
|4 |Item 4-----------------------------------|1234 gp--------|Test-----------|
|5 |Item 3-----------------------------------|1234 gp--------|---------------|
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
 


The Help Files

-=--=--=--=--=--=--=--=--=--=--=- Shop Help --=--=--=--=--=--=--=--=--=--=--=-
Usage: 
        View your list:         +shop
        This help file:         +shop/help
        Adds an item:           +shop/add <item>=<cost>=<maker> 
                                 (Can leave <maker> blank) Ex.: +sh/a bow=30=
        Removes an Item:        +shop/rem <item #>
        Edits an item:          +shop/edit <item #>=Item, Cost, or Maker=<edit>
                                  Ex.: +shop/edit 1=item=Bow of Awesome
        Moves an Item:          +shop/move <item #>=<new item #>
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
-=--=--=--=--=--=--=--=--=--=--=- Notes Help -=--=--=--=--=--=--=--=--=--=--=-
Usage: 
        View your notes:        +mynotes
        This help file:         +mynotes/help
        Adds a note:            +mynotes/add <ability>=<note> 
        Removes a note:         +mynotes/rem <note #>
        Edits a note:           +mynotes/edit <note #>=Ability or Note=<edit>
                                  Ex.: +mynotes/edit 1=note=It's Amazing!
        Moves a Note:           +mynote/move <note #>=<new note #>
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-

Installation

@create MyLists
@parent MyLists=#3166

DONE! That's it! You can look at the object you created for the help, or type +mynotes/help and +shop/help. Also, there are shortened versions of the commands, such as +sh/? and +myn/?.


For Those Interested in Code

Below is the code I used to create the parent object so far. I can't promise it's perfectly up to date, but it's at least where I started.

&DO_SHOPVIEW #3166=$^\+(shop|sho|sh)$:@pemit %#=[switch(0,words(setr(l,v(V_SHOPPINGLIST)),|),You haven't made your list yet! Type +shop/help to see the commands.,%r%xh[name(%#)]'s Shopping List!%xn %r%xb[repeat(-=-,26)]%r\|%xh%xw[ljust(#,2)]%xn\|%xh%xw[ljust(Item,41)]%xn\|%xh%xw[ljust(Price,15)]%xn\|%xh%xw[ljust(Crafter,15)]%xn%xb\|%r\|[iter(%ql,[ljust(%xh%xw[inum(0)]%xn,2)]\|[ljust(%xh%xw[elements(itext(0),1,@)]%xn,41,%xb-)]\|[ljust(%xh%xw[elements(itext(0),2,@)]%xn,15,%xb-)]\|[ljust(%xh%xw[elements(itext(0),3,@)]%xn,15,%xb-)]%xb\|,|,%xn%xb%r\|)]%r%xn%xb[repeat(-=-,26)]%xn)]
&DO_SHOPADD #3166=$^\+(shop|sho|sh)/(add|ad|a) (.+)=(.+)=(.+|)$:@pemit %#=[switch(0,[lte([inc(words(setr(1,v(V_SHOPPINGLIST)),|))],50)],You already have 50 entries please remove one before adding one.,[lte([strlen(trim(strip(%3)))],41)],Your item is [sub([strlen(trim(strip(%3)))],41)] characters too long.,[lte([strlen(trim(strip(%4)))],15)],Your price is [sub([strlen(trim(strip(%4)))],15)] characters too long.,[lte([strlen(trim(strip(%5)))],15)],Your crafter name is [sub([strlen(trim(strip(%5)))],15)] characters too long.,You add item %xh%3%xn for price %xh%4%xn by crafter %xh%5%xn to your list as item #%xh[inc(words(%q1,|))]%xn.[set(me,V_SHOPPINGLIST:[trim(squish(%q1|%3@%4@%5,|),,|)])])]
&DO_SHOPHELP #3166=$^\+(shop|sho|sh)/(help|hel|he|h|\?)$:@pemit %#=[center([ansi(hw,%bShop Help%b)],78,[ansi(b,-=-)])]%r[ansi(hc,Usage:)] %r%tView your list: %t[ansi(hw,+shop)]%r%tThis help file: %t[ansi(hw,+shop/help)]%r%tAdds an item: %t%t[ansi(hw,+shop/add \<item\>\=\<cost\>\=\<maker\>)] %r%t%t%t%t%b(Can leave \<maker\> blank) Ex.: +sh/a bow=30=%r%tRemoves an Item: %t[ansi(hw,+shop/rem \<item \#\>)]%r%tEdits an item: %t%t[ansi(hw,+shop/edit \<item \#\>\=Item\, Cost\, or Maker\=\<edit\>)]%r%t%t%t%t%b Ex.: +shop/edit 1=item=Bow of Awesome%r[ansi(b,[repeat(-=-,26)])]
&DO_SHOPREM #3166=$^\+(shop|sho|sh)/(remove|rem|re|rm|r) (.+)$:@pemit %#=[switch(0,isint(%3),It needs to be a integer.,and([lt(%3,[inc(words(setr(l,v(V_SHOPPINGLIST)),|))])],gt(%3,0)),That item number is invalid.,You are removing item #%3 from your list which is: %r[setq(l,v(V_SHOPPINGLIST))]%xh[elements([elements(%ql,%3,|)],1,@)]%xn for %xh[elements([elements(%ql,%3,|)],2,@)]%xn by %xh[elements([elements(%ql,%3,|)],3,@)]%xn.[set(me,V_SHOPPINGLIST:[remove(%ql,[elements(%ql,%3,|)],|)])])]
&DO_SHOPEDIT #3166=$^\+(shop|sho|sh)/(edit|edi|ed|e|et) (.+)=(.+)=(.+|)$:@pemit %#=[switch(0,isint(%3),Your item number needs to be a integer.,and([lt(%3,[inc(words(setr(l,v(V_SHOPPINGLIST)),|))])],gt(%3,0)),You do not have a #%xh%3%xn.,[switch(1,strmatch(%4,i*),and(0,[setr(m,1)],setr(n,item)),[switch(1,strmatch(%4,co*),1,strmatch(%4,$),1,strmatch(%4,g*),1,strmatch(%4,p*),1,0)],and(0,[setr(m,2)],setr(n,price)),[switch(1,strmatch(%4,m*),1,strmatch(%4,cr*),1,0)],and(0,[setr(m,3)],setr(n,crafter)),2)],[set(me,V_SHOPPINGLIST:[trim(squish([replace(%ql,%3,[replace(elements(%ql,%3,|),%qm,%5,@)],|)],|))])]You've changed the %qn for item #%xh%3%xn to %xh%5%xn.,I'm sorry. You tried to change #%xh%3's %4%xn which isn't a valid selection. Please choose %xhitem%xn\, %xhcost%xn\, or %xhmaker%xn to edit.)]

@set #3166/DO_SHOPVIEW=regexp
@set #3166/DO_SHOPADD=regexp
@set #3166/DO_SHOPREM=regexp
@set #3166/DO_SHOPHELP=regexp
@set #3166/DO_SHOPEDIT=regexp

&DO_ABILVIEW #3166=$^\+(mynotes|mynote|mynot|myno|myn)$:@pemit %#=[switch(0,words(setr(l,v(V_ABILLIST)),|),You haven't made any notes yet! Type +mynotes/help to see the commands,%r%xh[name(%#)]'s Ability Notes!%xn %r%xb[repeat(-=-,26)]%r\|%xh%xw[ljust(#,2)]%xn\|%xh%xw[ljust(ABILITY,20)]%xn\|%xh%xw[ljust(NOTES,52)]%xn%xb\|%r\|[iter(%ql,[ljust(%xh%xw[inum(0)]%xn,2)]\|[ljust(%xh%xw[elements(itext(0),1,@)]%xn,20)]\|[ljust(%xh%xw[elements(itext(0),2,@)]%xn,52)]%xb\|,|,%xn%xb%r\|)]%r%xn%xb[repeat(-=-,26)]%xn)]
&DO_ABILADD #3166=$^\+(mynotes|mynote|mynot|myno|myn)/(add|ad|a) (.+)=(.+)$:@pemit %#=[switch(0,[lte([inc(words(setr(1,v(V_ABILLIST)),|))],50)],You already have 50 entries please remove one before adding one.,[lte([strlen(trim(strip(%3)))],20)],Your ability is [sub([strlen(trim(strip(%3)))],20)] characters too long.,[lte([strlen(trim(strip(%4)))],52)],Your note is [sub([strlen(trim(strip(%4)))],52)] characters too long.,You added ability %xh%3%xn With the note: %xh%4%xn as #%xh[inc(words(%q1,|))]%xn.[set(me,V_ABILLIST:[trim(squish(%q1|%3@%4,|),,|)])])]
&DO_ABILHELP #3166=$^\+(mynotes|mynote|mynot|myno|myn)/(help|hel|he|h|\?)$:@pemit %#=[center([ansi(hw,%bNotes Help%b)],78,[ansi(b,-=-)])]%r[ansi(hc,Usage:)] %r%tView your notes: %t[ansi(hw,+mynotes)]%r%tThis help file: %t[ansi(hw,+mynotes/help)]%r%tAdds a note: %t%t[ansi(hw,+mynotes/add \<ability\>\=\<note\>)] %r%tRemoves a note: %t[ansi(hw,+mynotes/rem \<note \#\>)]%r%tEdits a note: %t%t[ansi(hw,+mynotes/edit \<note \#\>\=Ability or Note\=\<edit\>)]%r%t%t%t%t%b Ex.: +mynotes/edit 1=note=It's Amazing!%r[ansi(b,[repeat(-=-,26)])]
&DO_ABILREM #3166=$^\+(mynotes|mynote|mynot|myno|myn)/(remove|rem|re|rm|r) (.+)$:@pemit %#=[switch(0,isint(%3),It needs to be a integer.,and([lt(%3,[inc(words(setr(l,v(V_ABILLIST)),|))])],gt(%3,0)),That ability number is invalid.,You are removing item #%3 from your notes which is: %r%xh[elements([elements(%ql,%3,|)],1,@)]%xn with the note: %xh[elements([elements(%ql,%3,|)],2,@)]%xn[set(me,V_ABILLIST:[remove(%ql,[elements(%ql,%3,|)],|)])])]
&DO_ABILEDIT #3166=$^\+(mynotes|mynote|mynot|myno|myn)/(edit|edi|ed|e|et) (.+)=(.+)=(.+|)$:@pemit %#=[switch(0,isint(%3),Your item number needs to be a integer.,and([lt(%3,[inc(words(setr(l,v(V_ABILLIST)),|))])],gt(%3,0)),You do not have a #%xh%3%xn.,[switch(1,[switch(1,strmatch(%4,a*),1,strmatch(%4,s*),1,strmatch(%4,f*),1,strmatch(%4,i*),1,0)],and(0,[setr(m,1)],setr(n,ability name)),[switch(1,strmatch(%4,n*),1,strmatch(%4,c*),1,strmatch(%4,d*),1,0)],and(0,[setr(m,2)],setr(n,note)),2)],[set(me,V_ABILLIST:[trim(squish([replace(%ql,%3,[replace(elements(%ql,%3,|),%qm,%5,@)],|)],|))])]You've changed the %qn for ability #%xh%3%xn to: %xh%5%xn,I'm sorry. You tried to change #%xh%3's %4%xn which isn't a valid selection. Please choose %xhability%xn\, or %xhnote%xn to edit.)]

@set #3166/DO_ABILVIEW=regexp
@set #3166/DO_ABILADD=regexp
@set #3166/DO_ABILREM=regexp
@set #3166/DO_ABILHELP=regexp
@set #3166/DO_ABILEDIT=regexp