Craft Pro

by Red Hall Dev
The definitive crafting demo. [More]
To download this demo for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://RedHallDev.Craft_Pro##version=5

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://RedHallDev.Craft_Pro##version=5

139 downloads
Version 1.01
Date added: Jun 30 2015
Last updated: Aug 23 2015
4 fans
Craft Pro Description

Craft Pro is a freely available resource that makes crafting as easy as possible. There's a lot of documentation but the basics are very simple and there's a nice demo of everything so you can see how it all works.

Post any questions you have in Discussion.

It's made of 3 parts:

    Crafting Code (Crafting.dm)
Inventory Code (Inventory.dm)
Demo Files (/Demo)


You may wish to substitute in your own inventory code but you may very well find that you just want to use this inventory code instead.

Documentation

Crafting:
/*

atom
- components
A list of each component required to make the atom


- craftedAt
A list of each station a player must be within 1 tile of to
craft the atom

- tools
A list of each tool required to be in the inventory of the
player to craft the atom

obj/Item

- list/componentof
A list of everything you can create with this.
Leave it blank if you don't want to be able to craft an
item from your inventory

- Craft()
This is a proc that will be used as a verb if the item can
be crafted into something within the inventory. In other
words when componentof contains something

- New()
Add the ability to craft from the inventory if they are the
component of something

mob
- craft(atom/SOMETHING)
Attempt to craft said atom. Works when called from anywhere

atom
- canCraft()
On it's own will check for tools and crafting stations.
You can refine it and add your own skill checks or
whatever you like

- whileCrafting()
Redefine this to whatever you like. It will be called the
moment before successfully crafting something

- findComponents()
You won't ever need this or need to edit it. It finds all
components a player has which are needed and then returns
a list of each item associated with how much of it will be
used. It's a helper method for craft(SOMETHING)
*/

Inventory:
/*
mob
- inventorySlots
- inventorySlotsUsed

- spaceError()
The typical error message for when max space is reached. Used by
Inventory.dm and Crafting.dm

- spaceLeft()
Returns how much space is left in the inventory

- spaceFor(OBJECT)
Returns yes if there's enough space in the inventory for an object.
Including if the object is a stack.

- getObject(OBJECT, AMOUNT)
Probably one of the most important aspects of inventories is
controlling what happens when you attempt to get something (add it
to your inventory).

This lets you get some AMOUNT of some OBJECT. You may not pick it all
up if it stacks. But it will do its best to get what you ask without
breaking any stacking rules.

- loseObject(OBJECT, AMOUNT)
Probably one of the most important aspects of inventories is
controlling what happens when you attempt to drop something (remove it
from your inventory to move it to another location).

This lets you lose some AMOUNT of some OBJECT and move it to some
LOCATION. You may not pick it all up if it stacks. But it will do its
best to get what you ask without breaking any stacking rules.

obj/Item

An item is anything that can be picked up.

- amount
The number of units of this item. (50 stones)

- stackable
This object can represent more than 1 unit at
a time.

- stackSize
The maximum number of units that an object can
represent

- New()
Update suffix alteration made to default New()

- Del()
Make sure to update the inventory of whatever this Item is in
when it's deleted.

- setAmount()
Directly set the amount (updates the suffix)

- addAmount()
Add to this item's amount (Use carefully, you can accidently
add more units than the item can represent. You might be
looking for getObject() loseObject() instead which will
never let you add more than is available

- removeAmount()
Remove from this item's amount (Use carefully, you can accidently
add more units than the item can represent. You might be
looking for getObject() loseObject() instead which will
never let you add more than is available

- updateSuffix()
Set the suffix equal to the amount of units the item has. This
is what makes the inventory display the amount

- Pick_Up()
A verb to pick up all units of the object

- Drop()
A verb to drop all units of the object

- Pick_Up_Amount(AMOUNT)
A verb to pick up only AMOUNT units of the item

- Drop_Amount(AMOUNT)
A verb to drop only AMOUNT units of the item
*/