Last active
March 16, 2019 17:33
-
-
Save Davoleo/b3ffe1e062feca0ab35e4e6c378c77fb to your computer and use it in GitHub Desktop.
ZenScript Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crafttweaker.oredict.IOreDictEntry; | |
/* | |
Crafttweaker Maps/Associative Arrays | |
A map (or an Associative Array, which is the proper term) is a data-type that's similiar to arrays. | |
The big difference being that a map can have non-numeric indexes. | |
A map is declared with the {} brackets and entries are specified as key: value | |
Text before the key separator ":" will be interpreted as strings even if they don't have | |
the quotation marks, so both iron and "iron" would later be accessed through map["iron"] | |
You could fetch the IOreDictEntry for oreIron from the metalObjects map | |
with -> metalObjects["iron"].ore | |
When wondering what key represents what nesting level just read | |
"as IOreDictEntry[string][string]" LEFT to right | |
So for example: | |
First [string] bracket represents the level where the iron, gold and copper keys are | |
Second [string] bracket represents the level where the ore and dust keys are | |
Thidrly IOreDictEntry, The value. | |
*/ | |
var metalObjects as IOreDictEntry[string][string] = { | |
"iron": { | |
ore: <ore:oreIron>, | |
dust: <ore:dustIron> | |
}, | |
"gold": { | |
ore: <ore:oreGold>, | |
dust: <ore:dustGold> | |
}, | |
"copper": { | |
ore: <ore:oreCopper>, | |
dust: <ore:dustCopper> | |
}, | |
"silver": { | |
ore: <ore:oreSilver>, | |
dust: <ore:dustSilver> | |
} | |
}; | |
# They can both be accessed with [key][key] or [key].memberGetter | |
print(metalObjects["iron"]["dust"].firstItem.displayName); # -> Pulverized Iron | |
print(metalObjects["copper"]["ore"].firstItem.displayName); # -> Copper Ore | |
print(metalObjects["iron"].dust.firstItem.displayName); # -> Pulverized Iron | |
print(metalObjects["copper"].ore.firstItem.displayName); # -> Copper Ore | |
/* | |
You can loop nested maps like these with | |
either the key, value iterator and grab the nested map from -> value | |
*/ | |
for key, value in metalObjects { | |
recipes.addShapeless(value.dust.firstItem * 4, | |
[<immersiveengineering:tool>, value.ore] | |
); | |
} | |
# or the key iterator and get the nested map from -> metalObjects[key] | |
for key in metalObjects { | |
recipes.addShapeless(metalObjects[key].dust.firstItem * 4, | |
[<immersiveengineering:tool>, metalObjects[key].ore] | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crafttweaker.item.IItemStack; | |
import crafttweaker.item.IIngredient; | |
//var to create variables | |
//val to create constants | |
var test = "Hello world!"; | |
val constant = "LMAO"; | |
<minecraft:apple>.addTooltip("Human apples are so good!"); | |
val items as IItemStack[] = [ | |
<minecraft:stone:3>, | |
<minecraft:stone:4>, | |
<minecraft:stone:5>, | |
<minecraft:stone:6>, | |
<minecraft:grass>, | |
<minecraft:stone:2>, | |
<minecraft:stone:1>, | |
<minecraft:dirt:1>, | |
<minecraft:dirt>, | |
<minecraft:stone> | |
]; | |
for item in items { | |
item.addTooltip("Boring Blocks"); | |
} | |
furnace.remove(<minecraft:cooked_beef>); | |
val fences as IItemStack[] = [ | |
<minecraft:fence>, | |
<minecraft:nether_brick_fence>, | |
<minecraft:spruce_fence>, | |
<minecraft:birch_fence>, | |
<minecraft:jungle_fence>, | |
<minecraft:dark_oak_fence>, | |
<minecraft:acacia_fence> | |
]; | |
for item in fences { | |
recipes.remove(item); | |
} | |
var seeds = <minecraft:pumpkin_seeds>; | |
recipes.addShaped("example1", <ore:cropPumpkin>.firstItem, [ | |
[seeds, <minecraft:dirt>, seeds] | |
]); | |
recipes.addShapedMirrored("example2", <ore:cropPumpkin>.firstItem, [ | |
[<minecraft:dirt>, null, null], | |
[null, <minecraft:dirt>, null], | |
[null, null, <minecraft:dirt>] | |
]); | |
recipes.addShapeless("example3", <ore:cropPumpkin>.firstItem, [seeds, seeds, seeds]); | |
var orePlanks = <ore:plankWood>; | |
recipes.remove(<minecraft:wooden_pressure_plate>); | |
recipes.addShaped("wpExample1", <minecraft:wooden_pressure_plate>, [ | |
[orePlanks, orePlanks, <minecraft:stick>] | |
]); | |
var teHammers = [ | |
<thermalfoundation:tool.hammer_copper>, | |
<thermalfoundation:tool.hammer_tin>, | |
<thermalfoundation:tool.hammer_silver>, | |
<thermalfoundation:tool.hammer_aluminum>, | |
<thermalfoundation:tool.hammer_nickel>, | |
<thermalfoundation:tool.hammer_platinum>, | |
<thermalfoundation:tool.hammer_steel>, | |
<thermalfoundation:tool.hammer_electrum>, | |
<thermalfoundation:tool.hammer_invar>, | |
<thermalfoundation:tool.hammer_bronze>, | |
<thermalfoundation:tool.hammer_constantan>, | |
<thermalfoundation:tool.hammer_iron>, | |
<thermalfoundation:tool.hammer_diamond>, | |
<thermalfoundation:tool.hammer_gold>, | |
<thermalfoundation:tool.hammer_lead> | |
] as IItemStack[]; | |
for i, hammer in teHammers { | |
//Re-usable item recipes | i is the iteration index | |
recipes.addShapeless("te_hammer_crush_iron" + i, <thermalfoundation:material> * 2, | |
[hammer.anyDamage().transformDamage(3), <ore:oreIron>] | |
); | |
} | |
recipes.addShaped("iron_sifting", <thermalfoundation:material>, [ | |
[<minecraft:water_bucket>, <minecraft:iron_bars>.reuse()], | |
[null, <ore:oreIron>], | |
]); | |
//----------------------- Localizations | |
var entity = "entity."; | |
var append = ".name"; | |
<thermalfoundation:tool.hammer_copper>.displayName = "COPPAHH!"; | |
<thermalfoundation:tool.hammer_constantan>.displayName = "CONSTANTANTANTANANTATANTAN"; | |
game.setLocalization(<minecraft:emerald_ore>.definition.name + append, "Green Ore"); | |
game.setLocalization(<minecraft:wooden_pickaxe>.definition.name + append, "Crappy Pickaxe"); | |
game.setLocalization(entity + game.getEntity("spider").name + append, "Really Creepy"); | |
game.setLocalization(entity + <entity:thermalfoundation:basalz>.name + append, "BASSALZO"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment