Official ScriptUO EasyUO Scripts > Script development tools

TrailMyx's Next Generation File System (TM_NGFS)

(1/29) > >>

TrailMyx:
So sometimes I like to have a quick way to save things, but I don't want to completely blowup my registry.  So I'm coming up with some subs that compress all variables into a single registry entry.  CEO does something similar to this, but I'm going to have a bunch of support routines that'll allow you to copy between scripts, characters and dump to a file to move between computers.  It's going to be kinda interesting.

I'm also coming up with a manager so you can modify EVERYTHING that the filesystem manages.  That's why I needed the tab subs so I can automate this interface and make it look pretty.


--- Code: ---gosub TM_InitializeAdvFS test_script

;gosub TM_LoadVariables
;stop
set !test 25
set !this 35
set !variable 45
set %newvar another_value
gosub TM_RegisterVariable local std test ; local:std namespace  
gosub TM_RegisterVariable local std this ; local:std namespace
gosub TM_RegisterVariable local std variable  ; local:std namespace
gosub TM_RegisterVariable std std newvar  ; denotes a %var
gosub TM_SaveVariables
stop

;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
set !TM_FunctionCalled #FALSE
if %0 = 1 && !TM_FunctionCalled = #FALSE
  gosub %1
if %0 = 2 && !TM_FunctionCalled = #FALSE
  gosub %1 %2
if %0 = 3 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3
if %0 = 4 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4
if %0 = 5 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5
if %0 = 6 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6
if %0 = 7 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7
if %0 = 8 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8
if %0 = 9 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9
if %0 = 10 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10
if %0 = 11 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11
if %0 > 11
{
  display ok Too many arguments for "call", edit the call header.
  stop
}

; exit  ; include this line if you don't want to run the error checking.  NOT RECOMMENDED!  Add "set !TM_FunctionCalled #TRUE" to the end of your subs for full error-checking!
 
if !TM_FunctionCalled = #TRUE ; successfully called function.
  exit
if %0 = N/A
  display ok You may not run this script directly.
else
  display ok Function " , %1 , " not found.
stop

;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
sub TM_InitializeAdvFS
  namespace push
  namespace local TM_AdvFS
  set !lpc #LPC
  set #LPC 10000
  namespace clear
  if %0 = 0
  {
    display ok You must name your script, spaces will be converted to underscores.
    stop
  }
  set !script_name %1
  gosub AddUnderscore !script_name
  set !script_name #RESULT
  gosub AddUnderscore #SHARD
  set !slot #CHARID , _ , #RESULT , _ , !script_name , _vars
  set ! . !slot
  set !varcnt 0
  set !index 0
  set !script_index N/A
  while *TM_FS . !index <> N/A
  {
    if *TM_FS . !index = !slot
    {
      set !script_index !index
      break
    }
    set !index !index + 1
  }
  if !script_index = N/A
  {
    set !script_index !index
    set *TM_FS . !script_index !slot
  }
  set #LPC !lpc
  namespace pop
  set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
sub TM_RegisterVariable
  namespace push
  namespace local TM_AdvFS
  if !slot = N/A
  {
    display ok You must name your script and also run TM_InitializeAdvFS first.
    stop
  }
  set !nstype %1
  set !nsname %2
  set !var %3
  if !nstype ,  , !nsname ,  , !var notin ! . !slot
  {
    set !newval ! . !slot
    set ! . !slot !newval , !nstype ,  , !nsname ,  , !var , 
    set !varcnt !varcnt + 1
  }
  namespace pop
  set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
sub TM_SaveVariables
  namespace push
  namespace local TM_AdvFS
  set !lpc #LPC
  set #LPC 10000
  set !outstring
  set !start 1
  set !sepcnt 1
  for !i 1 !varcnt
  {
    gosub ReadItem ! . !slot
    set !nstype #RESULT
    gosub ReadItem ! . !slot
    set !nsname #RESULT
    gosub ReadItem ! . !slot
    set !var #RESULT
    if std in !nstype
    {
      set !val % . !var
    }
    else
    {
      namespace copy !var from !nstype !nsname
      set !val ! . !var
    }
    set !outstring !outstring , !nstype ,  , !nsname ,  , !var ,  , !val , 
  }
  set * . !slot !outstring
  set #LPC !lpc
  namespace pop
  set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
sub TM_LoadVariables
  namespace push
  namespace local TM_AdvFS
  set !lpc #LPC
  set #LPC 10000
  set !start 1
  set !sepcnt 1
  set !string * . !slot
  set !continue #TRUE
  while !continue = #TRUE
  {
    gosub ReadItem !string
    if #RESULT <> #TRUE
    {
      set !nstype #RESULT
      gosub ReadItem !string
      set !nsname #RESULT
      gosub ReadItem !string
      set !var #RESULT
      gosub ReadItem !string
      set !val #RESULT
      if std in !nstype
      {
        set % . !var !val
      }
      else
      {
        set ! . !var !val
        namespace copy !var to !nstype !nsname
      }
    }
  }
  set #LPC !lpc
  namespace pop
  set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
sub ReadItem
  str pos %1  !sepcnt
  if #STRRES <> 0
  {
    set !len #STRRES - !start
    str mid %1 !start !len
    set !start !start + !len + 1
    set !sepcnt !sepcnt + 1
    return #STRRES
  }
return #TRUE
;--------------------------------------------------------------------
; %1 - string to mung
sub AddUnderscore
  namespace push
  namespace local AU
  set !tempstring %1
  AddUnderscore_loop1:
    str pos !tempstring #SPC
    if #STRRES <> 0
    {
      set !val #STRRES - 1
      str left !tempstring !val
      set !left #STRRES
      set !val !val + 1
      str del !tempstring 1 !val
      set !tempstring !left , _ , #STRRES
      goto AddUnderscore_loop1
    }
  set #RESULT !tempstring
  namespace pop
return #RESULT
;--------------------------------------------------------------------

--- End code ---

Endless Night:
Interesting .. ill have to keep my eye on this thread.

TrailMyx:
This will be nice because you can manage ALL your namespace variables.  Also will be nice to visually surf through all the variables that are tracked by the filesystem, including all characters and all shards.  You can even transfer variables specific to scripts from one char to another.  Should be interesting.  Once you register a variable/namespace, then the filesystem will track it for you while keeping your registry from completely blowing up.  ;)

Scrripty:
oooooooooooo

TrailMyx:
heh.  Right now it's pretty usable I think. I haven't actually written a script that uses it yet, but I plan on working on the file system browser this weekend.

Navigation

[0] Message Index

[#] Next page

Go to full version