Setting up a Crafting Blueprint

Setting up a Crafting Blueprint

This guide goes through creating your very own custom item and blueprint crafting flow.

Getting your Raw Materials Ready

ALCS comes stock ready with three Raw Materials for you to use.

  1. Refined Steel
  2. Glass
  3. Aluminum Alloy

Now this is enough to set up some basic crafting recipes if you want to create more advanced and specific recipes you'll need to create your own.

To do this you'll first want to navigate to wos/advswl/crafting/items/raw_materials.lua
You can use any file in the items folder for your raw materials

Once in here, you'll want to add another raw material let's add this one.

wOS:RegisterItem( {
	Name = "Kyber Crystal Fragment",
	Description = "A crystal fragment seeming with energy from the force",
	Type = WOSTYPE.RAWMATERIAL,
	Rarity = 5,
	Model = "models/white/white.mdl",
} )
The model used is a white crystal from Zhrom's Star Wars Prop Pack but you can use any model you like

Now let's explain each property here.

  • Name: Is the name of the item displayed and also the name you'd use to add it to a players inventory via the admin menu or a Lua function
  • Description: A description of the item that's shown when the player hovers over it
  • Type: This is an internal enumeration for items that tell the system what type it is.
  • Rarity: This will tell ALCS how common this item is in item spawns. The higher the number the more common.
  • Model: The model is displayed in the inventory and world.

Now that we have our Raw Materials setup let's create our blueprint.

Creating Your Blueprint.

Once again in the wos/advswl/crafting/items folder, you'll want to create a .lua file for your blueprint.
The standard convention for this folder is itemType_itemName.lua but you can name them anything you like

Let us create a blueprint_crystal.lua file. In this file, we're gonna place the following code.

local ITEM = {}
ITEM.Rarity = 10

ITEM.Name = "Kyber Crystal"

ITEM.Description = "The force within can be refined into something powerful."

ITEM.Type = WOSTYPE.BLUEPRINT

ITEM.UserGroups = false

ITEM.BurnOnUse = true

ITEM.Model = "models/gangwars/crafting/blup.mdl"

ITEM.RarityName = "Epic"
ITEM.RarityColor = Color( 175, 175, 0 )

ITEM.Ingredients = {
	[ "Kyber Crystal Fragment" ] = 10,
}

ITEM.Result = "Kyber Crystal"

ITEM.OnCrafted = function( ply )
	ply:AddSkillXP( 100 )
end

wOS:RegisterItem( ITEM )

Now lets again explain each property here: Let's start with the ones that are the same as before

  • Rarity: Affects spawn rates.
  • Name: Display name
  • Type: Tells ALCS its a blueprint
  • Description: A description of the item
  • Model: The model shown in the inventory and world Now let's have a look at what new
  • UserGroups: This allows you to restrict what user groups are allowed to craft this item
  • BurnOnUse: Should this item be destroyed after it is used for crafting?
  • RarityName: Display an extra rarity name on the item, defaults to Common
  • RarityColor: Change the display colour of the item information menu, defaults to white
  • Result: The name of the item the player receives upon crafting this blueprint
  • Ingredients: Now this is a dictionary containing the ingredients needed to craft the item, you could increase the number of raw materials needed here or even add another one.
  • OnCrafted: This is a function run when the item is crafted, you can use this to do more advanced logic if you need to

Now that we have our blueprint set up it's time to set up our item.

Creating your Item

This starts the same as the last section by creating another item file. We'll call this one crystal_kyber.lua and we'll place the following code inside.

local ITEM = {}
ITEM.Rarity = 100

--The name of the item ( is also an identifier for spawning the item )
ITEM.Name = "Kyber Crystal"

--The description that appears with the item name
ITEM.Description = "A crystal seeming with energy from the force"

--The category it belongs to
ITEM.Type = WOSTYPE.CRYSTAL

--Add user groups that are allowed to use this tree. If anyone is allowed, set this to FALSE ( TREE.UserGroups = false )
ITEM.UserGroups = false

--Does this item disappear from the inventory after it's been applied?
ITEM.BurnOnUse = false

--The model of the item on the floor / inventory
ITEM.Model = "models/white/white.mdl"

--The chance for the item to appear randomly. 0 = will not spawn, 100 = incredibly high chance
ITEM.Rarity = 20

ITEM.DismantleParts = {
	[ "Kyber Crystal Fragment" ] = 8,
}

ITEM.OnEquip = function( wep )
	wep.UseColor = Color( 255, 255, 255 )
	wep.SaberDamage = wep.SaberDamage + 10
end

wOS:RegisterItem( ITEM )

Now let's go through the new properties in this file.

  • OnEquip: This is the function that's run when the item is equipped, it will also be rerun every time the lightsaber is deployed for the first time (after a player death, weapon drop, etc). This is where you'll do things like set the blade colour, length, any extra damage, etc.
  • DismantleParts: This is a table similar to the Ingredients except the player will receive these Raw Materials when dismantling this item instead.

Next Steps

Now that the items are all setup they will appear in your normal spawn pools and you can craft them via the crafting machine.

wikOS powered By wiltOS Technologies