Skip to content

Commit 26e2bc4

Browse files
Merge pull request #31 from RevolvingMadness/Change-README.md-to-work-with-the-new-function-styles
Updated README.md
2 parents 5799b55 + 453ca0a commit 26e2bc4

File tree

1 file changed

+88
-50
lines changed

1 file changed

+88
-50
lines changed

README.md

Lines changed: 88 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ It is up to you to discover most of the language through the progression system.
5151
However, every good README needs a hello world.
5252

5353
```ruby
54-
print "Hello, World!"
54+
print("Hello, World!")
5555
```
5656
This can be written into a book, and right-clicked into a Copper Golem. right-click again to run.
5757
<br />
@@ -73,14 +73,14 @@ You can join our discord server [here](https://discord.gg/2eR2hdYJMc).
7373
## Oxidisation and progression
7474
After a certain number of instruction executions, the golem will begin to oxidise.
7575
Interacting with the golem while holding an axe removes the rust.\
76-
If the golem is fully oxidised, it will not run anymore, but upon scraping it with an axe you will find example programs that explain the language of GolemScript.\
76+
If the golem is fully oxidised, it will not run anymore, but upon scraping it with an axe you will find example programs that explain the language of GolemScript.
7777
This process can be avoided however, by waxing the golem. As with anything copper, you can also scrape off the wax.
7878

7979

8080
## GolemScript Documentation
8181
The following (excellent) language documentation was written by xokz, from the MinecraftCommands discord.
8282

83-
By: xokz
83+
By: xokz (Edited by RevolvingMadness)
8484

8585
Code goes in a book and quill. Code can span multiple pages, but make sure there is a new line after every page!. The name of the book does not matter.
8686
Right click the minecart with the book to set the golems code, and right-click the minecart with a empty hand to execute the code.
@@ -90,7 +90,7 @@ Comments are indicated with a '#' and last until the end of the line. There are
9090

9191
EX.
9292
```ruby
93-
# this will not do anything since it is a comment
93+
# This will not do anything since it is a comment
9494
```
9595

9696
## 2. Variables
@@ -107,55 +107,70 @@ let str = "Hello"
107107
let x = 1
108108
let arr = [9, 2, -3, 6]
109109
let var = ["hello", "world"]
110-
let fizz = foo + x # this will be 8
111-
let buzz = var[x] # this will be 'world'
112-
let bar = var[2] + 7 # this will be 4
110+
# 'fizz' is now 8
111+
let fizz = foo + x
112+
# 'buzz' is now 'world'
113+
let buzz = var[x]
114+
# 'bar' is now 4
115+
let bar = var[2] + 7
113116
let obj = {a:1,b:2+3}
114117
```
115118

116119
Variables can be changed by simply redeclaring them.
117120

118121
EX.
119122
```ruby
123+
# 'foo' is now 7
120124
let foo = 7
121-
let foo = 8 # foo is now 8 instead of 7
125+
# 'foo' is now 8 instead of 7
126+
let foo = 8
122127
```
123128

124129
Arrays can be added and removed from via addition and subtraction.
125130

126131
EX.
127132
```ruby
128133
let arr = [0, 1, 2]
129-
let arr = arr + 3 # arr is now [0,1,2,3]
130-
let arr = arr - 1 # arr is now [0,1,2]
131-
let arr = arr - -1 # arr is now [1,2]
134+
# 'arr' is now [0, 1, 2]
135+
let arr = arr + 3
136+
# 'arr' is now [0, 1, 2, 3]
137+
let arr = arr - 1
138+
# 'arr' is now [0, 1, 2]
139+
let arr = arr - -1
140+
# 'arr' is now [1, 2]
132141
```
133142

134143
Objects can be added and removed from via addition and subtraction.
135144

136145
EX.
137146
```ruby
138147
let obj = {a:1,b:2,c:3}
139-
let obj = obj - "a" # obj is now {b:2,c:3}
140-
let obj = obj + {c:5,d:4} # obj is now {b:2,c:5,d:4}
148+
# 'obj' is now {a:1,b:2,c:3}
149+
let obj = obj - "a"
150+
# 'obj' is now {b:2,c:3}
151+
let obj = obj + {c:5,d:4}
152+
# 'obj' is now {b:2,c:5,d:4}
141153
```
142154

143155
Strings can be added to with addition.
144156

145157
EX.
146158
```ruby
147159
let str = "hello"
148-
print str # this will print 'hello'
160+
print(str)
161+
# This will print 'hello'
149162
let var = str + ", world!"
150-
print var # this will print 'hello, world!'
163+
print(var)
164+
# This will print 'hello, world!'
151165
```
152166

153167
Strings are just arrays of characters, so they can be indexed just like an array.
154168

155169
EX.
156170
```ruby
157171
let str = "hello, world!"
158-
print str[1] # this will print 'e'
172+
print(str[1])
173+
# This will print 'e'
159174
```
160175

161176
## 3. Printing
@@ -169,13 +184,20 @@ let bar = "xokz"
169184
let arr = [0, 4, 7]
170185
let obj = {hello:"world"}
171186

172-
print "Hello, world!" # this will print 'Hello, world!'
173-
print foo # this will print 8
174-
print name # this will print 'xokz'
175-
print arr # this will print '[0, 4, 7]'
176-
print arr[1] # this will print 4
177-
print arr[1] + foo # this will print 12
178-
print obj["hello"] # this will print 'world'
187+
print("Hello, world!")
188+
# This will print 'Hello, world!'
189+
print(foo)
190+
# This will print 8
191+
print(name)
192+
# This will print 'xokz'
193+
print(arr)
194+
# This will print '[0, 4, 7]'
195+
print(arr[1])
196+
# This will print 4
197+
print(arr[1] + foo)
198+
# This will print 12
199+
print(obj["hello"])
200+
# This will print 'world'
179201
```
180202

181203
## 4. Sleep
@@ -186,8 +208,10 @@ The provided value is how many ticks the golem will sleep for.
186208
EX.
187209
```ruby
188210
let time = 7
189-
sleep time # sleep for 7 ticks
190-
sleep 40 # sleep for 2 seconds, since 1 second is 20 ticks
211+
# Sleep for 7 ticks
212+
sleep time
213+
# Sleep for 2 seconds, since 1 second is 20 ticks
214+
sleep 40
191215
```
192216

193217
## 5. If Statements
@@ -199,22 +223,26 @@ EX.
199223
```ruby
200224
let foo = 0
201225
if foo
202-
print "success!" # this will not print since the condition results in 0
226+
print("success!")
227+
# This will not print since the condition results in 0
203228
end
204229

205230
let foo = 5
206231
if foo
207-
print "success!" # this will print because the condition did not result in 0
232+
print("success!")
233+
# This will print because the condition did not result in 0
208234
end
209235

210236
let bar = ""
211237
if bar
212-
print "success!" # this will not print since the condition results in an empty string
238+
print("success!")
239+
# This will not print since the condition results in an empty string
213240
end
214241

215242
let bar = "i love this datapack"
216243
if bar
217-
print "success!" # this will print since the condition did not result in an empty string
244+
print("success!")
245+
# This will print since the condition did not result in an empty string
218246
end
219247
```
220248

@@ -228,13 +256,15 @@ let foo = 7
228256
let bar = 5
229257

230258
if foo > bar
231-
print "success" # this will print since foo is greater than bar
259+
print("success")
260+
# This will print since foo is greater than bar
232261
end
233262

234263
let var = "hello, world"
235264

236265
if var = "goodbye, world"
237-
print "success" # this will not print since var is not "goodbye, world"
266+
print("success")
267+
# This will not print since var is not "goodbye, world"
238268
end
239269
```
240270

@@ -243,8 +273,9 @@ Strings and arrays have lengths, which can be compared against integers.
243273
EX.
244274
```ruby
245275
let str = "hello"
276+
# This will execute because the str of is less than ten
246277
if str < 10
247-
print "The length of the string is less than 10!"
278+
print("Success!")
248279
end
249280
```
250281

@@ -257,24 +288,25 @@ They execute while a condition is met.
257288

258289
EX.
259290
```ruby
260-
# this will print the numbers 0-19
261291
let i = 0
292+
# This will print the numbers 0-19
262293
while i < 20
263-
print i
294+
print(i)
264295
let i = i + 1
265296
end
266297

267-
# this will go on forever
298+
# This will run forever
268299
while 1
269-
print "wheee!"
300+
print("wheee!")
270301
end
271302
```
272303

273-
N loops execute a set number of times.
304+
`N` loops execute a set number of times.
274305

275306
```ruby
307+
# This will execute 10 times
276308
loop 10
277-
print "This will print 10 times"
309+
print("Loop")
278310
end
279311
```
280312

@@ -286,7 +318,8 @@ The array can use variables or literals.
286318
EX.
287319
```ruby
288320
let var = 1
289-
move [0, var, 0] # the golem will jump up one block
321+
move(0, var, 0)
322+
# The golem will jump up one block
290323
```
291324

292325
## 8. Getblock
@@ -297,11 +330,14 @@ EX.
297330
```ruby
298331
let best_block = "minecraft:dirt"
299332

300-
getblock [0, -1, 0] # the block under the golem is a dirt block in this example
301-
print BLOCK # will print 'minecraft:dirt'
333+
getblock(0, -1, 0)
334+
# The block under the golem is a dirt block in this example
335+
print(BLOCK)
336+
# This will print 'minecraft:dirt'
302337

338+
# This will execute because the block below is dirt
303339
if BLOCK = best_block
304-
print "Yes, dirt is the best." # this will print because the block below is dirt
340+
print("Yes, dirt is the best.")
305341
end
306342
```
307343

@@ -313,10 +349,10 @@ The slot number is 0 indexed.
313349

314350
EX.
315351
```ruby
316-
# in slot 6, we have put a dirt block.
352+
# In slot 6, we have put a dirt block.
317353

318-
place 5, [1,0,1]
319-
# this will place a dirt block diagonally to the
354+
place(5, [1, 0, 1])
355+
# This will place a dirt block diagonally to the
320356
# golem, provided there is not already a block there
321357
```
322358

@@ -325,9 +361,10 @@ The pickaxe will still lose durability.
325361

326362
EX.
327363
```ruby
328-
# in slot 7, we have an iron pickaxe.
364+
# In slot 7, we have an iron pickaxe.
329365

330-
place 6, [1,0,1] # this will mine the dirt block we placed earlier and take it back into the inventory.
366+
# This will mine the dirt block we placed earlier and take it back into the inventory.
367+
place(6, [1, 0, 1])
331368
```
332369

333370
If there is nothing in the slot, then nothing will happen.
@@ -339,9 +376,9 @@ It can be indexed like any other array.
339376

340377
EX.
341378
```ruby
342-
# if there is dirt in the first slot, print a message.
379+
# If there is dirt in the first slot, print a message.
343380
if INVENTORY[0] = "minecraft:dirt"
344-
print "yeah you got the good stuff"
381+
print("yeah you got the good stuff")
345382
end
346383
```
347384

@@ -355,5 +392,6 @@ EX.
355392
```ruby
356393
let regex = /ab?c/
357394
match regex, "abcdefg"
358-
print MATCH # prints "abc"
395+
# This prints 'abc'
396+
print(MATCH)
359397
```

0 commit comments

Comments
 (0)