How do I make a text box that automatically shows the name of the item that I set it to give?

Jump to: navigation, search

It is common to see textboxes with the line "You recieved <item>!" So common in fact, that you might be mistaken into thinking that it is done automatically.

In reality,this is often done simply by manually adding that line of text to your box.

However, with the new String commands, it's quite possible to make a generic "You got <item>!" text box. Pick a string number, and reserve it for these types of usages (I.e. elsewhere when you use string, don't assume that the contents of that string will stay the same between scripts).

Now, create a text box with this text in it: "You recieved ${S1}(s)!". The ${S1} lets you embed a string into the text box. The (s) bit is to pluralize the item, since you can give more than one item at a time ("You recieved Potion(s)!").

Finally, add a script similar to this:

script, give item, item, number, begin
  #this script assumes two things:
  # 1. The string is #1
  # 2. The "You got item" text box is #1 as well
  # Change these to suit.

  get item name(1,item)
  show text box (1)
  wait for text box
  get item(item,number)

You can get more fancy than this. For example, you may want to include the actual number in the text box. To do this, change the textbox to look like this: "You recieved ${S1}!" (we will handle the pluralization inside the script),

Then, put this script in (instead of the first one):

script, give item, item, number, begin
  #same assumptions as above.

  get item name(1,item) #get the item name
  if(number >> 1) then, begin #add an "s" if it's more than one
  clear string(2) #we need a second string
  append number(2,number) # "1" #put the number of items in
  $2+" " # add a space
  concatenate string(1,2) # combine the two strings ("1 potion" or "2 Masamunes")
  copy string(2,1) #put it in the right string
  show text box (1) #show it...
  wait for text box
  get item(item,number)