Author Topic: ENs - "Snippets of Code" - 35+ subs.  (Read 47656 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
Re: ENs - "Snippets of Code" - 25+ subs.
« Reply #30 on: April 30, 2011, 10:40:57 AM »
0
ENs Use Salvage Bag

Code: [Select]
gosub ENs_UseSalvageBag %SalvageBagID 1  ; popup option 1-3, 1=all, 2=ingots, 3=cloth
gosub ENs_UseSalvageBag %SalvageBagID     ; same as if 1 was passed

Code: [Select]
Sub ENs_UseSalvageBag ; Bagid Option= 1 2 3 if option not passed defaults as 1
  set !BagID %1
  set !Option %2
  if %0 = 1
     set !Option 1
  set !Escape 10
  Repeat
    exevent popup !BagId
    wait 5
    set !Escape !Escape - 1
  Until !Escape <= 0 || ( #Contname = Normal_gump && #ContSize = 106_78 )
  set !PopupContKind #ContKind
  If !Escape > 0
    {
    contpos 0 100
    wait 4
    set !x #contposx + 50
    set !y #contposy + ( !Option * 20 )
    set !Escape 5
    Repeat
      Click !x !Y DMC
      wait 3
      set !Escape !Escape - 1
    Until !Escape <= 0 || #Contkind <> !PopupContKind
    }
Return
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 - "Snippets of Code" - 25+ subs.
« Reply #31 on: August 18, 2011, 01:52:39 PM »
0
ENs MoveToContainor

Move ONE item or one stack of items to a container.

Code: [Select]
finditem POF G_2  ; find gold on ground radius 2
gosub ENs_MoveToContainor  #findid #Backpackid #findstack  ; move gold to backpack

Code: [Select]
Sub ENs_MoveToContainor ; 3/31/08 - %1 Item %2 Containor %3 stack %4 Wait (Optional, defaults to 12)
  set !DragDropWait %4
  if %0 < 4
    set !DragDropWait 12
  wait !DragDropWait
  ExEvent drag %1 %3
  ExEvent DropC %2
  wait !DragDropWait
Return
« Last Edit: August 18, 2011, 05:36:36 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 - "Snippets of Code" - 25+ subs.
« Reply #32 on: August 30, 2011, 07:30:06 PM »
0
ENs_TrimLeadingAndTrailingSpaces
Removes all leading and trailing spaces in a string .. ie '    this is a test    '  returns as 'this is a test'

Code: [Select]
event property <someitemID>
gosub ENs_TrimLeadingAndTrailingSpaces #property
display ok #result


Code: [Select]
sub ENs_TrimLeadingAndTrailingSpaces %1
  repeat ; Remove Leading
    Str Left %1 1
    set !Char #Strres
    if !Char = #Spc
       {
        str Len %1
        set !trim #Strres - 1
        str Right %1 !Trim
        set %1 #strres
        }
  until !Char <> #spc
 
  repeat ; Remove Trailing
    Str Right %1 1
    set !Char #Strres
    if !Char = #Spc
       {
        str Len %1
        set !trim #Strres - 1
        str Left %1 !Trim
        set %1 #strres
        }
  until !Char <> #spc
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 - "Snippets of Code" - 25+ subs.
« Reply #33 on: August 30, 2011, 07:32:05 PM »
0
ENs_DeleteString
Deletes all occurances of a string in another string  ie #spc 'this is a test'  returns 'thisisatest'

Code: [Select]
gosub  ENs_DeleteString  _ this_is_a_test   ; DeleteString OriginalString
display ok #Result   ; = thisisatest
gosub  ENs_DeleteString  test this_is_a_test
display ok #Result  ; = this_is_a_

Code: [Select]
sub ENs_DeleteString ; %1-delete %2 String
  str len %1
  set !Len #Strres
  While %1 in %2
    {
    str Pos %2 %1
    str del %2 #strres !Len
    set %2 #StrRes
    }
Return %2
« Last Edit: August 30, 2011, 07:33:49 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 - "Snippets of Code" - 25+ subs.
« Reply #34 on: August 31, 2011, 04:40:56 AM »
0
Auto Mount When Dismounted Script
Bit of dumb code that remounts you if your dismounted.

Code: [Select]
set %waittime 30
display ok Please Dismount
wait 30
display ok Please target your mount
set #targcurs 1
While #targcurs = 1
  wait 1
set %mount #ltargetid

set %ExitScript #False
repeat
  wait 2
  findItem %mount G
  if #findBagID <> #charID && #Findcnt > 0
    {
    msg All Follow Me $
    wait %Waittime
    set #lObjectID %mount
    event Macro 17
    wait 2s
    }
   while #Charghost = YES
     wait 1
Until %ExitScript = #true
halt
« Last Edit: September 01, 2011, 07:40:15 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 - "Snippets of Code" - 35+ subs.
« Reply #35 on: April 02, 2012, 08:56:34 AM »
0
ENs - Easy Dressing
Version 2.0

Easily unequip and reequip your paper-doll using the exevent equip 24 command.   Userful for if you die alot.   You may take apart the attached script and use the subs you require...


There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
ENs - EasyDressing.txt
« Last Edit: August 18, 2015, 05:17:18 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 - "Snippets of Code" - 35+ subs.
« Reply #36 on: November 19, 2012, 06:30:28 PM »
0
LOAD and Save data to a file  

; Example Code
Code: [Select]
goSub ENs_SetupCommandLine  ; initialize save/load enviroment
SET %TestVar 1
set %testvar2 test
set %Filename C:\easyuo\en-test.txt
display ok saveing a test value of %testvar - %testvar2
goSub ENs_ClearFile %filename
gosub ENs_SaveData %filename TestVar TestVar2
; ~~~~~~~~~~~~~~~~~~~
set %testvar 2
set %testvar2 boo
display ok resting testvalue to %testvar : %testvar2
; ~~~~~~~~~~~~~~~~~~~
gosub ENs_LoadData %fileName
display ok TestValue = %testvar : %testvar2 $ (should be 1 : test what was saved in file)
halt


; Subs
Code: [Select]
sub ENs_SaveData ; <%Filename> 1..z of <Varname to save without the % Sign>
  set !SDFileName %1
  set !SDBufferText
  set !SDFile  #spc , >> , #spc , !SDFileName
  set !SDAnd  #spc , && , #spc
  set !SDEcho Echo , #spc , Set , #spc
  set !SDVarName %2
  set !SdValue % . !SDVarName
  set !SDBufferText !SdEcho , %ENs_PercentSign , !SdVarName , #spc , !SDValue , !SDFile
  if %0 > 2
    {
    for !x 3 %0
      {
      set !SDVarName % . !x
      set !SdValue % . !SDVarName
      set !SDBufferText !SDBufferText , !SDAnd , !SDEcho , %ENs_PercentSign , !SdVarName , #spc , !SDValue , !SDFile
      }
    }
  if %ENs_Cmd = N/A
    gosub ENs_SetupCommandLine
  Execute %ENs_Cmd /c !SDBufferText
Return

sub ENs_LoadData ; %filename
  call %1
return

Sub ENs_ClearFile
  set !SDFileName %1
  if %ENs_Cmd = N/A
    gosub ENs_SetupCommandLine
  set !clOutput #SMC , #spc , ENs , #spc , Var , #spc , Save
  Execute %ENs_Cmd /c Echo !clOutput > !SDFileName
Return

Sub ENs_SetupCommandLine
  Set %ENs_Cmd cmd.exe
  Str Left #OSVer 1
  If #StrRes = 1
      Set %ENs_Cmd command.com
  If #StrRes = 2
      Set %ENs_Cmd cmd.exe
  set %ENs_PercentSign %
Return

« Last Edit: July 27, 2014, 07:33:36 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 - "Snippets of Code" - 25+ subs.
« Reply #37 on: January 21, 2013, 07:55:51 AM »
0
ENs Find Closest Type

Finds the closest item/monster player on the ground (pass the type list)


Code: [Select]
set %monster IS
gosub ENs_FindClosestType %Monster
display ok Closest monster id = #result
halt

Code: [Select]
sub ENs_FindClosestType
  set !dist 100000000
  set #result N/A
  findItem %1 G_20
  if #findcnt > 0
    {
    for #findindex 1 #findcnt
       {
        if #finddist < !dist
            {
            set !dist #finddist
            set #result #findid
            }
       }
    }
return #result
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 - "Snippets of Code" - 35+ subs.
« Reply #38 on: October 13, 2013, 06:00:41 AM »
0
ENs_ReplaceString

Searches Source string for occurrences of "ReplaceString", removes them and replaces with the contents of "WithString",

Code: [Select]
gosub ENs_ReplaceString  I___wish___these___were___a___single___space    ___    #spc
display ok #result

Code: [Select]
sub ENs_ReplaceString ; SourceString ReplaceString WithString
  str count %1 %2
  set %5 #strres
  Str len %2
  set %4 #strres
  While %5 > 0
    {
    str Pos %1 %2 %5
    set %6 #strres
    str del %1 %6 %4
    str Ins #StrRes %3 %6
    set %1 #StrRes
    set %5 %5 - 1
    }
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 - "Snippets of Code" - 35+ subs.
« Reply #39 on: April 05, 2015, 12:06:23 PM »
0
ENs_8x8Calculator

Maintains an array to determine if you have depleted the resource in that grid already.  Can be used for fishing, mining, lumberjacking or any other 8x8 resource.

How to use:  Upon starting at a new location RESET the grid, then when you located a resource spot check to see if the 8x8 grid that spot is in is already depleted  if not depleted, deplete it and add to the grid,  when you detect the next spot  check again continue until no more resource spots found.

Example pseudo code
Code: [Select]
goSub ENs_8x8Calculator RESET     ; Arrived at new location reset grid results
Repeat ; Starting resource gathering loop
    ; found a spot check it
    goSub  ENs_8x8Calculator %resoucex %resoucey
    IF #Result
       {  ; Area not depleted yet ... deplete the resource...
        If  %resource_depleted
             goSub  ENs_8x8Calculator %resoucex %resoucey ADD    ; add as depleted spot when resource depleted
        }
until <no more resouce spots found>

Code: [Select]
Sub ENs_8x8Calculator ; RESET OR  %x , %y OR %x %y ADD
  set #Result #False
  IF %1 = RESET || %EN_8x8ResourceSquare = N/A
     set %EN_8x8ResourceSquare
  If %0 >= 2 && %1 <> RESET
    {
    set !8x %1 / 8
    set !8y %2 / 8
    set !8x8pos _ , !8x , x , !8y
    set #Result !8x8pos notin %EN_8x8ResourceSquare
    IF %0 = 3 && %3 = ADD && #Result
      set %EN_8x8ResourceSquare %EN_8x8ResourceSquare , !8x8Pos
    }
Return #Result
« Last Edit: April 05, 2015, 12:08:49 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 - "Snippets of Code" - 35+ subs.
« Reply #40 on: April 09, 2015, 06:28:39 AM »
0
ENs_RandomWait

Wait a random amount of time between the min and max values passed.

Code: [Select]
gosub ENs_RandomWait  20 150
Code: [Select]
sub ENs_RandomWait  ; %1=Min wait,  %2=Max Wait in MS
   set !EN_Time %1 + ( #Random % ( %2 - %1 + 1 ) )
   wait !EN_Time
return
« Last Edit: April 09, 2015, 06:37:07 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 - "Snippets of Code" - 35+ subs.
« Reply #41 on: February 12, 2020, 08:27:37 AM »
+1
Dont know where you are in the world ...  ??   Maybe this will help.

Example Usage
Code: [Select]
gosub ENs_WhatFacetAmIOn
  display ok #result
gosub ENs_WhatLandMassAmIOn
  display ok #result
gosub ENs_WhereAmI
  display ok #result
halt

Helper Subs
Code: [Select]
sub ENs_WhereAmI
  gosub ENs_WhereIsThis #CURSKIND #CHARPOSX #CHARPOSY
  set #result %EN_Location_Facet , #spc , - , #spc , %EN_Location_LandMass
  set !Blank
  if %EN_Location_Landmass = !Blank
     set #result %EN_Location_Facet
return  #result

sub ENs_WhatFacetAmIOn
  gosub ENs_WhereIsThis
  set #result %EN_Location_Facet
return #result

sub ENs_WhatLandMassAmIOn
  gosub ENs_WhereIsThis
  set #result %EN_Location_LandMass
  set !Blank
  if #result = !Blank
    set #result %EN_Location_Facet
return #result

Main Sub
Code: [Select]
sub ENs_WhereIsThis  ; %1..3  curskind x y
  set !Facet %1
  set !x %2
  set !y %3
  if %0 = 0
    {
    set !Facet #CursKind
    set !x       #CharPosX
    set !y       #CharPosY
    }
  set %EN_Location_Facet
  set %EN_Location_LandMass
  if !Facet = 0
    {
    set %EN_Location_Facet    Felucca
    set %EN_Location_LandMass Britannia
    IF ( #CHARPOSX >= 5120  && #CHARPOSX <= 6143 ) && ( #CHARPOSY >= 2300 && #CHARPOSY <= 4095 )
        set %EN_Location_LandMass  T2A
    }
  if !Facet = 1
    {
    %EN_Location_Facet Trammel
    IF ( #CHARPOSX >= 5120  && #CHARPOSX <= 6143 ) && ( #CHARPOSY >= 2300 && #CHARPOSY <= 4095 )
        set %EN_Location_LandMass T2A
    }
  if !Facet = 2
    set %EN_Location_Facet Ilshenar
  if !Facet = 3
    set %EN_Location_Facet Malas
  if !Facet = 4
    set %EN_Location_Facet Tokuno
  if !Facet = 5
    {
    set %EN_Location_Facet  Ter , #spc , Mur
    IF ( #CHARPOSX >= 85 && #CHARPOSX <= 770 ) && ( #CHARPOSY >= 1348 && #CHARPOSY <= 1979 )
        set %EN_Location_LandMass  Eodon , #Spc , NW
    IF ( #CHARPOSX >= 593 && #CHARPOSX <= 946 ) && ( #CHARPOSY >= 1940 && #CHARPOSY <= 2178 )
        set %EN_Location_LandMass  Eodon , #spc , SE
    }
return
« Last Edit: February 12, 2020, 09:35:46 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: