giving items to npc issues

Anthony the tiger
03 Oct 2017, 02:38So I may have asked this question before but how do I specifically make it so you can only give an item to a specific npc. I want the player to only be able to give currency to certain npcs. I've considered making these npcs merchants and having cash system to make this more convenient so the player has to be directly in front of the npc in question.

DarkLizerd
03 Oct 2017, 03:57There is a help file on merchants and shops...
(Haven't used them myself...yet...)
The Pixie
03 Oct 2017, 06:58What would the player type?
GIVE CASH TO OLD LADY
You could do that using the built-in use/give system (activate on the Features tab), if cash is an object.
GIVE £25 TO OLD LADY
You would need a custom command, say give £#text# to #object#
, and convert the string text
to an int using ToInt
(check it can be first, with IsInt
), check the player has the amount, then update money attributes on the object and the player.
hegemonkhan
04 Oct 2017, 03:43you need an indicating/flagging/identifying of the Object... there's a few ways to do this:
- the 'name' (ID) and/or built-in (such as the 'alias') String Attributes and the String Manipulation Functions and a naming/labeling system/convention:
http://docs.textadventures.co.uk/quest/functions/#string
(such as 'StartsWith' or 'EndsWith' Functions)
-
a normal (String, Int, Boolean) Attribute
-
a List or Dictionary Attribute
-
Object Types / Types / Inherited Attributes, and the 'DoesInherit' Function
the most simple example (doesn't really use the above methods) is that of giving to a specific Object:
<command name="give_command">
<pattern>give #object_parameter#</pattern>
<script>
if (object_parameter = bob) {
bob.currency = bob.currency + player.currency
player.currency = 0
} else {
msg ("You can only give currency to the 'bob' Object, and due to using the '#objectXXX#', you can only do so when within the same room as him, at least without extra scripting, anyways")
}
</script>
</command>
<object name="room">
</object>
<object name="player">
<attr name="parent" type="object">room</attr>
</object>
<object name="bob">
<attr name="parent" type="object">room</attr>
</object>
jmnevil54
04 Oct 2017, 03:54I set it up with verbs. The pattern is GIVE *BLANK TO *BLANK.
I use the online editor anyhow. On there, it's a feature. I just have to click the option, then click that I want it to be given, default behaviour, then I go to the object I want to give it to, click other "Give (other object) to this", and either choose handle objects individually, or print a message.