Announcements > Development

2011/10/24 - Blockland r1395 features

(1/40) > >>

Badspot:
As of Blockland build 1395 there are some new features:

Brick_Treasure_Chest



A treasure chest brick that acts as a findable item.  Click on chest to open it.  It keeps track of how many chests there are and how many you have found.  The onActivate events on the brick are only triggered the first time a player opens the chest, so this can also be repurposed for "once per player" events.


Script_Player_Persistence

A simple player saving mod.  When a player disconnects, it saves their position, datablock, health and items, then restores that information when the player reconnects.  The treasure chest and checkpoint bricks will use this system (if enabled) to save and restore the client's current checkpoint brick and which chests they have found.  


Other changes may affect old add-ons

FxDTSBrick::onPlant() and FxDTSBrick::onLoadPlant() are now correctly distinguished from each other.  onPlant is called when a player plants a brick in the game, onLoadPlant is called when a brick is planted via loading a save file.  This should fix issues like duplicate events showing up on checkpoint bricks when loading a save.  However this bug has been around so long that many add-ons have been programmed around it and this fix may cause them to stop working.  The solution is to update the effected add-ons.  

Badspot:
Add-On developers:  You can use player persistence to save any tagged field on the client or player object by using the RegisterPersistenceVar() function.  Here is some example code:

--- Code: ---//load the persistence add-on now, if they have it enabled.
//you can also use ForceRequiredAddOn if your add-on doesn't work without persistence
LoadRequiredAddOn("Script_Player_Persistence");

if(isFunction(RegisterPersistenceVar))  //quick way to check if the persistence add-on loaded
{
   //usage: RegisterPersistenceVar(string <tagged field to match>, bool <match all>, string <datablock classname>);

   RegisterPersistenceVar("myVariable", false, "");             // save %client.myVariable and %player.myVariable to persistence file (if those values are set)

   RegisterPersistenceVar("myPrefix", true, "");                // save any tagged field on %client/%player starting with "myPrefix",
                                                                // eg %client.myPrefixFoo %client.myPrefix_24, etc.
                                                                // This is more expensive than a straight match and can have unintended consequences, so be careful

   RegisterPersistenceVar("myDatablockRef", false, "ItemData"); // save %client/%player.myDatablockRef to persistence but verifies that it is of class "ItemData"
                                                                // and translates the id number into a datablock name before saving. 
                                                                // Datablock id numbers will vary depending on the order and number of add-ons loaded,
                                                                // so use this if you need to save a datablock reference.
}

//optionally, you can package into the apply persistence function if you need to do custom stuff to fully restore the player's state
package <MyAddOn>PersistencePackage
{
   function GameConnection::applyPersistence(%client, %gotPlayer, %gotCamera)
   {
      Parent::applyPersistence(%client, %gotPlayer, %gotCamera);
     
      //Do custom stuff here...
   }
};
activatePackage(<MyAddOn>PersistencePackage);

--- End code ---
Player Persistence files are saved as config/server/persistence/<blid>.txt

Flush535:
Awesome!

FireFish:
Nice

inb4someonesaysripoffofminecr aft

Cyanian:
Looks really run.

I can sense a Blockland story mode.  :cookieMonster:

Navigation

[0] Message Index

[#] Next page

Go to full version