-
Notifications
You must be signed in to change notification settings - Fork 18
Memory Database v7
- status: complete
- version: 7.x
- follows from: Current, Previous, Next Step
The memory database is available under node.game.memory
of
the logic client type.
The memory database is an instance of the NDDB database and inherits all its methods.
There are three ways of inserting data in the memory database.
The input parameters to node.done
, which terminates the step, are automatically added to the database.
// Stage 1.1.1.
// Client id=A.
node.done({ foo: "bar"});
// Client id=B.
node.done({ foo: "bar"});
// Logic.
memory.size(); // 2 -> 1 item from A, 1 item from B.
Clients can insert new items in the memory database, without terminating the step, using the command node.set
. This is useful for continuous-time games.
// Client id=A (stage: 2.1.1).
node.set({ value: 1 });
node.set({ value: 2 });
// Logic.
memory.size(); // 4 (2 items from previous example, and 2 new ones).
The logic can manually add items to the database. Each item must contain a player
and stage
property, or an error will be raised. This is useful to fill in values from disconnected players.
// Logic.
memory.add({
player: 'B',
stage: { stage: 2, step: 1, round: 1},
value: 3
});
memory.size(); // 5 (4 items from previous examples, and 1 new one).
Go back to the wiki Home.
Copyright (C) 2021 Stefano Balietti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.