ID:156311
Nov 11 2010, 10:54 am
|
|
How would i go about making a crafting system that uses stackable items like when you get more then one carrot its says in the inventory carrot x3 and have the craft system rely on the number of items like if you have 3 carrots and 2 tomato's you make stew and if not it denies you.
|
Nov 11 2010, 11:39 am
|
|
By using locate() to find the object and - if it exists - checking its quantity to determine if you are allowed to create something.
|
In response to Garthor
|
|
obj As you can see it uses a suffix or so and I can't really tell where to go on from here i made a test verb but don't know how to work in the quantity of items mob/verb it only works if you have 1 of each item but after that i dunno how to make it do like if you have 5 gears and 1 carrot it then makes whatever. |
In response to Mastergamerxxx
|
|
Give items a 'quantity' variable, and when the user gets more than one of a stackable object, increase the quantity of the first object.
|
In response to Warlord Fred
|
|
perhaps someone can give me a example
|
In response to Mastergamerxxx
|
|
Perhaps you can read what he wrote and implement it. It's very simple and almost identical to what you already have.
|
In response to Garthor
|
|
Where do i put it i have no clue how to implement it
|
In response to Mastergamerxxx
|
|
Ugh how annoying i got the thing finally to work but now i dunno how the hell to add the recipe part.
Like I got it to work if the amount is >=3 and what not but how do i now make it read the recipe ////example items//// like where do i go from here |
In response to Mastergamerxxx
|
|
For each requirement of the recipe, check if that requirement is met. If the requirement is not met, abort. Once you've checked off on every requirement, go through the requirements again, removing items this time. Then, create the new item.
|
In response to Garthor
|
|
I mean code wise i obviously know to do that but how do i do it in code
|
In response to Mastergamerxxx
|
|
Code:
////example items//// Problem description: I dunno how to add on more items to the thing so it can make a proper crafting system every time i tried to do a && then previous code it doesn't work so how do i make it so it like if you got 4 carrots and 2 oils you can amke stuff |
In response to Mastergamerxxx
|
|
Check if you have 4 carrots. If you do, continue, if not, break.
If you do have 4 carrots, then check if you have 2 oils. If you do, continue, if not, break. If you do have 2 oils, that means you have all the requirements for the recipe. Decrease 4 carrots from the carrots, and 2 oils from the oils, and then create a new 'carrot soup' object. This can be altered to make any recipe you need. |
In response to Warlord Fred
|
|
I need a code sample of this i do not comprehend how to do this i do not know exactly what format of coding to do this in with this code i have
|
In response to Mastergamerxxx
|
|
Use if() on the quantity variables of the objects involved in the recipe.
|
I think it would be better to give all items a "quantity" variable, and then decipher between stackable and non-stackable by the value of this variable.
obj/item/var/quantity Like this, any item with a value of -1 means that it does not stack, which means that all you have to do is check for a variable value rather than the item's type. Less resource intensive. Any items with a value 0 or greater means it stacks. Obviously if it has a 0 value, then it should be deleted, haha |