Jump to content

String Manipulation Calls

Enraged Slith

Recommended Posts

The string manipulation calls are fairly simple if a bit obtuse. You are given a 'string buffer' which is your workspace in which to construct strings. It's really just a string itself that you can tack pieces onto, retrieve the contents of, and delete the contents of.


To do a task like what you want there are several stages. First, you have to assume that the string buffer may have been used before, so you'll want to empty it out before doing anything else; the clear_buffer() call does this. Next, you have to fetch the value you want to use, in this case the party's gold, which comes from coins_amount(). You can put this in an integer variable, or just use the result directly as the argument to the call in the next step. That step is: Once you have the number you're interested in, you turn it into a string and add that string to the buffer using append_number(). The command combining these two steps is then append_number(coins_amount()). Now the string buffer holds a string made from your number, and you want to get it out again. To do this, the game requires you to place the result into an intermediate string variable (See note). You do this by passing the string variable you want to put the data into as the argument to get_buffer_text(). Finally, you can then use the new contents of that string variable for your dialog choice. It's actually not that much code when written out. Assuming you have declared a string variable str:




Note: The get_buffer_text() call is a rather odd one in that I think it is possibly the only call in Avernumscript which exhibits pass-by-reference behavior, rather than the pass-by-value behavior of all other calls. This is confusing, since most people unfamiliar with programming will not be aware of such a distinction, and probably not even someone familiar with programming would guess that this function would work in this way. However, I think that Jeff probably discovered that he was stuck with this kludge because the most natural way to write the necessary call—as a function which returns a string as its result, is not, I believe, allowed by Avernumscript. Sigh.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...