Make Your Own Style PRO
The look of a machine is a separate effect script. Fasty ships the Capsule Machine, and the events it uses are a public API: any creator can build a roulette, a box opening, a claw machine…
How it is split
| Script | Job |
|---|---|
| Fasty Gacha (the main script, root prim) | Talks to the server, takes the money, runs the draw, delivers, pays profit shares. Always the same in every machine. |
| Your effect script (any prim) | Animates. It gets events from the main script and answers when the animation is over. |
An effect script never talks to the server and never touches money. A bug in your effect can't change a result or lose a prize. It also has its own memory, which keeps the main script light.
Messages
Everything travels as link_message:
| Direction | num | str | id |
|---|---|---|---|
Main → effects (sent to LINK_SET) | -46271 | EVENT|field|… | play ID (or NULL_KEY) |
| Effect → main | -46272 | COMMAND|field|… | play ID (or NULL_KEY) |
Fields are separated by |. Text fields (names) come escaped: use llUnescapeURL. Always send your commands with LINK_SET (in a one-prim object, LINK_ROOT reaches nothing).
Events (main → effect)
| Event | Fields | When |
|---|---|---|
STATE | state · price · items · name · API version (1) | At start, when it changes, and in reply to HELLO. State: ok, none (no collection), off (paused or empty), blocked (store not Pro), debit (no debit permission), pairing (connecting). |
WHO | — | The main script restarted: send HELLO again. |
PAID | buyer · name · amount | This play's turn started on screen: start animating. |
RESULT | product · rarity · position · total items · texture · name · late (0/1) | The server drew: stop on this item (position = index in the ITEMS list). late = 1: the animation of this play already ended (server was down); show something short or ignore. |
PENDING | buyer | Server down: the play is saved; the result comes later. |
ITEM | index · total · product · rarity · texture · chance (parts per million) · name | Reply to ITEMS, one per item, in table order. |
ITEMS_END | total | End of the list. |
Commands (effect → main)
| Command | Fields | What for |
|---|---|---|
HELLO | effect version · max duration (seconds, up to 60) | Introduce yourself (in state_entry and on WHO). The main script replies with STATE. The duration is the longest time between RESULT/PENDING and your DONE. |
DONE | — (id = the play) | The animation is over. |
ITEMS | — | Ask for the list of items (the main script fetches it in pages and passes it on). |
The order of a play
Someone pays. The play is saved and sent to the server right away (the animation never delays or changes the draw).
On screen, one play at a time:
PAID(Pay disappears while it animates) →RESULTorPENDING.Your effect animates and sends
DONE, or the time you declared inHELLOruns out (with no effect script, the time is 0).Only then the player gets the item and the proof link in chat, so the chat never spoils the surprise. Pay comes back.
Rules for your script
- Ignore what you don't know. New events and new fields may be added at the end in future versions; names and order of existing ones never change.
- Your style owns the look. The main script never sets floating text or changes the machine's appearance. Show the machine's state (closed, no collection, connecting…) from the
STATEevent. - Answer
WHOwithHELLO, and sendHELLOinstate_entry.
A minimal effect
integer EV = -46271; // main → effects
integer CMD = -46272; // effects → main
key gPlay; // the play being shown
default
{
state_entry()
{
llMessageLinked(LINK_SET, CMD, "HELLO|1|5", NULL_KEY); // version 1, up to 5 s per play
}
link_message(integer sender, integer num, string str, key id)
{
if (num != EV) return;
list f = llParseStringKeepNulls(str, ["|"], []);
string ev = llList2String(f, 0);
if (ev == "WHO") llMessageLinked(LINK_SET, CMD, "HELLO|1|5", NULL_KEY);
else if (ev == "PAID") llSetText("Rolling…", <1, 1, 1>, 1.0);
else if (ev == "RESULT")
{
string name = llUnescapeURL(llList2String(f, 6));
llSetText(llList2String(f, 2) + "!\n" + name, <1, 0.8, 0.2>, 1.0);
gPlay = id;
llSetTimerEvent(2.0);
}
else if (ev == "PENDING") { llSetText("Saved!", <1, 1, 1>, 1.0); gPlay = id; llSetTimerEvent(2.0); }
}
timer()
{
llSetTimerEvent(0);
llSetText("", ZERO_VECTOR, 0);
llMessageLinked(LINK_SET, CMD, "DONE", gPlay);
}
}Start from the example
The kit includes Fasty Gacha Effect (example): it narrates every event in your chat, shows the state as floating text and sends DONE 2 seconds after the result. Drop it into a machine to see the events live, then use it as the base for your own style.