giving items to npc issues

So 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.

There is a help file on merchants and shops...
(Haven't used them myself...yet...)

What would the player type?


You could do that using the built-in use/give system (activate on the Features tab), if cash is an object.


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.

you need an indicating/flagging/identifying of the Object... there's a few ways to do this:

  1. the 'name' (ID) and/or built-in (such as the 'alias') String Attributes and the String Manipulation Functions and a naming/labeling system/convention:
(such as 'StartsWith' or 'EndsWith' Functions)

  1. a normal (String, Int, Boolean) Attribute

  2. a List or Dictionary Attribute

  3. 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>
    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")

<object name="room">

<object name="player">
  <attr name="parent" type="object">room</attr>

<object name="bob">
  <attr name="parent" type="object">room</attr>

I 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.

This topic is now closed. Topics are closed after 60 days of inactivity.