fCraft Forums

Skip block
Page 1 of 1

Author:  Hellenion [ July 16th, 2012, 12:50 pm ]
Post subject:  Skip block

Imitates the skip block behaviour from 0.700

It may not be as sophisticated as f's implementation but this was the easiest way for modders to copy it.


Manual implementation:

Author:  fragmer [ July 16th, 2012, 8:05 pm ]
Post subject:  Re: Skip block

The official skip-block support was added in r1458-r1459. Here's the diff (won't be applicable to 0.6xx).

The most notable change was rewroting CommandReader.NextBlock(), CommandReader.NextBlockWithParam(), and Map.GetBlockByName(). Previously they just took a string and a player name, and returned Block. Now they write result into an "out" variable, and return a bool. This allows me to distinguish between cases where "skip" block was given and when an unrecognized block name was given.
/// <summary> Finds Block corresponding to given blockName. </summary>
/// <param name="blockName"> Given block name to parse. </param>
/// <param name="allowNoneBlock"> Whether "none" block type is acceptible. </param>
/// <param name="block"> Block corresponding to given blockName;
/// Block.None if value could not be parsed. </param>
/// <returns> True if given blockName was parsed as an acceptible block type. </returns>
/// <exception cref="ArgumentNullException"> If blockName is null. </exception>
public static bool GetBlockByName( [NotNull] string blockName, bool allowNoneBlock, out Block block ) {...

So a typical usage before was...
Block block = cmd.NextBlock( Player );
if( block == Block.Undefined ){
    // unrecognized block name
    // normal blocktype given

...and now it became...
Block block;
if( !cmd.NextBlock( Player, true, out block ) ){
    // unrecognized block name
}else if( block == Block.None ){
    // "none" blocktype given
    // normal blocktype given

Author:  fragmer [ August 14th, 2012, 4:55 am ]
Post subject:  Re: Skip block

I merged the official "skip" block implementation with fCraft 0.630:

SVN wrote:
fcraft: fragmer * r1646 /branch-0.60x/fCraft/ (34 files in 9 dirs):
Added support for "none" block in brushes - viewtopic.php?p=18087
Rewrote CommandReader.NextBlock, CommandReader.NextBlockWithParam, and Map.GetBlockByName to accommodate the change.
Renamed Block.Undefined to Block.None

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group