Author Topic: ENs - "Snippets of Code" - 35+ subs.  (Read 47683 times)

0 Members and 1 Guest are viewing this topic.

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
ENs - "Snippets of Code" - 35+ subs.
« on: August 28, 2009, 05:13:59 AM »
+1
Endless Nights Code Snippet Library

All Code in this thread is posted without any license, warranty, etc etc .  Do with it as you will, copy paste modify etc etc.

Be super nice if you posted a credit note.  Inspired by, Using ENS ?? , etc, etc .. not neccessary but nice.   Would be even nicer if you posted any  sweet addons or changes you made Here... Credits will be posted if used.

Enjoy but please dont post in this thread it will only get deleted.  If you wish to post a thank you note, comment, hatemail, review, notes, updates or anything else with reguards to these subs or EN in general please post it here..   


LIST of Subs in this thread in order of posting
CLIENT SWAPPING
FINDING NEW MACROS
Find and Enter An Ant Hole
FIND ANT QUEEN
NEW TARGET SYSTEM ON /OFF
QUEST ITEM TOGGLING
Drop Item on the Ground Around you  (non stacking)
Plants  - Unlock Decorative plants and pickup plant from the ground
Generic Pickup Item/ Type From the ground
COUNT ITEMS IN YOUR BACKPACK/ANY BAG
String Formatting
JOURNAL STRINGS
HIT TRAINING DUMMY
ANTI-IDLE SUB
GENERIC MOVE ITEM/S TO CONTAINER
ENs Siege Perilous ROT TIMER Sub
Ens Hide
ENs Event Macro Gump Open
ENs Get Formatted Date Time
ENs GumpClick
CalculateOverLoadWeight
ENs PadWithSpaces
ENs Type A String
ENs Make a string with spaces
ENs SetVar To String With Spaces
ENs Fill Pitchers From Water Trough
ENs Open Bag / Containor
ENs GetITemWeight
ENs CastSpellOn
ENs FindBag
ENs USeSalvageBag
ENs MoveToContainor
ENs_TrimLeadingAndTrailingSpaces
ENs_DeleteString
Auto Mount When Dismounted Script
ENs -EasyDressing - Equip and Unequip Items from paperdoll
ENs - Load and save data to a file
ENs_FindClosestType
ENs_ReplaceString
save load vars to/from file
ENs_8x8Calculator
ENs_RandomWait
ENs_WhereAmI
ENs_WhatFacetAmIOn
ENs_WhatLandMassAmIOn
ENs_WhereIsThis
« Last Edit: February 12, 2020, 08:23:32 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #1 on: September 01, 2009, 06:54:40 AM »
+1
CLIENT SWAPPING

This is the simple but effective sub ive always used for Swapping clients.  (This way you can have more than 2 open and it will still find the rigth client.  Its Pretty fun stuff

Code: [Select]
Sub SwapTo  ; CharID
 While #Charid <> %1
   {
   UOXL Swap
   wait 10
   }
Return

And heres a bit of code to set the Characters.. all ripped from my justice rezzor (its lacking Type checks so if you pick a box as your char it will accept it :) )
Code: [Select]
Gosub GetChar Red
set %Red #Result
Gosub GetChar Blue
set %BLue #Result

gosub SwapTo %Blue
halt

Sub GetChar
  display OK Target your %1 Character now
  set #targCurs 1
  while #targCurs = 1
    wait 0
Return #ltargetID
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #2 on: October 02, 2009, 08:18:12 AM »
+1
FINDING NEW MACROS

IF Skill... look at macro list and find last known number used for a macros.. then scan numbers following until you find it.


If spell .. do simular heres some code to help out

Code: [Select]
; Find Spell Macros
set %X 600   ; Set x to some starting number
set %xend    ; set ending number
Repeat
  setuotitle %x
  Event macro 15  %x
  wait 1
  If A in #charStatus
     {
     display ok Got a spell: %x
     wait 10
     }
  set %x %x + 1
Until %x = %Xend
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #3 on: October 16, 2009, 04:54:24 PM »
+1
Find and Enter An Ant Hole

When next to an anthole --> gosub Ens_EnterAntHole

Code: [Select]
Sub ENs_EnterAntHole
   set !oldCharposx #CharPosX
   set !OldCharPosy #CharPosY
   set !EnterHoleTries 5
   If %Antholetypes = N/A
      set %AntHoleTypes PUI_SUI_RVB
   Finditem %AntHoleTypes G_3
   If #Findcnt >= 1
     {
     set #lObjectID #findid
     Repeat
       set !EnterHoleTries !EnterHoleTries - 1
       event Macro 17 0
       Wait 4
     Until #charposx <> !Oldcharposx || #Charposy <> !oldCharposy || !EnterHoleTries <= 0
     }
Return ( #charposx <> !Oldcharposx || #Charposy <> !oldCharposy  )
« Last Edit: October 16, 2009, 04:57:05 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #4 on: October 16, 2009, 09:09:28 PM »
+1
FIND ANT QUEEN

Starting in lower Rigth corner .. this will run around until it finds the queen

Code: [Select]
gosub ENs_findAntQueen
halt

sub ENs_FindAntQueen
  If %QueenLoopValueMax = N/A
    gosub SetupQueenLoopValues
  set !queenfound #False
  set !Loopvalue 0
  repeat
    gosub queenmove !loopvalue
    gosub findqueen
  until #result   ; queen found
  wait 5
Return

sub FindQueen
  set #result #false
  finditem OHB G_7
  If #Findcnt > 0
    {
    set !exit 15
    Repeat
      finditem OHB G_7
      Event Pathfind #findx #findy #findz  ; the queen
      wait 1
      set !exit !exit -1
      finditem OHB G_2
    Until !exit < 1 || #findcnt > 0
    set #result #findcnt > 0
    }
Return #Result

Sub QueenMove
    set !x %QueenLoopValuex . %1
    set !y %QueenLoopValuey . %1
    set !z %QueenLoopValuez . %1
    set !Exit 20
    Repeat
      set !Exit !exit - 1
      event pathfind !x !y !z
      wait 1
    Until ( #Charposx = !x && #charposy = !y ) || !exit < 1
    set !loopvalue !loopValue + 1
    If !loopvalue >= %QueenLoopValueMAx
      set !LoopValue 1
REturn

sub SetupQueenLoopValues
  gosub AddQueenloopvalue 5805 1908 3
  gosub AddQueenloopvalue 5803 1896 2
  gosub AddQueenloopvalue 5796 1889 2
  gosub AddQueenloopvalue 5788 1881 2
  gosub AddQueenloopvalue 5779 1872 0
  gosub AddQueenloopvalue 5770 1872 1
  gosub AddQueenloopvalue 5761 1876 0
  gosub AddQueenloopvalue 5755 1885 0
  gosub AddQueenloopvalue 5752 1895 2
  gosub AddQueenloopvalue 5756 1905 2
  gosub AddQueenloopvalue 5759 1910 5
  gosub AddQueenloopvalue 5769 1919 1
  gosub AddQueenloopvalue 5776 1924 3
  gosub AddQueenloopvalue 5780 1931 1
  gosub AddQueenloopvalue 5788 1933 4
  gosub AddQueenloopvalue 5796 1925 2
  gosub AddQueenloopvalue 5805 1915 3
  gosub AddQueenloopvalue 5810 1918 1
  gosub AddQueenloopvalue 5806 1925 3
  gosub AddQueenloopvalue 5799 1930 2
  gosub AddQueenloopvalue 5794 1926 4
  gosub AddQueenloopvalue 5797 1918 3
  gosub AddQueenloopvalue 5790 1913 3
  gosub AddQueenloopvalue 5781 1907 2
  gosub AddQueenloopvalue 5772 1904 1
  gosub AddQueenloopvalue 5764 1897 3
  gosub AddQueenloopvalue 5769 1889 1
  gosub AddQueenloopvalue 5775 1887 4
  gosub AddQueenloopvalue 5782 1894 1
  gosub AddQueenloopvalue 5777 1899 20
  gosub AddQueenloopvalue 5784 1900 0
  gosub AddQueenloopvalue 5789 1906 0
  gosub AddQueenloopvalue 5795 1912 4
  gosub AddQueenloopvalue 5801 1918 2
  gosub AddQueenloopvalue 5803 1916 5
  gosub AddQueenloopvalue 5807 1911 3
Return

sub AddQueenLoopValue
  if %QueenLoopValueMAx = N/A
     set %QueenLoopValueMax 0
  set %QueenLoopValueMAx %QueenLoopValueMax + 1
  set %QueenLoopValuex . %QueenLoopValueMax   %1
  set %QueenLoopValuey . %QueenLoopValueMax   %2
  set %QueenLoopValuez . %QueenLoopValueMax   %3
Return

« Last Edit: October 16, 2009, 10:42:53 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #5 on: December 09, 2009, 10:02:39 AM »
+1
NEW TARGET SYSTEM ON /OFF

Below allows you to set it on or off and has inbult timeouts so if the client hangs or other the code doesnt get stuck.  Returns if it was succesfful in setting the desired on /off status

Code: [Select]
sub Ens_SetNewTargetSystem
  ; %1-On/off  %2-MaxAttampts %3-Waittime
  ; If nothing passed Default ON 6 20
  set !Status ON
  set !MaxAttempts 6
  set !MaxWaitTime 8
  If %0 > 0 && %1 <> N/A
     set !Status %1
  If %0 >= 2 && %2 <> N/A
    set !MaxAttempts %2
  If %0 >= 3 && %3 <> N/A
    set !MaxWaitTime %3
  set !StatusNo OFF
  If !status = OFF
     set !StatusNO ON
  set !YESString  New_Targeting_System_ , !Status
  set !NOString  New_Targeting_System_ , !StatusNo

  set !TargetOn #false
  repeat
    set !MaxAttempts !MaxAttempts - 1
    set !JOurnalOn #jindex + 1
    event macro 56
    set !Waittime !MaxWaitTime
    Repeat
      wait 1
      set !WaitTime !WaitTime - 1
      while #jindex >= !JournalOn
         {
         scanJournal !JOurnalOn
         IF !YESString = #journal
            set !Targeton #true
         IF !NOString = #journal
            set !Targeton #False
         set !JOurnalOn !JOurnalOn + 1
         }
    Until !WaitTime <= 0 || !TargetOn
  until !TargetOn  || !MaxAttempts <= 0
Return !TargetOn
« Last Edit: December 09, 2009, 10:06:09 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #6 on: December 09, 2009, 10:03:29 AM »
+1
QUEST ITEM TOGGLING

How to Make an item a quest item

Code: [Select]
set %ToggleQuestITemMenuLocation 6
gosub ENs_ToggleQuestITem   <item id>

Sub ENs_ToggleQuestITem ; %1
  exevent popup #charid
  wait 10
  set %Clicky 18 * %ToggleQuestITemMenuLocation
  set %Clicky %clicky + 2
  click 66 %clicky
  wait 10
  set #ltargetid %1
  set #ltargetkind 1
  event macro 22 0
  wait 10
  Key ESC   ; cancel toggle
  wait 10
Return

This only targets 1 item but you could mod it to target as many as you want.  TM has an additional sophistication in his script that READS the context menu to determine the postion of the Toggle Questitem selection.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #7 on: January 15, 2010, 07:44:58 PM »
+1
Drop Item on the Ground Around you  (non stacking)

Returns true or false for success or fail.  trys every spot around your character

Code: [Select]
Sub ENs_DropOnGround ; %itemid %BagFrom %DropRadius
  set %Item %1
  IF %0 <= 1
    set %2
  set %BagFrom %2
  IF %0 <= 2
    set %3 2
  set %DropRadius %3
 
  Set %XPos ( #CharPosX - %DropRadius )
  Set %YPos ( #CharPosY - %DropRadius )
  Set %DropExit #False
  Repeat
    wait 10
    FindItem %item C_ , %BagFrom
    wait 3
    If #FindKind = -1
      Set %DropExit #True
    IF %DropExit = #False
      {
      ;event ExMsg #charID 3 0 trying %xpos %ypos
      ExEvent Drag #findid #Findstack
      Wait 12
      ExEvent DropG %Xpos %YPos
   
      ; Increment Position
      Set %XPos ( %XPos + 1 )
      If %Xpos > ( #CharPosX + %DropRadius )
        {
        Set %YPos ( %YPos + 1 )
        Set %XPos ( #CharPosX - %DropRadius )
        }
      }
  Until %DropExit || %YPos > ( #CharPosY + %DropRadius )
Return %DropExit
« Last Edit: January 24, 2010, 10:29:34 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #8 on: January 16, 2010, 06:29:02 AM »
+1
Plants  - Unlock Decorative plants and pickup plant from the ground

Code: [Select]
set %MySecureID #backpackid   ; Setit

set %plantTypes OLI_BCF_VWE_BWE_UAF_JWE_IWE_EXE_UWE_ICF_BXE_YVE_CCF_NWE_MWE_DXE_TCF_NXE_BKP_ZJP_MKP_AKP_CKP_OKP_NKP_LKP_TXE_ZBF_AIF_GWE_VWE_WTE_ZBF_BWE_BCF_CCF_SVE_IWE_MWE_YVE_REK_QVE_BFK_WTE_FWE_NXE_CYE_JDF_

Finditem %Planttypes g_2
If #findcnt > 0
  {
  For #findindex 1 #findcnt
     {
      event property #findid
      wait 5   ; wiat for property to be set
      if  Decorative in #property
             {
              msg i wish to unlock this $
              target 3s
              set #ltargetid #findid
              event macro 22 0
              wait 5
             exevent drag #findid
             exevent dropc %Mysecureid
             wait 20
              }
     }
  }
« Last Edit: January 19, 2010, 04:52:21 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #9 on: January 16, 2010, 06:34:15 AM »
+1
Generic Pickup Item/ Type From the ground

Returns the count of items dragged.

Code: [Select]
Gosub En_PickupfromGround  %DaggerType 2 #backpackid
Code: [Select]
Sub En_Pickupfromground ; %1-item/type %2-radius %3-put in bag  %4 - optional drop delay (defaults 20)
  If %0 < 4
      set %4 20
  finditem %1 G_ , %2
  If #findcnt > 0
      {
       for #findindex 1 #findcnt
            {
            exevent drag #findid
            exevent drop %3
            wait %4
            }
      }
Return #findcnt
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
« Reply #10 on: February 08, 2010, 09:51:49 AM »
+1
COUNT ITEMS IN YOUR BACKPACK/ANY BAG

The easist and fastest way to get the exact number of items in your backpack and subpacks is to left UO do the work.
If you open your paperdoll and move mouse over the packpack you will notice that the property of your backpack contains this information all you have to do is extract it via string commands.

Below is a sub that Should work for anypack, Just pass the pack id to the sub the item count is returned in #Result.
Code: [Select]
gosub ENs_GetPackItemCount #BackPackID
display ok You have #result items in that Pack
halt

Code: [Select]
Sub ENs_GetPackItemCount  ; %1 ID Of Pack.
  event property %1
  str Pos #property contents:   1
  set %leftChar #strRes + 10
  str Pos #property /125 1
  set %CharCount #strRes - %LeftChar
  str Mid #Property %leftChar %Charcount
Return #strres
« Last Edit: February 08, 2010, 09:55:56 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #11 on: February 19, 2010, 06:02:10 AM »
+1
String Formatting

Adds spaces either to left of right of string to make string = Lenght

Code: [Select]
Sub ENs_PadWithSpaces ; %1=LEFT/RIGHT %2= finshed string LENGHT
  str len %3
  Set !Add %2 - #strres
  If !Add > 0
    For !Count 1 !Add
       {
        If %1 = LEFT
          set %3  #spc , %3
        ELSE
          SET %3 %3 , #SPC
       }
Return %3



Below Sub makes a string with spaces..  ie pass: this is a test ..  you will get returned a string 'this is a test'

Code: [Select]
sub ENs_MakeStringWithSpaces
  If %0 > 0 && %0 <> N/A
    {
    Set !FormatResult
    For !Count 1 %0
      Set !FormatResult !FormatResult , #spc , % . !Count
    }
return !FormatResult
« Last Edit: September 11, 2010, 06:19:14 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #12 on: September 11, 2010, 06:18:19 PM »
+1
JOURNAL STRINGS

Below sub will convert a regular string 'this is a test' into journal format 'this_is_a_test'

Code: [Select]
sub ENs_MakeJournalString
  While #Spc in %1
    {
    str Pos %1 #spc
    set %Pos #strres
    str del %1 %Pos 1
    str Ins #StrRes _ %pos
    set %1 #StrRes
    }
Return %1

Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #13 on: September 20, 2010, 05:26:14 PM »
+1
HIT TRAINING DUMMY

Sometimes i find really old chars that have min strenght .. i think from when i was testing advanced features of my character toolbox script... anyways instead of deleting char and starting over .. its easy enough to use a training dummy.

Code: [Select]
repeat
  gosub hitdummy
  wait 10
until #str = 20
halt

sub hitdummy
   finditem SDG G_1
   IF #findcnt > 0
      {
      set #lobject #findid
      event macro 17 0
      wait 1
      }
return
« Last Edit: September 23, 2010, 07:01:11 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #14 on: September 23, 2010, 04:38:50 AM »
+1
ANTI-IDLE SUB

A sub that will stop you from timing out.  Either pass random or 1-7, the sub will activate after being called >333 times
1= turn , and turn back
2= attempt to hide
3= Toggle war then peace or peace then war
4= open close chat
5= Bow
6= Salute
7= OpenBackpack
Random = Randomly selected 1-7

Code: [Select]
;===========================================
; ~~ Anti Idle Subs
;===========================================
Sub ENs_AntiIdle  ; %1 = 1-7 or Random
  If %ENs_Idletime = N/A
     Set %ENs_Idletime 0
  set %ENs_idletime %ENs_Idletime + 1
  If %ENs_idletime < 333
     Return
  set %ENs_idletime 0
  If %1 = Random || %1 = N/A
      Set %1  ( ( #random % 69 ) / 10 ) + 1
  set %AntiIdleType %1
  If %AntiIdleType = 1  ; Turn
    {
     If #CHARDIR = 7
       {
       event Macro 5 4
       wait 1s
       }
     event Macro 5 0
     wait 1s
     event Macro 5 4
     wait 1s
    }
  If %AntiIdleType = 2  ; Hide
    {
    event macro 13 21 ; Hiding
    wait 12s
    }
  If %AntiIdleType = 3  ; War & Peace
    {
     event Macro 6 0
     wait 1s
     event Macro 6 0
     wait 1s
    }
  If %AntiIdleType = 4  ; OpenClose Chat
    {
     event Macro 8 6
     wait 1s
     event macro 9 6
     wait 1s
    }
  If %AntiIdleType = 5  ; Bow
    {
     event Macro 18 0
     wait 1s
    }
  If %AntiIdleType = 6  ; Salute
    {
     event Macro 19 0
     wait 1s
    }
  If %AntiIdleType = 7  ; Open Backpack
    {
     event Macro 8 7
     wait 1s
    }

;  If %AntiIdleType = NEVERCALLED  ; InvokeVirtue
;    {
;     event macro 49 1 ; Invoke Honor Virtue
;     event macro 49 2 ; Invoke Sacrifice Virtue
;     event macro 49 3 ; Invoke Valor Virtue
;     wait 1s
;    }
Return
« Last Edit: September 23, 2010, 04:46:09 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Tags: