Absolutely.
rocket20001010 wrote:...how do i make them give me something back e.g give money, then they give food
I'm at work but will offer this quick solution until a more detailed one is needed. Since I am not looking at the editor right now, forgive me if this from-memory solution isn't exactly right. =)
If it is something that you just can buy one of...
This will work, but it is based on a barter system - you trade something for an item; you trade something else for a different item, etc.
1. I would make your NPC a surface container. Change the prefix to 'He is carrying'. You'll find this on the Features tab (container, change drop down to surface).
2. When you look at the NPC, it will say 'He is carrying..." You can change this prefix so that the wording sounds right for what he is selling. I think you can type in something like 'On his table, you see' or 'His wares include' Mess around with that until you get an output that you like.
3. Create whatever objects you want him to 'sell' and add them to the NPC object. Make sure they cannot be taken (untick the 'object can be taken'). Copy-paste those objects into a 'dead room'. Make sure these objects are 'able to be taken'!
4. If you have an object that you want to give him in exchange for what he is selling, go to the 'give' tab of that object and select the NPC name. Run the script 'move object to inventory' [bought object2]. boughtobject2 is the copy-pasted object of his wares.
5. If you do not want the object to be buyable again (which I suspect you wouldn't), use a 'remove object script' to remove that object from the game.
Now... if you want a more complex system where you are using a certain number of coins to buy a range of different things, then I can help with that too, but it will require setting up attributes - which gets a little trickier and will require me to be sitting in front of my home computer.
I will add a 'vendor/merchant' to my tutorial now though, because I think it is a good idea.
Remember, this is a basic outline. There are some other things you'll run into that are problematic, but this should give you an idea on how to set it up. I can make a better system when I'm at home and have time to iron out the details.
Let me know if you want tips on how to set the more complex trading system.