I am scripting an armor set for a server I am hosting for my friends and I am trying to make each piece of armor only craftable once globally. I have scowered the internet and skUnity for an answer, but I haven't found one. When I do "/sk reload armor.sk" I get the error "Line 44: (armor.sk) Variables cannot be used here. Line: On Craft of (opHelmet):" I understand what the error is saying, I just can't get around it. Here is my code:
on load:
#One time crafting variables
set {craftedHelmet} to false
set {craftedChestplate} to false
set {craftedLeggings} to false
set {craftedBoots} to false
#Eternal Helmet
set {opHelmet} to netherite helmet
add armor trim using quartz_material with silence_pattern to armor trim of {opHelmet}
enchant {opHelmet} with protection 6
#Eternal Chestplate
set {opChestplate} to netherite chestplate
add armor trim using quartz_material with silence_pattern to armor trim of {opChestplate}
enchant {opChestplate} with protection 999
#Eternal Leggings
set {opLeggings} to netherite leggings
add armor trim using quartz_material with silence_pattern to armor trim of {opLeggings}
enchant {opLeggings} with protection 6
#Eternal Boots
set {opBoots} to netherite boots
add armor trim using quartz_material with silence_pattern to armor trim of {opBoots}
enchant {opBoots} with protection 6 and feather falling 6
#Recipes
register new shaped recipe for {opHelmet} named "&c&lEternal Helmet" using ominous trial key, heavy core, ominous trial key, blaze rod, air, blaze rod, air, air and air with id "Eternal Helmet"
register new shaped recipe for {opChestplate} named "&c&lEternal Chestplate" using netherite ingot, air, netherite ingot, diamond block, heavy core, diamond block, blaze rod, blaze rod and blaze rod with id "Eternal Chestplate"
register new shaped recipe for {opLeggings} named "&c&lEternal Leggings" using ancient debris, heavy core, ancient debris, blaze rod, air, blaze rod, echo shard, air and echo shard with id "Eternal Leggings"
register new shaped recipe for {opBoots} named "&c&lEternal Boots" using ominous trial key, heavy core, ominous trial key, enchanted golden apple, diamond block, enchanted golden apple, nether wart, nether wart and nether wart with id "Eternal Boots"
command /givearmor:
trigger:
give {opHelmet} to player
give {opChestplate} to player
give {opLeggings} to player
give {opBoots} to player
#One time crafting
On Craft of {opHelmet}:
if {craftedHelmet} is false:
set {craftedHelmet} to true
else:
cancel event
send "&eThis item has already been crafted!" to player
on load:
#One time crafting variables
set {craftedHelmet} to false
set {craftedChestplate} to false
set {craftedLeggings} to false
set {craftedBoots} to false
#Eternal Helmet
set {opHelmet} to netherite helmet
add armor trim using quartz_material with silence_pattern to armor trim of {opHelmet}
enchant {opHelmet} with protection 6
#Eternal Chestplate
set {opChestplate} to netherite chestplate
add armor trim using quartz_material with silence_pattern to armor trim of {opChestplate}
enchant {opChestplate} with protection 999
#Eternal Leggings
set {opLeggings} to netherite leggings
add armor trim using quartz_material with silence_pattern to armor trim of {opLeggings}
enchant {opLeggings} with protection 6
#Eternal Boots
set {opBoots} to netherite boots
add armor trim using quartz_material with silence_pattern to armor trim of {opBoots}
enchant {opBoots} with protection 6 and feather falling 6
#Recipes
register new shaped recipe for {opHelmet} named "&c&lEternal Helmet" using ominous trial key, heavy core, ominous trial key, blaze rod, air, blaze rod, air, air and air with id "Eternal Helmet"
register new shaped recipe for {opChestplate} named "&c&lEternal Chestplate" using netherite ingot, air, netherite ingot, diamond block, heavy core, diamond block, blaze rod, blaze rod and blaze rod with id "Eternal Chestplate"
register new shaped recipe for {opLeggings} named "&c&lEternal Leggings" using ancient debris, heavy core, ancient debris, blaze rod, air, blaze rod, echo shard, air and echo shard with id "Eternal Leggings"
register new shaped recipe for {opBoots} named "&c&lEternal Boots" using ominous trial key, heavy core, ominous trial key, enchanted golden apple, diamond block, enchanted golden apple, nether wart, nether wart and nether wart with id "Eternal Boots"
command /givearmor:
trigger:
give {opHelmet} to player
give {opChestplate} to player
give {opLeggings} to player
give {opBoots} to player
#One time crafting
On Craft of {opHelmet}:
if {craftedHelmet} is false:
set {craftedHelmet} to true
else:
cancel event
send "&eThis item has already been crafted!" to player