Forgot? Join

Community Wolf Story guide

All pages in this guide

Fine tuning: page 5 of 16

Adding your own scripts

Where this works

  • Works todayWolfStorm: the box’s Scripts section with Copy a script, and the helper writing a script for you.
  • Next WolfViewer releaseWolfViewer: the same under a box’s More... and in the helper column.
  • On across Wolf Territories (each region at its next restart)wolfAdventureFire, wolfAdventureListen and the other functions below run on any region that has had its next restart, where the game is switched on. wolfAdventureGoto, Battle, Reward, Say and Companion, and the signal, battle and companion events, are there too.

Your land is full of scripted things: doors, levers, bells, traps, lamps. They can be part of your story. There are two directions:

  • Script to story: your script tells the story that something happened (the lever was pulled), and the story moves on.
  • Story to script: the story tells your objects what happened (the box has started, they won the fight), and they do something: a door opens, a lamp lights, smoke pours out.

Who may do this

Only your scripts (the game owner’s), a grid god’s, and scripts you trust for the game can move your story on. Nothing a script does goes beyond what you could do by hand. Calls are limited in how fast they can come; a refused call returns FALSE, and wolfGetLastError() says why.

Script to story: "When my script says..."

  1. Step 1: Click the box on Your story map, press More..., then A script moves it on.... Choose the box it leads to. (Or tell the helper: “When my lever script says pulled, they go to the vault.”)
  2. Step 2: The box now shows When my script says “…” under Scripts, with a name made from the box’s name.
  3. Step 3: Press Copy a script next to it. A ready touch script goes on your clipboard, with your game and the name filled in.
  4. Step 4: In your object: Content, New Script, open it, select all its text, paste over it, and save.

This is the kind of script you get (your game’s key and the name are filled in):

// Wolf Adventure: when touched, tells the adventure "vault-script" (the box's script step).
default
{
    touch_start(integer n)
    {
        if (!wolfAdventureFire(llDetectedKey(0), "<your adventure key>", "vault-script", ""))
            llOwnerSay("Not now: " + wolfGetLastError());
    }
}

wolfAdventureFire only works while that player’s party is on the box with that script step: pulling the lever too early does nothing, and the script is told why.

Story to script: "Your scripts hear..."

  1. Step 1: Click the box, press More..., then Tell my scripts it starts. (Or tell the helper: “When they choose to ring the bell, tell my scripts.” The helper can also send a signal when they make a choice, or when they win or lose a fight.)
  2. Step 2: The box shows Your scripts hear “…”. Press Copy a script for a ready listening script.
  3. Step 3: Paste it into your object, then add what the object should do where the script says so.
// Wolf Adventure: hears "lamp-starts" from the adventure's story.
integer CHANNEL = -7346;
default
{
    state_entry()
    {
        wolfAdventureListen(CHANNEL);
        llListen(CHANNEL, "", NULL_KEY, "");
    }
    listen(integer ch, string from, key id, string msg)
    {
        list f = llParseStringKeepNulls(msg, ["|"], []);
        if (llList2String(f, 0) == "signal" && llList2String(f, 2) == "<your adventure key>" && llList2String(f, 3) == "lamp-starts")
        {
            key player = llList2Key(f, 1);
            string data = llList2String(f, 4);
            // what your object does now (open a door, play a sound, set off an effect)
            llOwnerSay("lamp-starts for " + llKey2Name(player));
        }
    }
}

wolfAdventureListen(channel) sends the story’s events to your object as chat on that channel, so the script listens there too. The channel is your choice. Each event is one line of fields separated by |; the second field is the player’s key and the third the game’s key. (The event for reaching a box is spelt beat on the wire: it is the same thing as a box.)

wolfAdventureListen events
EventThe lineWhen
startstart|player|adventure|partyA player starts the game.
beatbeat|player|adventure|act|scene|boxThe party reaches a box.
choosechoose|player|adventure|choice|optionA choice is made.
flagflag|player|adventure|flag|valueSomething the story remembers changes.
rewardreward|player|adventure|rewardA reward is given.
endend|player|adventure|endingThe story ends.
leaveleave|player|adventureA player leaves.
signalsignal|player|adventure|name|dataA box, choice, win or loss sends your scripts a signal (the data is up to 240 bytes).
battlebattle|player|adventure|battle|won or lostA fight is won or lost.
companioncompanion|player|adventure|character|joined or leftA companion joins or leaves.

Your own scripts, scripts you trust and the region holder’s scripts hear the events. An object someone wears hears only its wearer’s events.

Ask the helper to write one

Tell the helper what you want: “Write me a script for a lamp that turns on when the lighthouse box starts.” It writes a short script, and Copy the script it wrote appears in its column (WolfStorm: Copy the script). Paste it into your own object and read it all before you save it. The helper never puts a script into anything by itself: you decide where it goes.

All the Wolf Adventure functions

adventure is the game’s key; "" means the only game that player is playing on this region (wolfAdventureSay needs the game named). Box, battle, reward and character ids are the ids in your game.

Wolf Adventure script functions
FunctionWhat it does
integer wolfAdventureFire(key avatar, string adventure, string trigger, string data)Fires the box’s script step with that name, for the player’s party, if they are on that box. data (up to 240 bytes) is kept in the session log.
integer wolfAdventureListen(integer channel)Sends the story’s events to this object as chat on the channel (0 stops).
string wolfAdventureGetFlag(key avatar, string adventure, string flag)Reads something the story remembers, if it allows scripts to read it.
integer wolfAdventureSetFlag(key avatar, string adventure, string flag, string value)Changes something the story remembers, if it allows scripts to change it; the story’s steps for it then run.
list wolfAdventureBeat(key avatar)Where that player is in the story: adventure, session, party, act, scene, box and its objective.
list wolfAdventureInfo()Every game switched on for this region: adventure, title, revision.
integer wolfAdventurePlaying(key avatar)TRUE when the avatar is playing a game here.
integer wolfAdventureTrustScript(string adventure, string scriptName, integer on)You, the owner, mark a script in this object as one of the game’s own (an edited copy is not), or take that back.
integer wolfAdventureChest(string adventure, string chestId, integer on)Binds this object as the game’s chest, which hands out items and rezzes props.
integer wolfAdventureGoto(key avatar, string adventure, string box)Moves the player’s party to that box, as a story step would.
integer wolfAdventureBattle(key avatar, string adventure, string battle)Starts that fight for the party; the result arrives as a battle event.
integer wolfAdventureReward(key avatar, string adventure, string reward)Gives the player that reward.
integer wolfAdventureSay(string adventure, string character, string text)That character says the text (up to 1,000 bytes) on this region.
integer wolfAdventureCompanion(key avatar, string adventure, string character, integer on)That character joins the party as a companion (TRUE) or leaves it (FALSE).

Every function is also listed in the LSL guide once the region update is live.