Database

Introduction

It will be possible to upload data to Atom and query it with a MagiScript command.

Available data sources:

-

  • pi : contains information about the Pi Revelations book

  • card : card stack-related queries, several popular stacks are supported

Querying the β€œpi” Database

To query the β€œpi” database, use the db.query() function with the first argument set to β€œpi”. The second argument should be a 4-digit number you want to search for in the database. For example, db.query(β€˜pi’, 4000) searches for the number 4000 in the β€œpi” database.

The db.query() function will return an object with keys page, line, and across. These keys represent the page number, line number, and column number where the 4-digit number can be found in the book.

Here’s an example code snippet that demonstrates how to query the β€œpi” database:

let data = db.query('pi', '4000');
console.log(data.page); // outputs the page
console.log(data.line); // outputs the line
console.log(data.across); // outputs the column

In this example, the db.query() function searches for the number 4000 in the β€œpi” database. The result is stored in the data variable, and then the console.log() function is used to output the result to the console.

Card Database

With the card database, you can work with card positions in popular stacks like:

-

  • β€œsimple”: a simple card deck order, clubs, diamonds, hearts, and spades from Ace to King:
    AC->KC, AD->KD, AH->KH, AS->KS

  • β€œnew”: a new deck order:
    AH->KH, AC->KC, KD->AD, KS->AS

  • β€œsistebbins”: Si Stebbins stack

  • β€œmnemonica”: Mnemonica by Juan Tamariz

  • β€œaronson”: Aronson stack by Simon Aronson

  • β€œmemorandum”: Memorandum by Woody AragΓ³n

You can query the card at position #n (please note, that the first card is n = 0):

// first card in new deck order
let card = db.query('card', 'mnemonica', 0);
console.log(card.pos); // 0 - pos in this ("mnemonica") stack
console.log(card.code); // 3 - pos in "simple" stack
console.log(card.name); // 4C
console.log(card.value); // 3 - Four
console.log(card.color); // 0 - Clubs
console.log(card.vibration); // '.... .'

The name property (β€˜4C’ in this case) can be sent to PeekSmith and it will recognize it as a poker card when Smart Text is ON. The code is the position of the card in the β€œsimple” stack (suit * 13 + value).

You can also search for the card in the stacks by name, and receive the index (pos):

// 10H in a new deck
let card = db.query('card', 'new', '10H');
console.log(card.pos); // 9 - 10th card in a new deck
console.log(card.code); // 35 - pos in "simple" stack
console.log(card.name); // 10H
console.log(card.value); // 9 - Ten
console.log(card.color); // 2 - Hearths
console.log(card.vibration); // '-- -'

And finally, it is also an option to search for the card by providing the suit and value:

// suit #2 (Hearts) and card value #11 (Q) card in the Si Stebbins stack
let card = db.query('card', 'sistebbings', 2, 11);
console.log(card.pos); // 11 - 10th card in stack
console.log(card.code); // 37 - pos in "simple" stack
console.log(card.name); // QH
console.log(card.value); // 11 - Queen
console.log(card.color); // 2 - Hearths
console.log(card.vibration); // '--.. -'

Conclusion

In MagiScript, it is possible to query information from a local β€œdatabase” using the db.query() function.

The β€œpi” database is a predefined data source that can be queried using MagiScript. By passing a 4-digit number to the db.query() function, you can find the page, line, and column where the number can be found in the Pi book.

The β€œcard” database is to help you work with card stacks, which can be useful for ACAAN routines.