Jump to content

On Craft


lilw

Recommended Posts

on craft:
  if item is {_i1}:
    stop
  if item is {_i2}:
    stop
  if item is {_i3}:
    stop
  if item is {_i4}:
    stop
  if item is {_i5}:
    stop
  if item is {_i6}:
    stop
  if item is {_i7}:
    stop
  if item is {_i8}:
    stop
  if item is {_i9}:
    stop
  if item is {_i10}:
    stop
  #etc to 100...

How would I make this shorter? I tried
 

on craft:
  loop 100 times:
  add 1 to {_number}
  if item is {_i{_number}}:
    stop
  

But it didnt seem to work.
Any suggestions?

Link to comment
Share on other sites

23 minutes ago, Adramelke said:

{_i%{_number}%}

 

also these are local variables that aren't set before they're used...

this didnt work 😞

 

on load:
  set {_i1} to redstone named "&dRegen Spark" with no nbt
  set {_i2} to sugar named "&bSpeed Spark" with no nbt
  set {_i3} to 8 arrows named "&aMercury Arrow" with no nbt#posion arrows
  set {_i4} to scute named "&aPhotosynthesiser" with no nbt#damages by 2 in a 5 radius
  set {_item} to leather helmet named "&aOak Helmet" 
  dye {_item} (144, 238, 144)
  set {_i5} to {_item}
  set {_item} to leather chestplate named "&aOak Chestplate" 
  dye {_item} (144, 238, 144)
  set {_i6} to {_item}
  set {_item} to leather leggings named "&aOak Leggings" 
  dye {_item} (144, 238, 144)
  set {_i7} to {_item}
  set {_item} to leather boots named "&aOak Boots"  
  dye {_item} (144, 238, 144)
  set {_i8} to {_item}
  set {_i9} to totem of undying named "&6Midas' Jewel" with no nbt
  set {_i10} to ghast tear named "&7Large Iron Fragment" with no nbt 
  set {_i11} to iron ingot named "&7Iron Ingot" with no nbt
  set {_i12} to blaze rod named "&6Strontium" with no nbt
  set {_i13} to nether bricks named "&5Obsidian Spark" with no nbt
  set {_i14} to lime dye named "&aDash Spark" with no nbt
  set {_i15} to magma cream named "&6Golden Spark" with no nbt
  set {_i16} to orange dye named "&6Midas Gel" with no nbt
  set {_i17} to ender pearl named "&5Enderpearl" with no nbt 
  set {_i18} to gray dye named "&fArrow &7Storm &fSpark" with no nbt
  set {_i19} to iron boots named "&7Steel Boots" 
  set {_i20} to iron leggings named "&7Steel Leggings" 
  set {_i21} to iron chestplate named "&7Steel Chestplate" 
  set {_i22} to iron helmet named "&7Steel Helmet" 
  set {_1item} to iron helmet named "&8Enhanced Steel Helmet" 
  enchant {_1item} with protection 1
  set {_i23} to {_1item}
  set {_2item} to iron leggings named "&8Enhanced Steel Leggings" 
  enchant {_2item} with protection 1
  set {_i24} to {_2item}
  set {_3item} to iron chestplate named "&8Enhanced Steel Chestplate" 
  enchant {_3item} with protection 1
  set {_i25} to {_3item}
  set {_4item} to iron boots named "&8Enchanced Steel Boots" 
  enchant {_4item} with protection 1
  set {_i26} to {_4item}
  set {_i27} to crafting table named "&6Crafting Table"
  set {_i28} to 4 oak planks named "&6Oak Planks"
  set {_i29} to 4 oak stairs named "&6Oak Stairs"

  register new shaped recipe for {_i1} using spruce leaves, oak Wood, spruce leaves, oak Wood, purple dye, oak Wood, spruce leaves and oak Wood, spruce leaves with id "regen_spark" in group "MIDAS BOX"
  register new shaped recipe for {_i2} using spruce leaves, oak Wood, spruce leaves, oak Wood, light blue dye, oak Wood, spruce leaves and oak Wood, spruce leaves with id "speed_spark" in group "MIDAS BOX"
  register new shaped recipe for {_i3} using arrow, arrow, arrow, arrow, firework star, arrow, arrow, arrow and arrow with id "mercury_arrow" in group "MIDAS BOX"
  register new shaped recipe for {_i4} using spruce leaves, ghast tear, spruce leaves, spruce leaves, coal, spruce leaves, andesite, andesite and andesite with id "photosynthesiser" in group "MIDAS BOX"
  register new shaped recipe for {_i5} using spruce leaves, spruce leaves, spruce leaves, oak Wood, air, oak Wood, air, air and air with id "oak_helmet" in group "MIDAS BOX"
  register new shaped recipe for {_i6} using spruce leaves, air, spruce leaves, oak Wood, oak Wood, oak Wood, spruce leaves, oak Wood and spruce leaves with id "oak_chestplate" in group "MIDAS BOX"
  register new shaped recipe for {_i7} using oak Wood, oak Wood, oak Wood, spruce leaves, air, spruce leaves, spruce leaves, air and spruce leaves with id "oak_leggings" in group "MIDAS BOX"
  register new shaped recipe for {_i8} using air, air, air, oak Wood, air, oak Wood, spruce leaves, air and spruce leaves with id "oak_boots" in group "MIDAS BOX"
  register new shaped recipe for {_i9} using black dye, yellow dye, black dye, yellow dye, diamond, yellow dye, black dye, yellow dye and black dye with id "midas_jewel" in group "MIDAS BOX"
  register new shaped recipe for {_i10} using iron nugget, iron nugget, iron nugget, iron nugget, air, iron nugget, iron nugget, iron nugget and iron nugget with id "large_iron_fragment" in group "MIDAS BOX"
  register new shaped recipe for {_i11} using ghast tear, ghast tear, ghast tear, ghast tear, air, ghast tear, ghast tear, ghast tear, and ghast tear with id "iron_ingot" in group "MIDAS BOX"
  register new shaped recipe for {_i12} using andesite, flint, andesite, flint, light blue dye, flint, andesite, flint and andesite with id "strontium" in group "MIDAS BOX"
  register new shaped recipe for {_i13} using gunpowder, gunpowder, gunpowder, gunpowder, black dye, gunpowder, gunpowder, gunpowder, and gunpowder with id "obsidian_spark" in group "MIDAS BOX"
  register new shaped recipe for {_i14} using air, light blue dye, air, ghast tear, slimeball, ghast tear, air, iron nugget and air with id "dash_spark" in group "MIDAS BOX"
  register new shaped recipe for {_i15} using glowstone, air, glowstone, glowstone, honeycomb, glowstone, air, glowstone and air with id "golden_spark" in group "MIDAS BOX"
  register new shaped recipe for {_i16} using glowstone, glowstone, glowstone, glowstone, yellow dye, glowstone, glowstone, glowstone and glowstone with id "midas_gel" in group "MIDAS BOX"
  register new shaped recipe for {_i17} using air, air, air, air, raw copper, air, air, dragon breath and air with id "enderpearl" in group "MIDAS BOX"
  register new shaped recipe for {_i18} using arrow, arrow, arrow, arrow, andesite, arrow, arrow, arrow and arrow with id "arrow_storm_spark" in group "MIDAS BOX"
  register new shaped recipe for {_i19} using air, air, air, iron ingot, air, iron ingot, iron ingot, sugar and iron ingot with id "steel_boots" in group "MIDAS BOX"
  register new shaped recipe for {_i20} using iron ingot, iron ingot, iron ingot, iron ingot, lime dye, iron ingot, iron ingot, air and iron ingot with id "steel_leggings" in group "MIDAS BOX"
  register new shaped recipe for {_i21} using iron ingot, air, iron ingot, iron ingot, lapis, iron ingot, iron ingot, iron ingot and iron ingot with id "steel_chestplate" in group "MIDAS BOX"
  register new shaped recipe for {_i22} using iron ingot, iron ingot, iron ingot, iron ingot, redstone, iron ingot, air, air and air with id "steel_helmet" in group "MIDAS BOX"
  register new shapeless recipe for {_i23} using iron helmet and iron helmet with id "enhanced_steel_helmet" in group "MIDAS BOX"
  register new shapeless recipe for {_i24} using iron leggings and iron leggings with id "enhanced_steel_leggings" in group "MIDAS BOX"
  register new shapeless recipe for {_i25} using iron chestplate and iron chestplate with id "enhanced_steel_chestplate" in group "MIDAS BOX"
  register new shapeless recipe for {_i26} using iron boots and iron boots with id "enhanced_steel_boots" in group "MIDAS BOX"
  register new shapeless recipe for {_i27} using oak plank, oak plank, oak plank and oak plank with id "crafttable" in group "MIDAS BOX"
  register new shapeless recipe for {_i28} using oak wood with id "oakplank" in group "MIDAS BOX"
  register new shaped recipe for {_i29} using air, air, oak plank, air, oak plank, oak plank, oak plank, oak plank and oak plank with id "oakstair" in group "MIDAS BOX"

on craft:
  loop 100 times:
    add 1 to {_number}
    if item is {_i%{_number}%}:
      stop
  else:
    cancel event

im really sorry if im doing anything wrong or wasting your time.

Link to comment
Share on other sites

any errors? or what's happening that is not supposed to or happening that isn't supposed to?

https://dev.bukkit.org/projects/skript/pages/variables-explanation
"

Nest Variables

Nest variables are when you put the value of an expression inside the variable name. An example could be :

{variable.%player%}

When Skript reads the variable, it will replace %player% with the name of the player. If you were to look in the variables.csv file (You should probably never look in there just in case something gets messed up, but for the sake of the example, I'm going to tell you what you might find) you would see

{variable.Demon_Penguin}

Skript would fill in the name of the player. In this case it was Demon_Penguin. This will essentially make a separate variable per player, which is used in most scripts. You can also put the value of another variable inside a variable name like this:

{favorite.%{color}%}

If {color} was set to green, then you would see {favorite.green}.

There may also be situations where you need multiple expressions to refer to the same player. For example, in a loop, you may need to refer to loop-player to get the correct player for a variable.

Local Variables

Local variables are used when you only want to use a variable for a little bit and don't want/need to save it. There can also exist multiple local variables of the same name at the same time. This is useful for things like log in events. While the code is executing for one player, another player may log in and need their own variable. In order to tell Skript you want this variable to be a local variable all you need to do is prefix the variable name with an _ Looks like this {_local} (Note that you may see it used as '*' in older posts, however in newer versions of Skript the underscore _ is used)"

this is what i was talking about for the variables...

 

Link to comment
Share on other sites

3 minutes ago, Adramelke said:

any errors? or what's happening that is not supposed to or happening that isn't supposed to?

no errors, cant get the item out of the crafting table, should be able to get it out but not any other non listed item like stone bricks for example

Link to comment
Share on other sites

try the following.... i would expect errors because i'm not testing/debugging it before i send it 🥲  i missed the important point that you want to limit crafting to only the list you're creating, sorry.

on load:
    set {_i1} to redstone named "&dRegen Spark" with no nbt
    set {_i2} to sugar named "&bSpeed Spark" with no nbt
    set {_i3} to 8 arrows named "&aMercury Arrow" with no nbt#posion arrow
    set {_i4} to scute named "&aPhotosynthesiser" with no nbt#damages by 2 in a 5 radius
    set {_item} to leather helmet named "&aOak Helmet"
    dye {_item} (144, 238, 144)
    set {_i5} to {_item}
    set {_item} to leather chestplate named "&aOak Chestplate"
    dye {_item} (144, 238, 144)
    set {_i6} to {_item}
    set {_item} to leather leggings named "&aOak Leggings"
    dye {_item} (144, 238, 144)
    set {_i7} to {_item}
    set {_item} to leather boots named "&aOak Boots"
    dye {_item} (144, 238, 144)
    set {_i8} to {_item}
    set {_i9} to totem of undying named "&6Midas' Jewel" with no nbt
    set {_i10} to ghast tear named "&7Large Iron Fragment" with no nbt
    set {_i11} to iron ingot named "&7Iron Ingot" with no nbt
    set {_i12} to blaze rod named "&6Strontium" with no nbt
    set {_i13} to nether bricks named "&5Obsidian Spark" with no nbt
    set {_i14} to lime dye named "&aDash Spark" with no nbt
    set {_i15} to magma cream named "&6Golden Spark" with no nbt
    set {_i16} to orange dye named "&6Midas Gel" with no nbt
    set {_i17} to ender pearl named "&5Enderpearl" with no nbt
    set {_i18} to gray dye named "&fArrow &7Storm &fSpark" with no nbt
    set {_i19} to iron boots named "&7Steel Boots"
    set {_i20} to iron leggings named "&7Steel Leggings"
    set {_i21} to iron chestplate named "&7Steel Chestplate"
    set {_i22} to iron helmet named "&7Steel Helmet"
    set {_1item} to iron helmet named "&8Enhanced Steel Helmet"
    enchant {_1item} with protection 1
    set {_i23} to {_1item}
    set {_2item} to iron leggings named "&8Enhanced Steel Leggings"
    enchant {_2item} with protection 1
    set {_i24} to {_2item}
    set {_3item} to iron chestplate named "&8Enhanced Steel Chestplate"
    enchant {_3item} with protection 1
    set {_i25} to {_3item}
    set {_4item} to iron boots named "&8Enchanced Steel Boots"
    enchant {_4item} with protection 1
    set {_i26} to {_4item}
    set {_i27} to crafting table named "&6Crafting Table"
    set {_i28} to 4 oak planks named "&6Oak Planks"
    set {_i29} to 4 oak stairs named "&6Oak Stairs"
        loop 29 times:
            {items::*} does not contain {_i%loop-value%}:
                add {_i%loop-value%} to {items::*}
    register new shaped recipe for {_i1} using spruce leaves, oak Wood, spruce leaves, oak Wood, purple dye, oak Wood, spruce leaves and oak Wood, spruce leaves with id "regen_spark" in group "MIDAS BOX"
    register new shaped recipe for {_i2} using spruce leaves, oak Wood, spruce leaves, oak Wood, light blue dye, oak Wood, spruce leaves and oak Wood, spruce leaves with id "speed_spark" in group "MIDAS BOX"
    register new shaped recipe for {_i3} using arrow, arrow, arrow, arrow, firework star, arrow, arrow, arrow and arrow with id "mercury_arrow" in group "MIDAS BOX"
    register new shaped recipe for {_i4} using spruce leaves, ghast tear, spruce leaves, spruce leaves, coal, spruce leaves, andesite, andesite and andesite with id "photosynthesiser" in group "MIDAS BOX"
    register new shaped recipe for {_i5} using spruce leaves, spruce leaves, spruce leaves, oak Wood, air, oak Wood, air, air and air with id "oak_helmet" in group "MIDAS BOX"
    register new shaped recipe for {_i6} using spruce leaves, air, spruce leaves, oak Wood, oak Wood, oak Wood, spruce leaves, oak Wood and spruce leaves with id "oak_chestplate" in group "MIDAS BOX"
    register new shaped recipe for {_i7} using oak Wood, oak Wood, oak Wood, spruce leaves, air, spruce leaves, spruce leaves, air and spruce leaves with id "oak_leggings" in group "MIDAS BOX"
    register new shaped recipe for {_i8} using air, air, air, oak Wood, air, oak Wood, spruce leaves, air and spruce leaves with id "oak_boots" in group "MIDAS BOX"
    register new shaped recipe for {_i9} using black dye, yellow dye, black dye, yellow dye, diamond, yellow dye, black dye, yellow dye and black dye with id "midas_jewel" in group "MIDAS BOX"
    register new shaped recipe for {_i10} using iron nugget, iron nugget, iron nugget, iron nugget, air, iron nugget, iron nugget, iron nugget and iron nugget with id "large_iron_fragment" in group "MIDAS BOX"
    register new shaped recipe for {_i11} using ghast tear, ghast tear, ghast tear, ghast tear, air, ghast tear, ghast tear, ghast tear, and ghast tear with id "iron_ingot" in group "MIDAS BOX"
    register new shaped recipe for {_i12} using andesite, flint, andesite, flint, light blue dye, flint, andesite, flint and andesite with id "strontium" in group "MIDAS BOX"
    register new shaped recipe for {_i13} using gunpowder, gunpowder, gunpowder, gunpowder, black dye, gunpowder, gunpowder, gunpowder, and gunpowder with id "obsidian_spark" in group "MIDAS BOX"
    register new shaped recipe for {_i14} using air, light blue dye, air, ghast tear, slimeball, ghast tear, air, iron nugget and air with id "dash_spark" in group "MIDAS BOX"
    register new shaped recipe for {_i15} using glowstone, air, glowstone, glowstone, honeycomb, glowstone, air, glowstone and air with id "golden_spark" in group "MIDAS BOX"
    register new shaped recipe for {_i16} using glowstone, glowstone, glowstone, glowstone, yellow dye, glowstone, glowstone, glowstone and glowstone with id "midas_gel" in group "MIDAS BOX"
    register new shaped recipe for {_i17} using air, air, air, air, raw copper, air, air, dragon breath and air with id "enderpearl" in group "MIDAS BOX"
    register new shaped recipe for {_i18} using arrow, arrow, arrow, arrow, andesite, arrow, arrow, arrow and arrow with id "arrow_storm_spark" in group "MIDAS BOX"
    register new shaped recipe for {_i19} using air, air, air, iron ingot, air, iron ingot, iron ingot, sugar and iron ingot with id "steel_boots" in group "MIDAS BOX"
    register new shaped recipe for {_i20} using iron ingot, iron ingot, iron ingot, iron ingot, lime dye, iron ingot, iron ingot, air and iron ingot with id "steel_leggings" in group "MIDAS BOX"
    register new shaped recipe for {_i21} using iron ingot, air, iron ingot, iron ingot, lapis, iron ingot, iron ingot, iron ingot and iron ingot with id "steel_chestplate" in group "MIDAS BOX"
    register new shaped recipe for {_i22} using iron ingot, iron ingot, iron ingot, iron ingot, redstone, iron ingot, air, air and air with id "steel_helmet" in group "MIDAS BOX"
    register new shapeless recipe for {_i23} using iron helmet and iron helmet with id "enhanced_steel_helmet" in group "MIDAS BOX"
    register new shapeless recipe for {_i24} using iron leggings and iron leggings with id "enhanced_steel_leggings" in group "MIDAS BOX"
    register new shapeless recipe for {_i25} using iron chestplate and iron chestplate with id "enhanced_steel_chestplate" in group "MIDAS BOX"
    register new shapeless recipe for {_i26} using iron boots and iron boots with id "enhanced_steel_boots" in group "MIDAS BOX"
    register new shapeless recipe for {_i27} using oak plank, oak plank, oak plank and oak plank with id "crafttable" in group "MIDAS BOX"
    register new shapeless recipe for {_i28} using oak wood with id "oakplank" in group "MIDAS BOX"
    register new shaped recipe for {_i29} using air, air, oak plank, air, oak plank, oak plank, oak plank, oak plank and oak plank with id "oakstair" in group "MIDAS BOX"

on craft:
    {items::*} does not contain output: #<--- i'm not sure what expression to use for the crafting output
        cancel event

 

Edited by Adramelke
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...