It's coming along nicely. I have written a file system browser that lets you see everything that's being tracked in the file system. I've dubbed this "Next Generation File System" or NGFS.
Attached is a picture of the browser.
Right now the memory is organized into two different possible ways to save. One is organized by #CHARID, shard and script tag. Another one is just organized by script tag. This way you get a way to transfer "generic information" from script to script, and also allow for data to be saved for a specific character on a specific shard.
Also, I'm partitioning the file system helper functions into user levels. So:
tm_NGFS_base = minimal base functions to allow a script to load/save from the file system
tm_NGFS_advanced = functions to allow for file system maintenance and advanced scripting
Perhaps another level for things like formatting the file system.
Here's a snapshot of the current functions (there's some test code at the end of the snippet)
sub TM_NGFS_InitializeScript
namespace push
namespace local TM_NGFS
namespace clear
set !lpc #LPC
set #LPC 10000
if %0 = 0
{
display ok You must name your script, spaces will be converted to underscores.
stop
}
set !TM_FSSIZE 1000 ; do not change this!!
set !script_name %1
set !args %0
gosub AddUnderscore !script_name
set !script_name #RESULT
if !args = 1
{
gosub AddUnderscore #SHARD
set !slot #CHARID , _ , #RESULT , _ , !script_name , _vars
}
else
{
set !slot generic , _ , !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_NGFS_RegisterVariables
if %0 <= 2
{
display ok Not enough arguments
stop
}
namespace push
namespace local TM_NGFS
if !slot = N/A
{
display ok You must name your script and also run TM_NGFS_InitializeScript first.
stop
}
set !nstype %1
set !nsname %2
for !i 3 %0
{
set !var % . !i
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_NGFS_SaveVariables
namespace push
namespace local TM_NGFS
set !lpc #LPC
set #LPC 10000
set !outstring
set !start 1
set !sepcnt 1
set !line_count 0
set !temp_str ! . !slot
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 ,
str len !outstring
if #STRRES >= !TM_FSSIZE
{
set * . !slot , !line_count !outstring
set !outstring
set !line_count !line_count + 1
set !start !start - 1
str del ! . !slot 1 !start
set ! . !slot #STRRES
set !start 1
set !sepcnt 1
}
}
str len !outstring
if #STRRES > 0
{
set * . !slot , !line_count !outstring
set !line_count !line_count + 1
}
set * . !slot , !line_count N/A ; make sure there's nothing left at end of the list
set #LPC !lpc
set ! . !slot !temp_str
namespace pop
set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
sub TM_NGFS_LoadVariables
namespace push
namespace local TM_NGFS
set !lpc #LPC
set #LPC 10000
set !start 1
set !sepcnt 1
set !line_count 0
set !temp !slot , !line_count
set !string * . !temp
set ! . !slot
set !varcnt 0
set !continue #TRUE
while !continue = #TRUE
{
gosub ReadItem !string
if !continue = #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 !newval ! . !slot
set ! . !slot !newval , !nstype , , !nsname , , !var ,
set !varcnt !varcnt + 1
}
if !continue = #FALSE
{
set !line_count !line_count + 1
set !temp !slot , !line_count
set !string * . !temp
set !start 1
set !sepcnt 1
if !string <> N/A
set !continue #TRUE ; still more to process
}
}
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
}
set !continue #FALSE
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
; Test code-------------------------------------------------------------------------
gosub TM_NGFS_InitializeScript test_script
gosub TM_NGFS_LoadVariables
stop
for !i 0 100
{
set !test . !i !i
gosub TM_NGFS_RegisterVariables local std test . !i
}
gosub TM_NGFS_SaveVariables
stop
;--------------------------------------------------------------------
set !test 25
set !this 35
set !variable 45
set %newvar another_value
;gosub TM_NGFS_RegisterVariables local std test this variable ; local:std namespace
gosub TM_NGFS_RegisterVariables local std test ; from local:std !test
gosub TM_NGFS_RegisterVariables local std this ; from local:std !this
gosub TM_NGFS_RegisterVariables local std variable ; from local:std !variable
gosub TM_NGFS_RegisterVariables std std newvar ; denotes a %var
gosub TM_NGFS_SaveVariables
stop
gosub TM_NGFS_InitializeScript new_script2 generic ; make a generic copy
for !i 0 100
{
set !test . !i !i
gosub TM_NGFS_RegisterVariables local std test . !i
}
gosub TM_NGFS_SaveVariables
gosub TM_NGFS_InitializeScript new_script22
for !i 0 100
{
set !test . !i !i
gosub TM_NGFS_RegisterVariables local std test . !i
}
gosub TM_NGFS_SaveVariables
stop