Hello, I am trying to figure out how to spawn an item in a users inventory using
a verb. Would anyone have an example of how this would be possible?
Thank you!
ID:2428609
![]() Feb 16 2019, 7:56 pm
|
|
![]() Feb 17 2019, 3:38 am
|
|
What do you mean by saying "spawn"? Do you want add item to inventory?
|
Right, Instead of having an item on the ground and the player picks it up I want to add an item to the players inventory after an action. For example if they kill something an item automatically appears in the users inventory.
|
@Kozuma3 Thanks for the reply but that is pretty vague, I'm not sure how I would implement that.
I've been working with something like this. Code: Ore = 0 mob/verb/Mining() usr << "Mining Laser Engaged!" var yield = rand(1,10) usr.Ore += yield So I can give the user ore with a variable but I'd rather give them an item as I want all verbs and encounters to give items they can buy and sell for more of a user run economy. And storing all items gained as variables seems like a bad way to do it. Hopefully this explains my question a bit more if you need further details I will try to help I appreciate any theories or ideas you or anyone can provide. |
It depends on if you use an item stacking system or not, if you do, you'd just check for the existing item and increase the amount variable. If not you'd want to do something like:
var/yield = rand(1,10) I don't really recommend that approach, introducing some form of stacking system would be much better. |
As Nadrew said, stacking items more effective in this case.
obj/item |
You can use locate() to determine if an item of a specific type is in the inventory, without looping.
|
Nadrew wrote:
You can use locate() to determine if an item of a specific type is in the inventory, without looping. You're right, i forget about it, could you remind me how its work? @Edit: Somethink like this? var/curItem = locate(myItem) in Inventory |
locate(Type) in Container - is the format you're trying to remember, Marek. Pressing F1 in Dream Maker and going to the locate proc revealed this info.
|
var/obj/curItem = locate(myItem.type) in Inventory |
Here's a look on how I handle it.
inventory |