Non-threaded

Forums » Feature Wishing Well » Read Thread

Suggestions for improvements and additions to the site.
This feature was rejected 6/27/2012: Automatically rejected as part of the FWW clean out.

Set variables to letters.

15 years ago

Or: Less restrictive variables.
Would it be possible to allow variables to be set to letters? I want to save and display a word that is entered by the reader, but my current method requires a very long line of code to be used every time the word is to be displayed. Allowing variables to be set to letters would allow me to use the code once and the variable every time after that. For example:

[Very long line of code that sets $LINKTEXT31 to the word.]
%N:=$LINKTEXT31

Link #31 would not be visible, of course. Alternatively:

%N:="N"
%N:=%N+"a"
%N:=%N+"m"
%N:=%N+"e"

If that would set %N to "Name" then I would be able to skip using a link and the code would be significantly shorter.

Are either of these feasible, or will I be stuck using a very long line of code every time I want the word to be displayed?

Set variables to letters.

15 years ago

I do believe TSMPaul has created something similar to this. however, im not completely sure since i dont know your exact goal. However, once you have written out that long script you can just copy and paste it into your notebook and then just copy and paste it again when you need it. rather than just writing it every time.

nate

Set variables to letters.

15 years ago

and just for clarification, you have a notebook here on CYS under the "My Stuff" tab.

nate

Set variables to letters.

15 years ago

I already have it saved on a WordPad document and on two pages in my storygame. The problem is that it is 9,270 characters long and I would rather use something that is 2 characters long.

Set variables to letters.

15 years ago

well, since you already know scripting and such, you are ahead of a good majority of those here at CYS.

nate

Set variables to letters.

15 years ago

Hi. I could find no easy way to have words as variables. My method was very long, and I basically copied the code, and pasted it into a page script wherever I wanted the custom word to appear. Hopefully you can make sense of what I'm talking about here:

I wanted the player to be able to enter the name of their character. I chose a 10 letter long name limit, and made 10 variables, letter1, letter2, etc.

I then had a page where they could create their name. It consisted of a link that was 'I'm finished', and then one link for each letter of the alphabet. The links all diected back to the same page, except the 'I'm finished' link that entered the rest of the game.

The script for the page did this:

IF %LETTER1 = 1 THEN $PAGETEXT :=  $PAGETEXT +  "A"

IF %LETTER1 = 2 THEN $PAGETEXT :=  $PAGETEXT +  "B"

and so on through the alphabet for Letter1. I made letter1 display a capital letter, for the start of their name.

I had a variable called %CURRENT which was the current letter. For example, the first letter, or the second letter. When the player clicked on one of the links on the page it would assign the letter they clicked to the current variable. So if %CURRENT was 5, and they clicked on a D, then the script for the D choice would say

IF %CURRENT = 1 THEN %LETTER1 := "D"

IF %CURRENT = 2 THEN %LETTER2 := "D"

and so on, through the 10 possible letters the player can select for the word.

Then it adds +1 to %CURRENT, so that when the page is redrawn, and they click a letter again, the current letter variable is the next letter in the word.

Then I made a set of A to Z's for letter2, letter3, and so on, displaying a lower case letter.

Using $PAGETEXT := $PAGETEXT + "text" simply adds text to the last position on the screen.

So I would display the page text up to the point the person's name is mentioned, then have the 10 letter check against A to Z to write the person's name, then use pagetext = pagetext + and write the rest of the page's text. That way, the name appears on the screen as a regular part of the text.

I don't know if this is anything like the script you have written. It's certainly more than two lines long. As far as I know, there's simply no way to assign actual text to a variable using scripting - only assigning numbers. To display player entered text, you have to work it a letter at a time using numeric variables.

Set variables to letters.

15 years ago

%LETTER1:="D" sets %LETTER1 to 0. If you meant to type 4 instead of "D" then our scripts are the same (except mine has shorter names and no spaces). 

http://www.myadventuregame.com/story/Word_Recall_Demonstration.aspx 
This is a demonstration of how saving and recalling words must be done now. Again, would it be feasible to change the editor to allow variables to be set to letters (and perhaps symbols)?

 

Set variables to letters.

15 years ago

Oops, yeah, I meant assign the number that corresponds to the character.

Yeah, it's kind of a long way to do things. It would be great to have word strings as variables.