Tutorial 11: Converting text based numbers to numerical with PS

Finally, we'll end with a most obscure property of PhoenixSpeak! Anywhere in DS where it has a # symbol requires a number or variable, so if you're including numbers in your strings, the DS lines won't always work if you're wanting the string to represent a variable.

This is where PS can save lives! PhoenixSpeak gives you the ability to convert numbers introduced into an entry in textual form (through a string, a special text replacement string or a PS entry called through $) into, instead, a numerical form that is extractable into a variable.

A good use case for this technique would be to imagine a verbal command in DS that requires multiple integers to be inputted into one line. For example, let's say we are writing DS for an RPG type Dream, and we want to quickly be able to modify an NPC’s stats for debugging, without having to manually edit PS info, or having to edit the values one by one.

To start, we could create a command that looks like this:

(0:32) When someone says something with {@setstats} in it,

Now, we can then add words to the command to modify the stats of our intended target. A full command would look like this when spoken in Dream:

@setstats Goblin 50 5 7 6

The first word, @setstats, would indicate the command being used. This is recognized as [PARAM0] or [CMD] for string manipulation purposes.

The second word, Goblin, would indicate the intended target. This will be [PARAM1].

The third word, 50, would indicate the amount of hitpoints the NPC should have. [PARAM2]

The fourth, fifth, and sixth words, 5 7 6, would indicate Attack, Defense, and Agility respectively. These are [PARAM3] [PARAM4] [PARAM5].

The DS line (5:314) set variable # to the number the triggering furre just said or emoted can only handle one integer input at a time, and since there are four integers in that one command alone, the logical thing to do to extract that data would be to use DS Params. DS params are treated as strings though, and therefore cannot be accepted in any DS line where an integer is required.

In other words, (5:601) memorize that the PhoenixSpeak info {...} about the furre named {...} will now be # will not work.

On the other hand, (5:604) memorize that the PhoenixSpeak info {...} about the furre named {...} will now be {...} will work!

Here are the final segments of DS:

(5:604) memorize that the PhoenixSpeak info {[PARAM1] Health} about the furre named {NPC DATA} will now be {[PARAM2]}.
(5:604) memorize that the PhoenixSpeak info {[PARAM1] Attack} about the furre named {NPC DATA} will now be {[PARAM3]}.
(5:604) memorize that the PhoenixSpeak info {[PARAM1] Defense} about the furre named {NPC DATA} will now be {[PARAM4]}.
(5:604) memorize that the PhoenixSpeak info {[PARAM1] Agility} about the furre named {NPC DATA} will now be {[PARAM5]}.

Notice how the data is stored as strings because of the use of DS Params? PhoenixSpeak can convert that data to integers by using the line (5:611) remember the PhoenixSpeak info {...} about the furre named {...}, and put it in variable #.

Account E-Mail

Password