Text Adventure, NPC Merchants

RavianGamingIndustries
19 Nov 2016, 21:10

How can I make a NPC into a merchant, like if you click "Speak To" a menu pops up with items he has for sale


The Pixie
19 Nov 2016, 21:29

If you are using the off-line editor there is a library to do just that:
https://github.com/ThePix/quest/wiki/Shop-Library


RavianGamingIndustries
19 Nov 2016, 21:43

I figured out a way but in terms of making it possible it's very complicated, i wish there was a way to have a simple currency system without having to number each coin (thankfully using copy/paste numbers them for me)


TinFoilMkIV
19 Nov 2016, 22:11

Unless you want the player to be able to interact with a representation of piles of money, being able to split them up and such, you would be better off making the money an attribute of the player itself, and any other character that needs a held money value. Alternatively if you want the currency to be an object but don't need multiples of it you can make one coin object and make the number of coins an attribute that modifies the alias (name that the player sees) to reflect the amount.


RavianGamingIndustries
19 Nov 2016, 22:20

If the amount of currency was an attribute of the player, how could i make a trade system, such as trading say, 3 gold for a dagger, also how does putting a number in the alias affect the amount of coins i will have?


hegemonkhan
19 Nov 2016, 22:38

The illusion of doing things: the manipulation (changing/altering/creating/setting/re-setting/etc) of Attributes and thus keeping Object 'movement (containment: the built-in 'parent' Object Attribute)' and the quantity of Objects to a minimum.

see this too on Attributes and the the 'if' Script (near the bottom, I show how you do transactions, for example 'buying/selling'), the 'bread and butter' of basic coding/programming (these two SUPER Scripts, especially when used together, lets you do 90% of everything you want to do in your game):

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

and here's a step by step guide on creating a demo game that you can play/study on the basics of Attribute usage:

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375

and there's this post too:

http://textadventures.co.uk/forum/quest/topic/tzydhkmayemqgcohyd4hsa/teleportation#6e3ec916-5809-4961-afb2-85877be9e562

ask if you need any help, or whatever within anything.


for simple game design stuff (aka, for people new to coding/programming), Attribute usage is great, but for complex stuff (once you're a good programmer, creating advanced/complex large gaming systems: equipment, magic, npcs, dialogue, etc etc), then you want to go back to using Objects (OBJECT-ORIENTED PROGRAMMING/DESIGN: OOP/OOD), but this is for people who know porgramming/coding well.


RavianGamingIndustries
19 Nov 2016, 22:55

Your post did not help, the "Set Variable/ Attribute" script didn't work, the value for the money attribute always stayed zero even when i tried adding 1 to it

By the way I'm using the online editor and not the offline one


TinFoilMkIV
19 Nov 2016, 23:11

Depending on how you code things, the NPC merchant shouldn't care whether you're actually giving them a physical object as long as the player meets the requirements for the trade, in this case a money value. If the merchant is going to keep track of the money it is holding as well you just give it the same attribute, and during the trade subtract the determined amount from the player and add it to the merchant's value.

As for the alias, it would be so you could have an object that's just called "Pile of Coins" or some such, then based on the amount it contains you could modify the alias to say something like "Pile of 156 Coins", unless you prefer to have a generic name and only give the exact value upon examination.

Remember the game doesn't actually care whether something is an object or just a number, more often than not it's best to keep to the simplest thing you can unless you're trying to make really detailed systems.


hegemonkhan
19 Nov 2016, 23:13

try my second link, on creating a step by step demo game.

Are you seeing the displayment of the Attribute with the 'statusattributes', ??? As, this is a bit tricky to gettting it to display the current value of an Attribute.

I need to know what you did, to help you fix it up and get it working... if you could post your entire game code, then I can help you with getting it to work (not sure if this can be done online... does it have a top horizontal menu bar with a notepaper like button/option ??? if so, this is a toggle between the GUI/Editor and your entire game code)


here's an example working game (hopefully, I don't have any mistakes/errors in my code, lol):

<asl version="550">
  <game name="example_game">
    <attr name="gameid" type="string">7664e88c-fe16-47e4-89ba-bfffa677b1c0</attr>
    <attr name="version" type="string">1.0</attr>
    <attr name="firstpublished" type="string">2016</attr>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <attr name="strength_integer_attribute" type="int">0</attr>
      <attr name="statusattributes" type="simplestringdictionary">strength_integer_attribute = Strength: !</attr>
    </object>
    <object name="strength_object">
      <attr name="alias" type="string">strength</attr>
      <attr name="displayverbs" type="simplestringlist">increase;decrease</attr>
      <attr name="increase" type="script">
        player.strength_integer_attribute = player.strength_integer_attribute + 1
      <attr>
      <attr name="decrease" type="script">
        player.strength_integer_attribute = player.strength_integer_attribute - 1
      <attr>
    </object>
  </object>
  <verb>
    <property>increase</property>
    <pattern>increase</pattern>
    <defaultexpression>You can't increase that!</defaultexpression>
  </verb>
  <verb>
    <property>decrease</property>
    <pattern>decrease</pattern>
    <defaultexpression>You can't decrease that!</defaultexpression>
  </verb>
</asl>

TinFoilMkIV
19 Nov 2016, 23:21

It seems some of the confusion is over the use of custom attributes, which according to to the documentation here http://docs.textadventures.co.uk/quest/tutorial/custom_attributes.html is not accessible to the online editor. I would personally highly recommend using the offline editor unless there is something stopping you from being able to use it.


RavianGamingIndustries
19 Nov 2016, 23:22

TinyFoil how do i change the attributes value tho??? i've tried just about everything and nothing works


hegemonkhan
19 Nov 2016, 23:23

P.S.

try adding in a 'print message' Script after your 'set a variable or attribute' 'increasing attribute' Script:

add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] NAME_OF_YOUR_OBJECT_CONTAINING_YOUR_CURRENCY_ATTRIBUTE.NAME_OF_YOUR_CURRENCY_ATTRIBUTE

replace my caps stuff with the names you're using for them (note that there is a dot/period in between the name of the object and the name of the attribute, no spaces)

this will show/display your currency attribute after you increase it, so you can see if it is working or not. If it is working, then the problem is likely with the set up of the 'statusattribute' displayment of it in the right side/pane.


TinFoilMkIV
19 Nov 2016, 23:23

Seems like the issue is the missing functionalities in the web editor, as per - http://docs.textadventures.co.uk/quest/webeditor.html

I only ever used the offline editor so if there are workarounds I'm not aware of them, and I'd recommend using the offline editor if possible


hegemonkhan
19 Nov 2016, 23:30

It seems the Web Editor doesn't have the 'add attribute' GUI/Editor feature, if I understand TinFoil's link, lol.

thus, you got to do the Attribute stuff through scripting (like with when using the Game Book version):

using the 'set a variable or attribute' Script, my guide does cove this, but it can be confusing... as scripting(coding) isn't newbie-friendy

the 'set a variable or attribute' Script allows you to both create an Attribute and give it an initial value, as well as, be able to change that Attribute's Value.