[Ohrrpgce] SVN: james/5051 Load the hero hand position from the RSAV file if the node exists (which

Ralph Versteegen teeemcee at gmail.com
Thu Feb 16 01:11:18 PST 2012


On 16 February 2012 22:06, Ralph Versteegen <teeemcee at gmail.com> wrote:
> On 16 February 2012 20:23, James Paige <Bob at hamsterrepublic.com> wrote:
>> On Wed, Feb 15, 2012 at 11:12:44PM -0800, James Paige wrote:
>>> On Wed, Feb 15, 2012 at 11:11:04PM -0800, subversion at HamsterRepublic.com wrote:
>>> > james
>>> > 2012-02-15 23:11:04 -0800 (Wed, 15 Feb 2012)
>>> > 92
>>> > Load the hero hand position from the RSAV file if the node exists (which it never does yet)
>>> > ---
>>> > U   wip/savegame.rbas
>>>
>>> Ralph, would you mind double-checking my work here? I think I did it
>>> right, and it compiles anbd runs, and the .default part of the nodespec
>>> seems to be working, but I am still new to ReloadBasic and I feel like
>>> my footing is a bit shakey.
>>
>> Actually, after testing properly on an .rsav instead of a game that only
>> had a .sav, I see that I *definitely* did that wrong, and the .default
>> is not actually working... I just don't understand what I did wrong :(
>>
>> ---
>> James
>
> +       READNODE slot."hand" as hand
> +        WITHNODE hand."frame" as fr
> +         j = GetInteger(fr)
> +         .hand_pos(j).x = fr."x".default(her.hand_pos(j).x)
> +         .hand_pos(j).y = fr."y".default(her.hand_pos(j).y)
> +        END WITHNODE
> +       END READNODE
>
> The defaults are only used if slot."hand"."frame" exists but
> hand."frame"."x/y" do not. The only way to do what you want is to
> pre-initialise with the default values at the beginning, like the
> elemental resists are. Note that since this is inside a "READNODE
> slot, default" block, the "READNODE slot."hand" as hand" will always
> be processed, even if slot."hand" doesn't exist. If you tagged ",
> default" onto the end of that, then the WITHNODE would also always be
> processed even if there was no slot."hand"."frame". In that case fr
> would be NULL, so j would be 0, and the second hand position wouldn't
> be set.
>
> Because .hand_pos is a fixed length array, it could be possible to add
> support for loading each of its elements with defaults automatically,
> but currently that's only supported for arrays of ints.

Well actually, it would be possible to use LOADARRAY if you wrote a
separate function to load an XYPair (which would be quite a good idea,
actually) ... I'll go implement that.



More information about the Ohrrpgce mailing list