pxt-arcade icon indicating copy to clipboard operation
pxt-arcade copied to clipboard

Setting player custom data doesn't seem to be working

Open kiki-lee opened this issue 2 years ago • 5 comments

Unless I don't know how to use it properly?

Screenshot by Dropbox Capture

https://makecode.com/_JdRW8oVghAM1

kiki-lee avatar Jun 27 '23 19:06 kiki-lee

Okay, this is weird...this is happening in the same game when I add a callout to see who is who...

Screenshot by Dropbox Capture

Maybe I'm not initializing the players correctly?

kiki-lee avatar Jun 27 '23 20:06 kiki-lee

Looks like an off-by-one error in the player state array: https://github.com/microsoft/pxt-common-packages/blob/a0bcbbee0b53f5e443e5693996904fd9a186ac8a/libs/multiplayer/player.ts#L169

Should read

    while (this._state.length <= key) this._state.push(0);

Workaround is to write to a state key one higher than you actually want to store.

eanders-ms avatar Jun 27 '23 20:06 eanders-ms

The player number thing looks like a different issue. It isn't converting to the JavaScript I would have expected. I get this:

    mp.getPlayerSprite(p4).sayText(convertToText(mp.getPlayerByNumber(number)))

What I expected:

    mp.getPlayerSprite(p4).sayText(convertToText(p4.number))

eanders-ms avatar Jun 27 '23 20:06 eanders-ms

Hmm. Is there something I should be doing differently there? I don't need it for my delivery tomorrow, but I anticipate it will come up again.

kiki-lee avatar Jun 28 '23 02:06 kiki-lee

Forum user reporting the player custom data issue: https://forum.makecode.com/t/why-doesnt-my-set-player-state-work/27988/2

eanders-ms avatar Mar 28 '24 17:03 eanders-ms