Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Superfighters Deluxe - LocalStorage and SharedStorage

Share questions, scripts and tutorials related to the ScriptAPI in SFD.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Superfighters Deluxe - LocalStorage and SharedStorage

Post by Gurt » Mon Jan 28, 2019 5:17 pm

Superfighters Deluxe v.1.1.0 will introduce local storage which allows you in your map or script to store permanent data which is maintained between server restarts and between different map restarts.

Previously you could only store a single string in the IGame.Data between map restarts. This was reset once the map changed to another map or the server restarted.
Now you will be able to store data using key-value pairs instead similar to how cookies work using javascript.
You will have access to the local storage using IGame.LocalStorage.
You will also have access to a shared storage using IGame.GetSharedStorage(..). The shared storage can be read between different scripts.

The interface will look like this:
► Show Spoiler
► Show Spoiler
There's also a matching IGame.SessionStorage that can be used with the same interface instead of the old IGame.Data if you don't care about permanent storage.

This local storage can open up for some configurable extension scripts (and maps) to the end user.
► Show Spoiler
Update: Added IGame.GetSharedStorage(..) which can read and write to the same storage between different scripts and maps. Note that any script can access this and change its data.
12 x
Gurt

Juansero29
Fighter
Fighter
Posts: 52
Joined: Sun Jun 12, 2016 1:07 am
Title: Superfighter
SFD Account: Juansero29
SFD Alias: Juansero29
Started SFD: Pre-Alpha 1.0.5
Location: France
Gender:
Age: 25
Contact:

Post by Juansero29 » Mon Jan 28, 2019 6:08 pm

OMG. I think it is time to come back to developing scripts for this game. IT'S BEEN SO LONG!
4 x

Code: Select all

boom() {
  echo "BOOM!";			
}
BOOM!
----------------------------------------
Setting the world free since 1998
----------------------------------------

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Mon Jan 28, 2019 9:00 pm

Thanks Gurt, this is a great addition and sure allows more complex and different maps to be made. However I feel like it is a bit late. The game is dying really fast and it's hard to find any decent servers. There are just so few players playing anymore. I have used really, really much time making maps and scripts during these few years. It just doesn't feel worth anymore with no one playing them. I hope I could make some content that could bring more players to the game but I don't know if it's going to help at all. It's interesting to see how the community is going to develop from now on.
3 x
Image

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Mon Jan 28, 2019 11:26 pm

Gurt wrote:
Mon Jan 28, 2019 5:17 pm
Superfighters Deluxe v.1.1.0 will introduce local storage which allows you in your map or script to store permanent data which is maintained between server restarts and between different map restarts.

Previously you could only store a single string in the IGame.Data between map restarts. This was reset once the map changed to another map or the server restarted.
Now you will be able to store data using key-value pairs instead similar to how cookies work using javascript.
You will have access to the local storage using IGame.LocalStorage. The interface will look like this:
► Show Spoiler
There's also a matching IGame.SessionStorage that can be used with the same interface instead of the old IGame.Data if you don't care about permanent storage.

This local storage can open up for some configurable extension scripts (and maps) to the end user.
► Show Spoiler
Will this system be a single growing file or there will be per-extension/map files? Data inside will be in binary of human-readable format?

I just think of translatable maps where the translation is in reality one of this "cookie session" file and every time someone wants to update or translate in another language he simply provides a different file, but keeping some guidelines in order to make it to work, for example this file need to have the same name of the map file but with extension .sfdata for example. Of course this implies that someone wrote a system to externalize strings from the map, but this is another story.

The problem occurs if there is only a big one file, what if I want to share only some data with other people and not all my current saved configurations of scripts and maps?
Off Topic
Motto73 wrote:
Mon Jan 28, 2019 9:00 pm
Thanks Gurt, this is a great addition and sure allows more complex and different maps to be made. However I feel like it is a bit late. The game is dying really fast and it's hard to find any decent servers. There are just so few players playing anymore. I have used really, really much time making maps and scripts during these few years. It just doesn't feel worth anymore with no one playing them. I hope I could make some content that could bring more players to the game but I don't know if it's going to help at all. It's interesting to see how the community is going to develop from now on.
I beg to differ a little...

The player-base doesn't need to be playing on multiplayer servers at all costs, some other people may prefer to play with bots and doing single player adventure maps, they could also prefer local multiplayer as the lag is non-existent.

Keep in mind that with the Steam release we lost a pretty decent part of the player-base we used to see, some of them were party players, they only wanted to play with themselves as they were all close friends, now with cracked clients all around they can still play by connecting by ip to other cracked clients, and that's the only thing they ever wanted, can we call them bad people? Not really, can we call them selfish? Maybe yes, because they are proving to prefer playing in a throttled way rather than supporting the devs.
3 x

User avatar
Sree
Superfighter
Superfighter
Posts: 325
Joined: Sun May 08, 2016 8:19 pm
SFD Account: phasmic
SFD Alias: sree
Gender:
Age: 23

Post by Sree » Tue Jan 29, 2019 3:26 pm

Motto73 wrote:
Mon Jan 28, 2019 9:00 pm
I have used really, really much time making maps and scripts during these few years. It just doesn't feel worth anymore with no one playing them. I hope I could make some content that could bring more players to the game but I don't know if it's going to help at all.
new community content may not bring more players to the game, but It can at least preserve the few players that play sfd.
2 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Tue Jan 29, 2019 9:24 pm

Update: Added IGame.GetSharedStorage(..) to access shared storage which can be used to "talk" cross-scripts if you want. See the updated topic for some deeper summary and quirks.
1 x
Gurt

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Tue Jan 29, 2019 9:35 pm

JakSparro98 wrote:
Mon Jan 28, 2019 11:26 pm
Will this system be a single growing file or there will be per-extension/map files? Data inside will be in binary of human-readable format?
There will be one file per extension script and per map. It will be UTF8 encoded textfiles, one line per key-value with a little bit of special parsing. Should be fairly simple to edit and add new key-value pairs if you want.

Keep in mind that the files are generated when scripts write anything to the local storage (or shared storage). These data files aren't included in the maps when you share the maps alone. Otherwise you can share your files as they are placed in your documents/Superfighters Deluxe/Cache/ScriptData/ folder.

In a nutshell the key and value is separated with a pipe like this:
MyString|Lorem Ipsum

but we also add the datatype before the key separated with another pipe like this:
string|MyString|Lorem Ipsum

so in game you would type to access this value:
string str = "";
Game.SessionStorage.TryGetItemString("MyString", out str);
// str is now "Lorem Ipsum"

other datatypes:
int|MyInt|12345
float|MyFloat|12345.678
bool|MyBool|false

for arrays the values are just separated with pipes too:
string[]|MyStrings|First string|Second string|Third string
int[]|MyInts|12345|52|5
bool[]|...
float[]|...

If you have pipes in your keys or text they are automatically escaped to the text "\|"
null values are represented with the text "\0"
2 x
Gurt

Post Reply