How do I make a shop that can be used only one, two or three times?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

You can create a shop that can only be used once with both plotscripting and NPC conditionals.

Using Conditionals[edit]

See How to use NPCs and Tags for an extensive introduction to using textbox conditionals.

  • Create a new tag. This tag will be turned ON when the one-time shop is used
  • Create the textbox which calls the shop. In its conditionals, set
 Always do the following
  set tag 2 = ON (one-time use shop)
  set tag 0 = ON [unchangeable]

and

 Always do the following
  go to shop 1
  • Next create the second textbox to jump which the first one jumps to instead if the shop has already been used, and write something like "Sorry, the one time offer has expired."
  • Then go back to the conditionals of the first textbox and make it jump to the second instead if the tag is ON.
 IF tag 2 = ON (one-time use shop)
  jump to textbox 2 instead

Using Plotscripting[edit]

This example uses shop number 21 and npc 17 as the shop keeper. Attach this script to the textbox that would normally call the shop:

plotscript, single use shop, begin

 if (check tag(tag: no more goods) == OFF) then, begin
   use shop (21)
   set tag (tag: no more goods, ON)
 end, else, begin
   show textbox (368) # "sorry, I have no more goods to sell"
 end
end


Multiple uses with plotscripting[edit]

If you want the shop to be used more than once you have to use plotscripting and a global variable

global variable (1,shop)  # Limit the number of uses of the shop
#---------------------------------------------------------------

plotscript, shop, begin
 if (shop << 4) then , begin # in this example the shop is avialable only for 4 times
   increment (shop) #give the name you have put to the global variable
   use shop (21) #shop number 
 end, else, begin
   #after 4 times new things happen
   show textbox (368)
 end
 # add further logic here:  "I have received brand new goods and we now offer home delivery!"
end

You can use these scritps for various other purposes too (If you want an npc to say something two or three times before changing their speech for example).