Furcadia - The Second Dreaming!!

Creation Talks

January 28th, 2007        5pm FST
DS Optimisation -- Gar


Gar: Greetings! Welcome to the Mr. Fishy school of DS optimization. In today's class we'll learn a few tricks to counteract some of the most common DS inefficiencies and a few ways to squeeze a few extra lines out of that bloated DS file.
Gar: As most of you probably know, you can have a maximum of 8000 lines of DS in your dream(Well, 7999 to be exact.) and yet even that great number never seems to be enough for a lot of furres. Now I myself have DSed a dream or two, and after a while, I became curious as to what exactly people were putting in their dreams that would use so many lines.
Gar: One of the most complex dreams I have had the pleasure of working on, M'Rill's Egyptian Festival, has several major quests, a floor-tile based puzzle, a working marketplace, stages with anti talking DS, oodles of signs and one of the most complex rides I have ever seen(an Egyptian barge that can transport 8-10 people at once) and yet it tops out at 3807 lines of DS(and it could probably be reduced).
Gar: So if such a busy dream only needs less than 4000 lines of DS, why does it take almost 8000 lines to get the effects you want? Well keep listening and I shall try to give you a few hints that could save you many precious lines of DS.
Gar: Ways to save 1: Reversing the question.
Gar: When designing DS you often have to ask yourself questions. Questions like: How do I give share to a small list of friends? or How do I keep people from walking in all my flowers? These questions suggest ideas for how to write your DS For the first one the most common way to give share to your friends is like this:

(0:9) When a furre arrives in the dream,
    (1:70) and their name is {Friend1},
             (5:102) share dream control with the triggering furre.
(0:9) When a furre arrives in the dream,
    (1:70) and their name is {Friend2},
             (5:102) share dream control with the triggering furre.
(0:9) When a furre arrives in the dream,
    (1:70) and their name is {Friend3},
             (5:102) share dream control with the triggering furre.

Gar: This is not bad DS, not by a long shot. But what if you're popular, what if you have 40 friends? All of a sudden each of those friends 'costs' you 3 lines of DS. And yes, your friends are worth it, but that does get kind of expensive after a while. (smiley)
Gar: So how can we make this more efficient? How can we turn this DS around and just not give share to anyone who isn't our friend? Well we already have a clue, this line of DS:

    (1:170) and their name is not {...},

Gar: So how can we use this line to give your friends share? Well I'll give you the DS first, but then I'll try and explain why. The DS looks something like this:

(0:9) When a furre arrives in the dream,
       (3:2) at position (0,1) on the map,
             (5:4) place object type 1.
(0:9) When a furre arrives in the dream,
    (1:170) and their name is not {friend1},
    (1:170) and their name is not {friend2},
    (1:170) and their name is not {friend3},
       (3:2) at position (0,1) on the map,
             (5:4) place object type 0
(0:9) When a furre arrives in the dream,
    (1:1013) and position (0,1) is object type 1,
             (5:102) share dream control with the triggering furre.

Gar: It takes a bit of DS to set up, and really, for just three friends it takes more DS lines than doing it the 'normal way', but look! Now each new friend you add 'costs' only a single new DS trigger. Just add them to the 'not' list. The way DS works is all the 1: triggers must be true before the effect will happen. So if their name happens to match even one name on the long 'not' list, the pillow won't change to object 0 and the furre will get share.
Gar: How about keeping furres off your flowers? The easiest way that the mind suggests is to just make sure that whenever you walk into a flower you move them back where they came from:

(0:3) When somebody moves into object type (flower1),
             (5:18) move the triggering furre back where they came from.
(0:3) When somebody moves into object type (flower2),
             (5:18) move the triggering furre back where they came from.
(0:3) When somebody moves into object type (flower3),
             (5:18) move the triggering furre back where they came from.

Gar: Now the answer to this one is a little more obvious than the last one. Instead of testing for every single object you want to protect, simply make a single special floortile(make it look like some nice dirt) and put it under all your flowers, then you can use:

(0:2) When somebody moves into floor type (flowerdirt),
             (5:18) move the triggering furre back where they came from.

Gar: One trigger, and all your flowers are safe! No matter how many of them there are! Be on the lookout for places in your DS where you can use a single floor to indicate the location of many objects, or a single walkable invisible object to indicate where specific floors are. Or a combination of both, a couple specific floors and a specific object or two to indicate what would otherwise be a much larger collection of floors and objects.
Gar: So now we know a few ways of designing DS more efficiently, how about a trick for writing DS more efficiently. This is a technique that is well used by DS masters but isn't well documented anywhere, and can be very powerful when used properly.
Gar: Ways to save 2: Stacking Causes and Conditions on top of a single set of areas and effects.
Gar: Say you want it so whenever a furre bumps into one of your 10 paintings it plays a sound, changes the floor under their feet to green, emits your gallery url to them and moves them back where they came from. Conventionally you'd need to write your DS something like this:

(0:3) When somebody moves into object type (painting1),
       (3:6) where the triggering furre moved into,
             (5:8) play sound # to whoever set off the trigger.
             (5:1) set the floor to type #.
             (5:200) emit message {http://www.myfakegallery.url} to whoever set off the trigger.
             (5:18) move the triggering furre back where they came from. 

Gar: And you'd need to write all that for each painting! Well thanks to a hidden clause put in during the Squirrel update there's a more efficient way to DS this.
Gar: DS 0: and 1: triggers can be stacked to share common 3: 4: and 5: triggers. So in the case of these paintings we could write out our Ds like this:

(0:3) When somebody moves into object type (painting1),
(0:3) When somebody moves into object type (painting2),
(0:3) When somebody moves into object type (painting3),
(0:3) When somebody moves into object type (painting4),
       (3:6) where the triggering furre moved into,
             (5:8) play sound # to whoever set off the trigger.
             (5:1) set the floor to type #.
             (5:200) emit message {http://www.myfakegallery.url} to whoever set off the trigger.
             (5:18) move the triggering furre back where they came from.

Gar: What this basically means is that when a furre walks into painting 1 OR painting 2 OR painting 3 OR painting 4 ...then do all of that stuff. What would have taken 60 lines of DS to do 10 paintings now only takes 15 lines, much more efficient. (smiley)
Gar: At it's simplest this can be used to even cute down a shared list like we had earlier, assuming you aren't using the ultra-efficient method I showed you (smiley) That should look something like this:

(0:9) When a furre arrives in the dream,
    (1:70) and their name is {Friend1},
(0:9) When a furre arrives in the dream,
    (1:70) and their name is {Friend2},
(0:9) When a furre arrives in the dream,
    (1:70) and their name is {Friend3},
             (5:102) share dream control with the triggering furre.

Gar: Sure it's only saving you a couple lines here and there, but every little bit helps.
Gar: Which brings me to my final topic, and potentially the scariest one. (Gar's topic, not mine!)
Gar: Ways to save 3: Variables
Gar: When properly used a single variable can replace dozens of lines of redundant DS. Like this DS from the FluFF pit in Naia that checks to make sure that the furre is on one of the over 2 dozen types of fluffpillows:

(0:31) When a furre says {@Books},
  (0:31) When a furre says {@Adult},
  (0:31) When a furre says {@Furre},
  (0:31) When a furre says {@Friendly},
  (0:31) When a furre says {@Weird},
  (0:31) When a furre says {@Looking},
              (5:350) set variable %Pillowtalk to the X,Y position the triggering furre (moved from/is standing at).
              (5:381) set variable %Pillowtype to the object type at (%Pillowtalk).

Gar: Sorry about those being spammy...have to hurry this along a bit! You can read over the logfile!
Gar: There's that cause stacking again, Naia was one of the first dreams to use it. What this trigger does(and this isn't the whole trigger, I stripped off most of the @commands) is check that the object number is of the pillow you're sitting at. Then it compares it with another trigger like this one:

(0:31) When a furre says {@Looking},
     (1:201) and variable %Pillowtype is greater than 2507.
     (1:202) and variable %Pillowtype is less than 2532.
        (3:5) where the triggering furre (moved from/is standing at),
              (5:4) place object type 2525.

Gar: See that 1:201 and 1:202 ..those two triggers checking that variable saves hundreds of lines of DS. Without the variable the Ds would look something like this:

(0:31) When a furre says {@Looking},
     (1:18) and they (moved from/are standing at) object type 2508,
  (0:31) When a furre says {@Looking},
     (1:18) and they (moved from/are standing at) object type 2509,
  etc.... all the way up to
  (0:31) When a furre says {@Looking},
     (1:18) and they (moved from/are standing at) object type 2531,
        (3:5) where the triggering furre (moved from/is standing at),
              (5:4) place object type 2525.

Gar: And I would have to do that for EACH pillow.
Gar: Variables can be daunting, to be sure. But there are a lot of good tutorials out there on how to use them. for now, to get you used to them I'd like to introduce to simplest use for a variable I can think of: The variable switch.
Gar: We're going to make a simple lock that prevents anyone in your dream who doesn't have share from moving. Not very useful, or maybe very useful, depending on your personality. First off we need a trigger to define our variable. So we know whether the switch will start out on or off.

(0:0) When everything is starting up,
              (5:300) set variable %Lock to the value 0. (0 is our off position)

Gar: There, now our switch is off. Next we need two triggers, one to turn the lock on, and one to turn it off again when we feel kind and want to let people move again.

(0:31) When a furre says {lock},
     (1:11) and the triggering furre has got shared control (or is the dream owner),
              (5:300) set variable %Lock to the value 1. (one is our on position)
(0:31) When a furre says {unlock},
     (1:11) and the triggering furre has got shared control (or is the dream owner),
              (5:300) set variable %Lock to the value 0. (back to our off position)

Gar: Finally, the fun part, keeping people in place when the lock is turned on!

(0:1) Whenever somebody moves,
     (1:111) and the triggering furre hasn't got shared control (and is not the dream owner),
     (1:200) and variable %lock is equal to 1,
              (5:18) move the triggering furre back where they came from.

Gar: Bwhehe! What fun! And it's that simple. Variables are the single most powerful tool in DS. Using less than 5 variables I trimmed over 7000 lines of someones DS down to less than 3500. A single variable helped someone who was afraid they were going to need over 1000 countdown timers to fix their DS so it would use zero instead. I wish I had the time today to give further examples, but I think I'm out of time. (smiley) At this time though I think I can accept a few brief questions.
Gar: Before that though I'd like to thank you all for coming. I hope that you can use some of the tricks and ideas I've mentioned today to make your group or guild's DS more efficient, and thereby have more room to pack fun activities into your dream. Thank you! Any questions?


This page, subsequent pages and all content therein, unless otherwise stated is copyright © Dragon's Eye Productions. Site maintained by The Beekin Scribes.

Furcadia Creations