dfpyre 0.7.11__tar.gz → 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dfpyre might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dfpyre
3
- Version: 0.7.11
3
+ Version: 0.8.0
4
4
  Summary: A package for creating and modifying code templates for the DiamondFire Minecraft server.
5
5
  Home-page: https://github.com/Amp63/pyre
6
6
  License: MIT
@@ -18,7 +18,7 @@ Description-Content-Type: text/markdown
18
18
 
19
19
  # pyre
20
20
 
21
- A package for external creation of code templates for the DiamondFire Minecraft server (mcdiamondfire.com).
21
+ A package for external creation of code templates for the DiamondFire Minecraft server (mcDiamondFire.com).
22
22
 
23
23
  PyPi Link: https://pypi.org/project/dfpyre/
24
24
 
@@ -34,8 +34,8 @@ pip install dfpyre
34
34
  - All code item types
35
35
  - Direct sending to DF via recode or codeclient
36
36
  - Automatic type conversion (int to num, str to text)
37
- - Name checking ("did you mean ___?" for close matches)
38
- - Default tag values
37
+ - Warnings for unrecognized actions and tags
38
+ - Full tag support
39
39
 
40
40
  ## Documentation
41
41
  ## Basics
@@ -73,92 +73,64 @@ pip install dfpyre
73
73
  - [Editing Tags](#editing-tags)
74
74
  - [Importing from Code](#importing-from-code)
75
75
  - [Script Generation](#script-generation)
76
- - [Method List](#method-list)
76
+ - [Function List](#function-list)
77
77
 
78
78
  ___
79
79
 
80
- ### Setup
80
+ ## Setup
81
81
 
82
- To start creating in pyre, you have to create a DFTemplate object like so:
82
+ To start creating in pyre, use the `player_event`, `entity_event`, `function`, or `process` functions to start a template.
83
83
 
84
84
  ```py
85
85
  from dfpyre import *
86
- t = DFTemplate()
87
- ```
88
-
89
- Basically everything stems from this template object.
90
86
 
91
- This is the basic layout of a file:
87
+ template = player_event('Join', [
92
88
 
93
- ```py
94
- from dfpyre import *
95
- t = DFTemplate()
96
- # [Event, Function, or Process]
97
- # [Your code here]
98
- t.build()
89
+ ])
99
90
  ```
100
91
 
101
- The commented lines represent where you will insert calls to methods in the template object.
92
+ You can then insert additional codeblocks inside of that first function call.
102
93
 
103
94
  Here's a complete program that prints a message to every player when a player joins:
104
95
 
105
96
  ```py
106
97
  from dfpyre import *
107
- t = DFTemplate()
108
- t.player_event('Join')
109
- t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
110
- t.build_and_send('codeclient')
98
+
99
+ player_event('Join', [
100
+ player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
101
+ ]).build_and_send('codeclient')
111
102
  ```
112
103
 
113
- ### Events and Actions
104
+ ## Events and Actions
114
105
 
115
106
  You can find a list of events and actions [here](#method-list)
116
107
 
117
- As shown in [setup](#setup), every code line must start with an event, function, or process. After that, you're free to put anything you want.
118
-
119
108
  The following program sends a message to all players and gives a player 10 apples upon joining:
120
109
 
121
110
  ```py
122
111
  from dfpyre import *
123
- t = DFTemplate()
124
- t.player_event('Join')
125
- t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
126
- t.player_action('GiveItems', item('apple', 10))
112
+
113
+ player_event('Join', [
114
+ player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
115
+ player_action('GiveItems', Item('apple', 10))
116
+ ]).build_and_send('codeclient')
127
117
  ```
128
118
 
129
- ### Building
119
+ ## Building
130
120
 
131
121
  You have 2 different options for building your code line.
132
122
  You can either:
133
123
 
134
124
  1. Save the compressed template code to a variable and send it to minecraft later
125
+ - Use the `build` method on a template object
135
126
  2. Build and send directly to your minecraft client (recommended)
127
+ - Use the `build_and_send` method on a template object
136
128
 
137
- If you choose the first option, the code would look something like this:
138
-
139
- ```py
140
- from dfpyre import *
141
- t = DFTemplate()
142
- t.player_event('Join')
143
- t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
144
- template_code = t.build() # do whatever you want with this
145
- ```
146
-
147
- If you choose the second option, you can do this:
148
-
149
- ```py
150
- from dfpyre import *
151
- t = DFTemplate()
152
- t.player_event('Join')
153
- t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
154
- t.build_and_send('codeclient') # builds and sends automatically to minecraft
155
- ```
156
-
157
- ### Variable Items
129
+ ## Variable Items
158
130
 
159
131
  ### Text
160
132
 
161
- Represents a diamondfire text item:
133
+ Represents a DiamondFire text item:
162
134
 
163
135
  ```py
164
136
  text('hello %default.')
@@ -168,63 +140,67 @@ If a regular string is passed to a method as a chest parameter, it will automati
168
140
 
169
141
  ```py
170
142
  # These do the same thing:
171
- t.player_action('SendMessage', text('%default joined.'))
172
- t.player_action('SendMessage', '%default joined.')
143
+ player_action('SendMessage', Text('%default joined.'))
144
+ player_action('SendMessage', '%default joined.')
173
145
  ```
174
146
 
175
147
  ### Number
176
148
 
177
- Represents a diamondfire number item:
149
+ Alias: `Num`
150
+
151
+ Represents a DiamondFire number item:
178
152
 
179
153
  ```py
180
- num(5)
181
- num(3.14)
154
+ Number(5)
155
+ Number(3.14)
182
156
  ```
183
157
 
184
158
  If a regular integer or float is passed to a method as a chest parameter, it will automatically be converted to a num object:
185
159
 
186
160
  ```py
187
161
  # These do the same thing:
188
- t.set_variable('=', var('number'), num(10))
189
- t.set_variable('=', var('number'), 10)
162
+ set_variable('=', Variable('number'), num(10))
163
+ set_variable('=', Variable('number'), 10)
190
164
  ```
191
165
 
192
166
  ### Variable
193
167
 
194
- Represents a diamondfire variable item:
168
+ Alias: `Var`
169
+
170
+ Represents a DiamondFire variable item:
195
171
 
196
172
  ```py
197
- var('num')
198
- var('text1')
173
+ Variable('num')
174
+ Variable('text1')
199
175
  ```
200
176
 
201
177
  You can set variable values by using the `set_variable` method:
202
178
 
203
179
  ```py
204
- t.set_variable('=', var('num'), 12) # sets 'num' to 12
205
- t.set_variable('x', var('doubled'), var('num'), 2) # sets 'doubled' to 24
180
+ set_variable('=', Variable('num'), 12) # sets 'num' to 12
181
+ set_variable('x', Variable('doubled'), Variable('num'), 2) # sets 'doubled' to 24
206
182
  ```
207
183
 
208
- You can set the scope of the variable by using the `scope` argument:
184
+ You can set the scope of the variable using the `scope` argument:
209
185
 
210
186
  ```py
211
- t.set_variable('=', var(num1, scope='unsaved'), 12) # `unsaved` is the same as a game variable.
212
- t.set_variable('=', var(num1, scope='saved'), 12)
213
- t.set_variable('=', var(num1, scope='local'), 12)
187
+ set_variable('=', Variable('num1', scope='unsaved'), 12) # `unsaved` is the same as a game variable.
188
+ set_variable('=', Variable('num2', scope='saved'), 12)
189
+ set_variable('=', Variable('num3', scope='local'), 12)
214
190
  ```
215
191
 
216
192
  #### Shorthand Variables
217
193
 
218
- You can also use the variable shorthand format like this:
194
+ You can also use the variable shorthand format to express variables more tersely:
219
195
  ```py
220
196
  # These do the same thing:
221
- t.set_variable('=', var('lineVar', scope='line'), 5)
222
- t.set_variable('=', '$ilineVar', 5)
197
+ set_variable('=', Variable('lineVar', scope='line'), 5)
198
+ set_variable('=', '$i lineVar', 5)
223
199
  ```
224
200
 
225
- Shorthand vars should be formatted like this: `$[scope id][var name]`
201
+ Shorthand vars should be formatted like this: `$[scope id] [var name]`
226
202
 
227
- Here's a list of the scope IDs:
203
+ Here's the list of scope IDs:
228
204
  - `g` = Game (unsaved)
229
205
  - `s` = Saved
230
206
  - `l` = Local
@@ -232,20 +208,23 @@ Here's a list of the scope IDs:
232
208
 
233
209
  ### Location
234
210
 
235
- Represents a diamondfire location item:
211
+ Alias: `Loc`
212
+
213
+ Represents a DiamondFire location item:
236
214
 
237
215
  ```py
238
- loc(x=25.5, y=50, z=25.5, pitch=0, yaw=-90)
216
+ Location(x=25.5, y=50, z=25.5, pitch=0, yaw=-90)
239
217
  ```
240
218
 
241
219
  Example:
242
220
 
243
221
  ```py
244
- # teleport player on join
222
+ # Teleport player on join
245
223
  from dfpyre import *
246
- t = DFTemplate()
247
- t.player_event('Join')
248
- t.player_action('Teleport', loc(10, 50, 10))
224
+
225
+ player_event('Join', [
226
+ player_action('Teleport', Location(10, 50, 10))
227
+ ])
249
228
  ```
250
229
 
251
230
  ### Item
@@ -253,58 +232,64 @@ t.player_action('Teleport', loc(10, 50, 10))
253
232
  Represents a minecraft item:
254
233
 
255
234
  ```py
256
- item('stick', count=5)
257
- item('stone', 64)
235
+ Item('stick', count=5)
236
+ Item('stone', 64)
258
237
  ```
259
238
 
260
239
  To add extra data to an item, you can use any methods from the [mcitemlib](https://github.com/Amp63/mcitemlib) library
261
240
 
262
241
  ### Sound
263
242
 
264
- Represents a diamondfire sound item:
243
+ Alias: `Snd`
244
+
245
+ Represents a DiamondFire sound item:
265
246
 
266
247
  ```py
267
- sound('Wood Break', pitch=1.5, vol=2.0)
248
+ Sound('Wood Break', pitch=1.5, vol=2.0)
268
249
  ```
269
250
 
270
251
  Example:
271
252
 
272
253
  ```py
273
- # plays 'Grass Place' sound on join
254
+ # Plays 'Grass Place' sound on join
274
255
  from dfpyre import *
275
- t = DFTemplate()
276
- t.player_event('Join')
277
- t.player_action('PlaySound', sound('Grass Place'))
256
+
257
+ player_event('Join', [
258
+ player_action('PlaySound', Sound('Grass Place'))
259
+ ])
278
260
  ```
279
261
 
280
262
  ### Particle
281
263
 
282
- Represents a diamondfire particle item:
264
+ Represents a DiamondFire particle item:
283
265
 
284
266
  ```py
285
- particle({'particle':'Cloud','cluster':{'amount':1,'horizontal':0.0,'vertical':0.0},'data':{'x':1.0,'y':0.0,'z':0.0,'motionVariation':100}})
267
+ Particle({'particle':'Cloud','cluster':{'amount':1,'horizontal':0.0,'vertical':0.0},'data':{'x':1.0,'y':0.0,'z':0.0,'motionVariation':100}})
286
268
  ```
287
269
 
288
270
  Example:
289
271
 
290
272
  ```py
291
- # plays a white cloud particle effect at 5, 50, 5
273
+ # Plays a white cloud particle effect at 5, 50, 5
292
274
  from dfpyre import *
293
- t = DFTemplate()
294
- t.player_event('Join')
295
- part = particle({'particle':'Cloud','cluster':{'amount':1,'horizontal':0.0,'vertical':0.0},'data':{'x':1.0,'y':0.0,'z':0.0,'motionVariation':100}})
296
- t.player_action('Particle', part, loc(5, 50, 5))
275
+
276
+ part = Particle({'particle':'Cloud','cluster':{'amount':1,'horizontal':0.0,'vertical':0.0},'data':{'x':1.0,'y':0.0,'z':0.0,'motionVariation':100}})
277
+ player_event('Join', [
278
+ player_action('Particle', part, loc(5, 50, 5))
279
+ ])
297
280
  ```
298
281
 
299
282
  Currently, the particle object does not support colors.
300
283
 
301
284
  ### Potion
302
285
 
303
- Represents a diamondfire potion item:
286
+ Alias: `Pot`
287
+
288
+ Represents a DiamondFire potion item:
304
289
 
305
290
  ```py
306
291
  # gives speed 1 for 1 minute
307
- potion('Speed', dur=1200, amp=0)
292
+ Potion('Speed', dur=1200, amp=0)
308
293
  ```
309
294
 
310
295
  Example:
@@ -312,18 +297,19 @@ Example:
312
297
  ```py
313
298
  # gives the player infinite saturation 255
314
299
  from dfpyre import *
315
- t = DFTemplate()
316
- t.player_event('Join')
317
- t.player_action('GivePotion', potion('Saturation', amp=254))
300
+
301
+ player_event('Join', [
302
+ player_action('GivePotion', Potion('Saturation', amp=10))
303
+ ])
318
304
  ```
319
305
 
320
306
  ### Game Value
321
307
 
322
- Represents a diamondfire game value item:
308
+ Represents a DiamondFire game value item:
323
309
 
324
310
  ```py
325
- gamevalue('Player Count')
326
- gamevalue('Location' target='Selection')
311
+ GameValue('Player Count')
312
+ GameValue('Location' target='Selection')
327
313
  ```
328
314
 
329
315
  Example:
@@ -331,17 +317,20 @@ Example:
331
317
  ```py
332
318
  # function that prints player count and cpu
333
319
  from dfpyre import *
334
- t = DFTemplate()
335
- t.function('printData')
336
- t.player_action('SendMessage', gamevalue('Player Count'), gamevalue('CPU Usage'))
320
+
321
+ function('printData', [
322
+ player_action('SendMessage', GameValue('Player Count'), GameValue('CPU Usage'))
323
+ ])
337
324
  ```
338
325
 
339
326
  ### Vector
340
327
 
341
- Represents a diamondfire vector item:
328
+ Alias: `Vec`
329
+
330
+ Represents a DiamondFire vector item:
342
331
 
343
332
  ```py
344
- vector(x=1.1, y=0.0, z=0.5)
333
+ Vector(x=1.1, y=0.0, z=0.5)
345
334
  ```
346
335
 
347
336
  Example:
@@ -349,17 +338,18 @@ Example:
349
338
  ```py
350
339
  # sets the player's x velocity to 1.0 on join
351
340
  from dfpyre import *
352
- t = DFTemplate()
353
- t.player_event('Join')
354
- t.player_action('SetVelocity', vector(x=1.0, y=0.0, z=0.0))
341
+
342
+ player_event('Join', [
343
+ player_action('SetVelocity', Vector(x=1.0, y=0.0, z=0.0))
344
+ ])
355
345
  ```
356
346
 
357
347
  ### Parameter
358
348
 
359
- Represents a diamondfire parameter item:
349
+ Represents a DiamondFire parameter item:
360
350
 
361
351
  ```py
362
- parameter('text', ParameterType.STRING)
352
+ Parameter('text', ParameterType.STRING)
363
353
  ```
364
354
 
365
355
  Example:
@@ -367,44 +357,44 @@ Example:
367
357
  ```py
368
358
  # builds a function that says "Hello, [name]" where `name` is the inputted parameter.
369
359
  from dfpyre import *
370
- t = DFTemplate()
360
+
371
361
  name_parameter = parameter('name', ParameterType.TEXT)
372
- t.function('SayHi', name_parameter)
373
- t.player_action('SendMessage', 'Hello, ', var('name', 'line'))
362
+ function('SayHi', name_parameter codeblocks=[
363
+ player_action('SendMessage', 'Hello, ', Variable('name', 'line'))
364
+ ])
374
365
  ```
375
366
 
376
367
  ### Conditionals and Brackets
377
368
 
378
369
  A list of conditionals and loops can be found [here](#method-list).
379
370
 
380
- A specific syntax must be followed when creating conditionals and loops. Each conditional statement must be followed by a `bracket()` method, which will contain code. Here's an example:
371
+ A specific syntax must be followed when creating conditionals and loops. Here's an example:
381
372
 
382
373
  ```py
383
- # prints 'clicked' when a player right clicks with a stick in their hand
374
+ # Prints 'clicked' when a player right clicks with a stick in their hand
384
375
  from dfpyre import *
385
- t = DFTemplate()
386
- t.player_event('RightClick')
387
- t.if_player('IsHolding', item('stick'))
388
- t.bracket(
389
- t.player_action('SendMessage', 'clicked')
390
- )
376
+
377
+ player_event('RightClick', [
378
+ if_player('IsHolding', Item('stick'), codeblocks=[
379
+ player_action('SendMessage', 'clicked')
380
+ ])
381
+ ])
391
382
  ```
392
383
 
393
384
  To create an `else` statement, use the `else_` method:
394
385
 
395
386
  ```py
396
- # says the player is 'on the ground' when grounded and 'in the air' otherwise.
387
+ # Says the player is 'on the ground' when grounded and 'in the air' otherwise.
397
388
  from dfpyre import *
398
- t = DFTemplate()
399
- t.function('grounded')
400
- t.if_player('IsGrounded')
401
- t.bracket(
402
- t.player_action('ActionBar', 'on the ground')
403
- )
404
- t.else_()
405
- t.bracket(
406
- t.player_action('ActionBar', 'in the air')
407
- )
389
+
390
+ function('grounded' [
391
+ if_player('IsGrounded', codeblocks=[
392
+ player_action('ActionBar', 'on the ground')
393
+ ])
394
+ else_([
395
+ player_action('ActionBar', 'in the air')
396
+ ])
397
+ ])
408
398
  ```
409
399
 
410
400
  ### Loops
@@ -412,26 +402,27 @@ t.bracket(
412
402
  As for loops, the bracket syntax is the same and will automatically change to "repeat-type" brackets:
413
403
 
414
404
  ```py
415
- # prints numbers 1-5
405
+ # Prints numbers 1-5
416
406
  from dfpyre import *
417
- t = DFTemplate()
418
- t.player_event('Join')
419
- t.repeat('Multiple', var('i'), 5)
420
- t.bracket(
421
- t.player_action('SendMessage', var('i'))
422
- )
407
+
408
+ player_event('Join', [
409
+ repeat('Multiple', Variable('i'), 5, codeblocks=[
410
+ player_action('SendMessage', Variable('i'))
411
+ ])
412
+ ])
423
413
  ```
424
414
 
425
415
  ### Creating Functions and Processes
426
416
 
427
- To create a function or process, just start the template with a `function` or `process` method:
417
+ To create a function or process, just start the template with `function` or `process`:
428
418
 
429
419
  ```py
430
- # function that gives a player 64 golden apples
420
+ # Function that gives a player 64 golden apples
431
421
  from dfpyre import *
432
- t = DFTemplate()
433
- t.function('doStuff')
434
- t.player_action('GiveItems', item('golden_apple', 64))
422
+
423
+ function('doStuff', codeblocks=[
424
+ player_action('GiveItems', Item('golden_apple', 64))
425
+ ])
435
426
  ```
436
427
 
437
428
  ### Calling Functions and Processes
@@ -440,9 +431,10 @@ Calling Functions and processes is also simple:
440
431
 
441
432
  ```py
442
433
  from dfpyre import *
443
- t = DFTemplate()
444
- t.player_event('Join')
445
- t.call_function('doStuff')
434
+
435
+ player_event('Join', [
436
+ call_function('doStuff')
437
+ ])
446
438
  ```
447
439
 
448
440
  ### Editing Tags
@@ -450,9 +442,10 @@ You can edit an action's tags by passing the `tags` argument to a template metho
450
442
 
451
443
  ```py
452
444
  from dfpyre import *
453
- t = DFTemplate()
454
- t.player_event('Join')
455
- t.player_action('SendMessage', 'hello', tags={'Alignment Mode': 'Centered'})
445
+
446
+ player_event('Join', [
447
+ player_action('SendMessage', 'hello', tags={'Alignment Mode': 'Centered'})
448
+ ])
456
449
  ```
457
450
 
458
451
  If you choose not to modify a specific tag, its default value will be used.
@@ -464,10 +457,10 @@ You can import existing templates from their built code using the `from_code` me
464
457
 
465
458
  ```py
466
459
  from dfpyre import *
467
- template_code = 'H4sIAGVyIGYC/3WOMQ7CMAxFz4LnDsw5AhITI6qQSaw2IrGrxkJCVe5eh3boAJP9n/Kfs8AziX8VcPcFYgC3Zej26YDexGoZvUZhAxeJ3PI8WMtKSrnV+1q7P4op4Yfmx244qG7E4Uql4EA/jNv2Jc3qJU/2KqBiY4yZjI6UkpzAjkNJouDO1X7S1xUDaGUl2QAAAA=='
468
460
 
461
+ template_code = 'H4sIAGVyIGYC/3WOMQ7CMAxFz4LnDsw5AhITI6qQSaw2IrGrxkJCVe5eh3boAJP9n/Kfs8AziX8VcPcFYgC3Zej26YDexGoZvUZhAxeJ3PI8WMtKSrnV+1q7P4op4Yfmx244qG7E4Uql4EA/jNv2Jc3qJU/2KqBiY4yZjI6UkpzAjkNJouDO1X7S1xUDaGUl2QAAAA=='
469
462
  t = DFTemplate.from_code(template_code)
470
- # add onto the template from here
463
+ # Do stuff with the template here
471
464
  ```
472
465
 
473
466
 
@@ -477,13 +470,13 @@ You can also generate an equivalent python script for a template from a template
477
470
 
478
471
  ```py
479
472
  from dfpyre import *
480
- template_code = 'H4sIAGVyIGYC/3WOMQ7CMAxFz4LnDsw5AhITI6qQSaw2IrGrxkJCVe5eh3boAJP9n/Kfs8AziX8VcPcFYgC3Zej26YDexGoZvUZhAxeJ3PI8WMtKSrnV+1q7P4op4Yfmx244qG7E4Uql4EA/jNv2Jc3qJU/2KqBiY4yZjI6UkpzAjkNJouDO1X7S1xUDaGUl2QAAAA=='
481
473
 
474
+ template_code = 'H4sIAGVyIGYC/3WOMQ7CMAxFz4LnDsw5AhITI6qQSaw2IrGrxkJCVe5eh3boAJP9n/Kfs8AziX8VcPcFYgC3Zej26YDexGoZvUZhAxeJ3PI8WMtKSrnV+1q7P4op4Yfmx244qG7E4Uql4EA/jNv2Jc3qJU/2KqBiY4yZjI6UkpzAjkNJouDO1X7S1xUDaGUl2QAAAA=='
482
475
  t = DFTemplate.from_code(template_code)
483
476
  t.generate_script('my_template.py') # generated python script will be written to my_template.py
484
477
  ```
485
478
 
486
- ### Method List
479
+ ### Function List
487
480
 
488
481
  - Events / Function / Process
489
482
  - player_event
@@ -505,7 +498,6 @@ t.generate_script('my_template.py') # generated python script will be written
505
498
  - if_entity
506
499
  - else_
507
500
  - repeat
508
- - bracket
509
501
 
510
502
  - Other
511
503
  - control