your current location:首页 > news>About I want to write basic algorithms in GRS .jpg [GRS] Groovyscript Minecraft Game

About I want to write basic algorithms in GRS .jpg [GRS] Groovyscript Minecraft Game

2024-12-05 23:05:42|Myriagame |source:minecraft skins

Foreword

In fact, GRS is different from CRT's self -created grammar ZS. He uses an official programming language Groovy.

Grovy is a JVM -based script language.While it is compatible with the Java syntax, it borrows the characteristics of language such as Ruby, Python, etc., and has its own set of simple and flexible grammar.

So in fact, if you want to write an algorithm in GRS, you can search Groovy.(What did wiki not give?)

This tutorial only gives the knowledge of simple basic algorithm that is not given in GRS WIKI, as well as tutorials for those who do not understand Chinese.

Secondly, I am a super -programming novice, please indicate!

This tutorial you have learned to use GRS to modify the simple formula!

Variables and array

 // We know that there are many common variables such as Byte, SHORT, INT, Long and so on.

// Here we only introduce Defer data type declaration variables.

// Let's take a look at the official example of the DEF type.

DEF NUM1 = 10 // I am an int type!

Def Num2 = 10L // I am a long type!

Def Num3 = 10 as byte // I am a Byte type!

DEF NUM4 = 10 AS Short // I am a Byte type!

DEF NUM5 = 1.0F // I am Float type!

DEF NUM6 = 1.0d // I am Double type!

DEF BOOL = TRUE // I am a Boolean type!

// As you can see the DEF type is a type of oil, that is, Dynamically type and dynamic type.

// So we can directly use it to define the data type of MC items.

// Define the variable Ironingot to represent the iron ingot in the original version.

DEF Ironingot = Item ('Minecraft: Iron_INGOT')

// Define the array ore to represent all minerals in the original version.

DEF iu = [

Item ('Minecraft: GOLD_ORE'), Item ('Minecraft: Iron_ore'), item ('Minecraft: Coal_ore'), item ('Minecraft: LAPIS_ORE'),

Item ('Minecraft: Diamond_ore'), item ('Minecraft: Redstone_ore'), item ('Minecraft: EMERALD_ORE'), item ('Minecraft: Quartz_ore')

]

GRS can actually write or not to write a score!It's too suitable for the magic to change the new!

Operator

 // The operator about the addition, subtraction and multiplication is no different from Java and C languages.

// There is still an arithmetic operating operating symbolic operator logic operating symbolic operator assignment operator assignment.

// We can use only some simple operations normally and quickly

int x = 5 // Definition x variable x ++ // x = 6

Cycle and conditional statements

 // The words here are for example, because this part is no different from other languages.

// Delete all the formula of all the swords

DEF SWORD = [

Item ('Minecraft: Wooden_sword'), item ('MINECRAFT: Stone_sword'), ITEM ('Minecraft: Iron_sword'),

Item ('Minecraft: GOLDEN_SWORD'), item ('Minecraft: Diamond_sword')

]

// There are two ways of writing

for (int i; i <5; i ++) {

Crafting.removebyoutput (sword [i])

}

// Those who need to be judged in specific numbers can be used in the above writing method, and the following methods will be used to add new elements to the array.

for (I in Sword) {

Crafting.removebyoutput (sword [i])

}

// At this time, you can also use conditional statements

for (I in Sword) {

If (sword [i] == item ('minecraft: diamond_sword')) break // If the first element of the array is equal to the diamond sword, the cycle is stopped.

Crafting.removebyoutput (sword [i])

}

Example of normal cycle convenience (my personal integration package):

I integrate the defense formula in the package (convinced

 // Define the array of 16 dyed honey juice

def honey_drop = []

for (int i = 13; i <= 28; i ++) {

Honey_drop.add (Item ('Extrabees: Honey_drop', i), i)

}

// Define the number of 16 pigment gas

def color = [

GAS ('Red.name'),

GAS ('Yellow.name'),

GAS ('Blue.name'),

Gas ('Green.name'),

GAS ('Black.name'),

GAS ('White.name'), Gas ('Brown.name'),

GAS ('Orange.name'),

Gas ('Cyan.name'),

GAS ('Purple.name'),

GAS ('Gray.name'),

GAS ('Lightblue.name'),

Gas ('Pink.name'),

GAS ('Lime.name'),

GAS ('Magenta.name'),

GAS ('Silver.name'),

]

// Increase the recipe of various dyes in the pressure reaction room

for (int t = 0; t <16; t ++) {

Mods.mekanism.pressurizeDreamChamber.RcipeBuilder ()

.Fluidinput (FLUID ('Water')*5000)

.Gasinput (Gas ('Oxygenrichedwater')*1000)

.Input (Honey_drop [t])

.Output (item ('Forestry: Honeydew')))

.Gasoutput (color [t]*500)

.Register ();}

// Provide the formula of the blueprints at all stages

// Blueprint formula in the industrial stage

DEF BLUEPRINT_IC2 = [

Item ('ModularMachinery: Itemblueprint'). Withnbt

Item ('ModularMachinery: Itemblueprint'). Withnbt

Item ('ModularMachinery: Itemblueprint'). Withnbt (["Dynamicmachine": "ModularMachinery: Rock_switch"],),

Item ('ModularMachinery: Itemblueprint'). Withnbt (["DynamicMachine": "ModularMachinery: Small_scale_prcessor"],

Item ('ModularMachinery: Itembluprint'). Withnbt (["Dynamicmachine": "ModularMachinery: Steel_resmelting_furnace"])

]

for (int BP1 = 0; BP1 <5; BP1 ++) {

If (bp1 == 4) {

Mods.enderio.alloy_smelter.Recipebuilder ()

.Input (ITEM ('IC2: Misc_resource', 6), blueprint_ic2 [bp1])

.Output (blueprint_ic2 [0])

. Energy (512)

.Xp (10)

.Tierany ()

.Register (); BREAK

}

Mods.enderio.alloy_smelter.Recipebuilder ()

.Input (ITEM ('IC2: Misc_resource', 6), blueprint_ic2 [bp1])

.Output (blueprint_ic2.get (BP1+1)))

. Energy (512)

.Xp (10)

.Tierany ()

.Register ();

}

You can write a simple algorithm when you see here!

I am also cute!To be continued!