What is a string and how do I use it?

From OHRRPGCE-Wiki

Jump to: navigation, search
This article does not meet the standard of quality we would like to have. Feel free to revise it and make it better by using the edit link at the top of the page. This tag should be removed when an editor feels it is of high quality.

The reason this article has been marked is: Not very comprehensive

A string, in its most basic concept, is a bunch of letters grouped together. It can include words, numbers, punctuation symbols or even complete sentences.

You must use Plotscripting to use strings. If you just want to make heroes and NPCs talk to each other, you do not need strings. Just use Text Boxes.

Like 98.9% of all programming languages, a string in plotscripting is written in your script enclosed by quotation marks (either " or '). In HamsterSpeak, it is the " mark. Unfortunately, that's where the sanity ends, and it becomes obvious that strings are a massive hack. You can't just throw strings enclosed in quotation marks around like numbers like in 98.8% of other languages, you have to refer to them by ID numbers, in the same way you refer to heroes by ID or party slot numbers. There are a fixed number of string slots, ID's 0 to 31, which you can use and assign literal strings to.

#A quick example:

$1 ="Hello "
$2 ="Bob"

1 $+ 2

show string (1) #this will show the string "Hello Bob" in the corner of the screen

The above example fills string 1 with the word "Hello " and fills string 2 with the word "Bob" and then combines them together by adding string 2 to the end of string 1.

By themselves, however, they aren't very useful. It would be trivial to make a text box saying "Hello Bob" without using strings. However, if we make a script like this:

$1="Hello "
get hero name (2, hero:bob)

1 $+ 2

show string (1) #this will show the string "Hello <name>", depending on the name of the hero

To learn more about strings, you should read the Plotscripting Dictionary entries about string commands

Personal tools