dfpyre 0.8.0__tar.gz → 0.8.2__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.8.0
3
+ Version: 0.8.2
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
@@ -29,6 +29,11 @@ Run the following command in a terminal:
29
29
  pip install dfpyre
30
30
  ```
31
31
 
32
+
33
+ ### CodeClient Installation
34
+
35
+ This module works best with [CodeClient](https://modrinth.com/mod/codeclient) installed. Once you've installed it, enable `CodeClient API` in the General config tab.
36
+
32
37
  ## Features
33
38
  - All code block types
34
39
  - All code item types
@@ -103,7 +108,7 @@ player_event('Join', [
103
108
 
104
109
  ## Events and Actions
105
110
 
106
- You can find a list of events and actions [here](#method-list)
111
+ You can find a list of events and actions [here](#function-list)
107
112
 
108
113
  The following program sends a message to all players and gives a player 10 apples upon joining:
109
114
 
@@ -111,7 +116,7 @@ The following program sends a message to all players and gives a player 10 apple
111
116
  from dfpyre import *
112
117
 
113
118
  player_event('Join', [
114
- player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
119
+ player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS),
115
120
  player_action('GiveItems', Item('apple', 10))
116
121
  ]).build_and_send('codeclient')
117
122
  ```
@@ -133,7 +138,7 @@ You can either:
133
138
  Represents a DiamondFire text item:
134
139
 
135
140
  ```py
136
- text('hello %default.')
141
+ Text('hello %default.')
137
142
  ```
138
143
 
139
144
  If a regular string is passed to a method as a chest parameter, it will automatically be converted to a text object:
@@ -159,7 +164,7 @@ If a regular integer or float is passed to a method as a chest parameter, it wil
159
164
 
160
165
  ```py
161
166
  # These do the same thing:
162
- set_variable('=', Variable('number'), num(10))
167
+ set_variable('=', Variable('number'), Number(10))
163
168
  set_variable('=', Variable('number'), 10)
164
169
  ```
165
170
 
@@ -275,7 +280,7 @@ from dfpyre import *
275
280
 
276
281
  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
282
  player_event('Join', [
278
- player_action('Particle', part, loc(5, 50, 5))
283
+ player_action('Particle', part, Location(5, 50, 5))
279
284
  ])
280
285
  ```
281
286
 
@@ -288,14 +293,14 @@ Alias: `Pot`
288
293
  Represents a DiamondFire potion item:
289
294
 
290
295
  ```py
291
- # gives speed 1 for 1 minute
296
+ # Gives speed 1 for 1 minute
292
297
  Potion('Speed', dur=1200, amp=0)
293
298
  ```
294
299
 
295
300
  Example:
296
301
 
297
302
  ```py
298
- # gives the player infinite saturation 255
303
+ # Gives the player infinite saturation 10
299
304
  from dfpyre import *
300
305
 
301
306
  player_event('Join', [
@@ -315,7 +320,7 @@ GameValue('Location' target='Selection')
315
320
  Example:
316
321
 
317
322
  ```py
318
- # function that prints player count and cpu
323
+ # Function that prints player count and CPU usage
319
324
  from dfpyre import *
320
325
 
321
326
  function('printData', [
@@ -336,7 +341,7 @@ Vector(x=1.1, y=0.0, z=0.5)
336
341
  Example:
337
342
 
338
343
  ```py
339
- # sets the player's x velocity to 1.0 on join
344
+ # Sets the player's x velocity to 1.0 on join
340
345
  from dfpyre import *
341
346
 
342
347
  player_event('Join', [
@@ -355,20 +360,20 @@ Parameter('text', ParameterType.STRING)
355
360
  Example:
356
361
 
357
362
  ```py
358
- # builds a function that says "Hello, [name]" where `name` is the inputted parameter.
363
+ # Builds a function that says "Hello, [name]" where `name` is the inputted parameter.
359
364
  from dfpyre import *
360
365
 
361
366
  name_parameter = parameter('name', ParameterType.TEXT)
362
- function('SayHi', name_parameter codeblocks=[
367
+ function('SayHi', name_parameter, codeblocks=[
363
368
  player_action('SendMessage', 'Hello, ', Variable('name', 'line'))
364
369
  ])
365
370
  ```
366
371
 
367
372
  ### Conditionals and Brackets
368
373
 
369
- A list of conditionals and loops can be found [here](#method-list).
374
+ A list of conditionals and loops can be found [here](#function-list).
370
375
 
371
- A specific syntax must be followed when creating conditionals and loops. Here's an example:
376
+ To create code inside of brackets, use the `codeblocks` argument. Here's an example:
372
377
 
373
378
  ```py
374
379
  # Prints 'clicked' when a player right clicks with a stick in their hand
@@ -387,19 +392,21 @@ To create an `else` statement, use the `else_` method:
387
392
  # Says the player is 'on the ground' when grounded and 'in the air' otherwise.
388
393
  from dfpyre import *
389
394
 
390
- function('grounded' [
395
+ function('grounded', codeblocks=[
391
396
  if_player('IsGrounded', codeblocks=[
392
397
  player_action('ActionBar', 'on the ground')
393
- ])
398
+ ]),
394
399
  else_([
395
400
  player_action('ActionBar', 'in the air')
396
401
  ])
397
402
  ])
398
403
  ```
399
404
 
405
+ Note that `player_event`, `entity_event`, and `else_` do not require `codeblocks=`, but all other bracket blocks do.
406
+
400
407
  ### Loops
401
408
 
402
- As for loops, the bracket syntax is the same and will automatically change to "repeat-type" brackets:
409
+ As for loops, the syntax is the same and will automatically change to "repeat-type" brackets:
403
410
 
404
411
  ```py
405
412
  # Prints numbers 1-5
@@ -420,7 +427,7 @@ To create a function or process, just start the template with `function` or `pro
420
427
  # Function that gives a player 64 golden apples
421
428
  from dfpyre import *
422
429
 
423
- function('doStuff', codeblocks=[
430
+ function('giveApples', codeblocks=[
424
431
  player_action('GiveItems', Item('golden_apple', 64))
425
432
  ])
426
433
  ```
@@ -433,12 +440,12 @@ Calling Functions and processes is also simple:
433
440
  from dfpyre import *
434
441
 
435
442
  player_event('Join', [
436
- call_function('doStuff')
443
+ call_function('giveApples')
437
444
  ])
438
445
  ```
439
446
 
440
447
  ### Editing Tags
441
- You can edit an action's tags by passing the `tags` argument to a template method:
448
+ You can modify an action's tags by passing the `tags` argument to a template method:
442
449
 
443
450
  ```py
444
451
  from dfpyre import *
@@ -466,7 +473,7 @@ t = DFTemplate.from_code(template_code)
466
473
 
467
474
  ### Script Generation
468
475
 
469
- You can also generate an equivalent python script for a template from a template object:
476
+ You can also generate an equivalent Python script for a template from a template object:
470
477
 
471
478
  ```py
472
479
  from dfpyre import *
@@ -476,9 +483,11 @@ t = DFTemplate.from_code(template_code)
476
483
  t.generate_script('my_template.py') # generated python script will be written to my_template.py
477
484
  ```
478
485
 
486
+ This feature is useful for getting a text representation of existing templates.
487
+
479
488
  ### Function List
480
489
 
481
- - Events / Function / Process
490
+ - **Events / Function / Process**
482
491
  - player_event
483
492
  - entity_event
484
493
  - function
@@ -486,12 +495,12 @@ t.generate_script('my_template.py') # generated python script will be written
486
495
  - call_function
487
496
  - start_process
488
497
 
489
- - Actions
498
+ - **Actions**
490
499
  - player_action
491
500
  - game_action
492
501
  - entity_action
493
502
 
494
- - Conditionals / Loops
503
+ - **Conditionals / Loops**
495
504
  - if_player
496
505
  - if_variable
497
506
  - if_game
@@ -499,7 +508,7 @@ t.generate_script('my_template.py') # generated python script will be written
499
508
  - else_
500
509
  - repeat
501
510
 
502
- - Other
511
+ - **Other**
503
512
  - control
504
513
  - select_object
505
514
  - set_variable
@@ -11,6 +11,11 @@ Run the following command in a terminal:
11
11
  pip install dfpyre
12
12
  ```
13
13
 
14
+
15
+ ### CodeClient Installation
16
+
17
+ This module works best with [CodeClient](https://modrinth.com/mod/codeclient) installed. Once you've installed it, enable `CodeClient API` in the General config tab.
18
+
14
19
  ## Features
15
20
  - All code block types
16
21
  - All code item types
@@ -85,7 +90,7 @@ player_event('Join', [
85
90
 
86
91
  ## Events and Actions
87
92
 
88
- You can find a list of events and actions [here](#method-list)
93
+ You can find a list of events and actions [here](#function-list)
89
94
 
90
95
  The following program sends a message to all players and gives a player 10 apples upon joining:
91
96
 
@@ -93,7 +98,7 @@ The following program sends a message to all players and gives a player 10 apple
93
98
  from dfpyre import *
94
99
 
95
100
  player_event('Join', [
96
- player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
101
+ player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS),
97
102
  player_action('GiveItems', Item('apple', 10))
98
103
  ]).build_and_send('codeclient')
99
104
  ```
@@ -115,7 +120,7 @@ You can either:
115
120
  Represents a DiamondFire text item:
116
121
 
117
122
  ```py
118
- text('hello %default.')
123
+ Text('hello %default.')
119
124
  ```
120
125
 
121
126
  If a regular string is passed to a method as a chest parameter, it will automatically be converted to a text object:
@@ -141,7 +146,7 @@ If a regular integer or float is passed to a method as a chest parameter, it wil
141
146
 
142
147
  ```py
143
148
  # These do the same thing:
144
- set_variable('=', Variable('number'), num(10))
149
+ set_variable('=', Variable('number'), Number(10))
145
150
  set_variable('=', Variable('number'), 10)
146
151
  ```
147
152
 
@@ -257,7 +262,7 @@ from dfpyre import *
257
262
 
258
263
  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}})
259
264
  player_event('Join', [
260
- player_action('Particle', part, loc(5, 50, 5))
265
+ player_action('Particle', part, Location(5, 50, 5))
261
266
  ])
262
267
  ```
263
268
 
@@ -270,14 +275,14 @@ Alias: `Pot`
270
275
  Represents a DiamondFire potion item:
271
276
 
272
277
  ```py
273
- # gives speed 1 for 1 minute
278
+ # Gives speed 1 for 1 minute
274
279
  Potion('Speed', dur=1200, amp=0)
275
280
  ```
276
281
 
277
282
  Example:
278
283
 
279
284
  ```py
280
- # gives the player infinite saturation 255
285
+ # Gives the player infinite saturation 10
281
286
  from dfpyre import *
282
287
 
283
288
  player_event('Join', [
@@ -297,7 +302,7 @@ GameValue('Location' target='Selection')
297
302
  Example:
298
303
 
299
304
  ```py
300
- # function that prints player count and cpu
305
+ # Function that prints player count and CPU usage
301
306
  from dfpyre import *
302
307
 
303
308
  function('printData', [
@@ -318,7 +323,7 @@ Vector(x=1.1, y=0.0, z=0.5)
318
323
  Example:
319
324
 
320
325
  ```py
321
- # sets the player's x velocity to 1.0 on join
326
+ # Sets the player's x velocity to 1.0 on join
322
327
  from dfpyre import *
323
328
 
324
329
  player_event('Join', [
@@ -337,20 +342,20 @@ Parameter('text', ParameterType.STRING)
337
342
  Example:
338
343
 
339
344
  ```py
340
- # builds a function that says "Hello, [name]" where `name` is the inputted parameter.
345
+ # Builds a function that says "Hello, [name]" where `name` is the inputted parameter.
341
346
  from dfpyre import *
342
347
 
343
348
  name_parameter = parameter('name', ParameterType.TEXT)
344
- function('SayHi', name_parameter codeblocks=[
349
+ function('SayHi', name_parameter, codeblocks=[
345
350
  player_action('SendMessage', 'Hello, ', Variable('name', 'line'))
346
351
  ])
347
352
  ```
348
353
 
349
354
  ### Conditionals and Brackets
350
355
 
351
- A list of conditionals and loops can be found [here](#method-list).
356
+ A list of conditionals and loops can be found [here](#function-list).
352
357
 
353
- A specific syntax must be followed when creating conditionals and loops. Here's an example:
358
+ To create code inside of brackets, use the `codeblocks` argument. Here's an example:
354
359
 
355
360
  ```py
356
361
  # Prints 'clicked' when a player right clicks with a stick in their hand
@@ -369,19 +374,21 @@ To create an `else` statement, use the `else_` method:
369
374
  # Says the player is 'on the ground' when grounded and 'in the air' otherwise.
370
375
  from dfpyre import *
371
376
 
372
- function('grounded' [
377
+ function('grounded', codeblocks=[
373
378
  if_player('IsGrounded', codeblocks=[
374
379
  player_action('ActionBar', 'on the ground')
375
- ])
380
+ ]),
376
381
  else_([
377
382
  player_action('ActionBar', 'in the air')
378
383
  ])
379
384
  ])
380
385
  ```
381
386
 
387
+ Note that `player_event`, `entity_event`, and `else_` do not require `codeblocks=`, but all other bracket blocks do.
388
+
382
389
  ### Loops
383
390
 
384
- As for loops, the bracket syntax is the same and will automatically change to "repeat-type" brackets:
391
+ As for loops, the syntax is the same and will automatically change to "repeat-type" brackets:
385
392
 
386
393
  ```py
387
394
  # Prints numbers 1-5
@@ -402,7 +409,7 @@ To create a function or process, just start the template with `function` or `pro
402
409
  # Function that gives a player 64 golden apples
403
410
  from dfpyre import *
404
411
 
405
- function('doStuff', codeblocks=[
412
+ function('giveApples', codeblocks=[
406
413
  player_action('GiveItems', Item('golden_apple', 64))
407
414
  ])
408
415
  ```
@@ -415,12 +422,12 @@ Calling Functions and processes is also simple:
415
422
  from dfpyre import *
416
423
 
417
424
  player_event('Join', [
418
- call_function('doStuff')
425
+ call_function('giveApples')
419
426
  ])
420
427
  ```
421
428
 
422
429
  ### Editing Tags
423
- You can edit an action's tags by passing the `tags` argument to a template method:
430
+ You can modify an action's tags by passing the `tags` argument to a template method:
424
431
 
425
432
  ```py
426
433
  from dfpyre import *
@@ -448,7 +455,7 @@ t = DFTemplate.from_code(template_code)
448
455
 
449
456
  ### Script Generation
450
457
 
451
- You can also generate an equivalent python script for a template from a template object:
458
+ You can also generate an equivalent Python script for a template from a template object:
452
459
 
453
460
  ```py
454
461
  from dfpyre import *
@@ -458,9 +465,11 @@ t = DFTemplate.from_code(template_code)
458
465
  t.generate_script('my_template.py') # generated python script will be written to my_template.py
459
466
  ```
460
467
 
468
+ This feature is useful for getting a text representation of existing templates.
469
+
461
470
  ### Function List
462
471
 
463
- - Events / Function / Process
472
+ - **Events / Function / Process**
464
473
  - player_event
465
474
  - entity_event
466
475
  - function
@@ -468,12 +477,12 @@ t.generate_script('my_template.py') # generated python script will be written
468
477
  - call_function
469
478
  - start_process
470
479
 
471
- - Actions
480
+ - **Actions**
472
481
  - player_action
473
482
  - game_action
474
483
  - entity_action
475
484
 
476
- - Conditionals / Loops
485
+ - **Conditionals / Loops**
477
486
  - if_player
478
487
  - if_variable
479
488
  - if_game
@@ -481,7 +490,7 @@ t.generate_script('my_template.py') # generated python script will be written
481
490
  - else_
482
491
  - repeat
483
492
 
484
- - Other
493
+ - **Other**
485
494
  - control
486
495
  - select_object
487
496
  - set_variable
@@ -0,0 +1,16 @@
1
+ from typing import Literal
2
+
3
+ PLAYER_ACTION_ACTION = Literal['SetHotbar', 'SetReducedDebug', 'CloseInv', 'GiveItems', 'NoKeepInv', 'SetHandCrafting', 'BossBar', 'SetBossBar', 'ParticleSphere', 'SetVelocity', 'Particle', 'AddInvRow', 'NoNatRegen', 'DisplayLightning', 'Damage', 'SendAnimation', 'SetXPProg', 'SetInventory', 'TpSequence', 'Heal', 'SetSpawnPoint', 'SetInventoryKept', 'LaunchUp', 'GetTargetEntity', 'ForceFlight', 'LoadInv', 'ChatStyle', 'ChatColor', 'Kick', 'ProjColl', 'MiscAttribute', 'SpectateTarget', 'HurtAnimation', 'SurvivalMode', 'GmSurvival', 'DisplayBellRing', 'SetStatus', 'SetCursorItem', 'SetAbsorption', 'SetFireTicks', 'CombatAttribute', 'SetGamemode', 'RemoveInvRow', 'WakeUpAnimation', 'DisableBlocks', 'SetScoreObj', 'L SetHealth', 'ParticleEffect', 'ClearInv', 'SetFreezeTicks', 'SetGliding', 'SetRotation', 'ClearItems', 'SetFlying', 'DisplayBlockOpen', 'SetHandItem', 'SendAdvancement', 'ClearChat', 'SetMenuItem', 'LaunchToward', 'SetArmor', 'DisplayGateway', 'GiveSaturation', 'DisplayEquipment', 'GiveExp', 'FaceLocation', 'ClearScoreboard', 'ActionBar', 'SetChatTag', 'ShiftWorldBorder', 'DisplaySignText', 'SetSpeed', 'ExpandInv', 'LaunchProj', 'NoProjColl', 'ShowDisguise', 'ParticleCuboidA', 'PlaySound', 'SetCompass', 'MobDisguise', 'EnableBlocks', 'OpenBlockInv', 'ParticleCircleA', 'RemoveBossBar', 'ClearBars', 'SetEquipment', 'GiveRngItem', 'SetDropsEnabled', 'SendToPlot', 'RemovePotion', 'RemoveEffect', 'DisplayFracture', 'SetEntityHidden', 'SetSidebar', 'AllowDrops', 'Vibration', 'SetSlot', 'ParticleRay', 'ParticleCuboid', 'SendMessageSeq', 'SendDialogue', 'SetNamePrefix', 'ClearDispBlock', 'SetRainLevel', 'Undisguise', 'ParticleSpiralA', 'InstantRespawn', 'SetScore', 'SetNameColor', 'ReachAttribute', 'SetAtkSpeed', 'DisablePvp', 'SetTickRate', 'PlayEntitySound', 'ReplaceProj', 'SetExp', 'MiningAttribute', 'KBAttribute', 'MovementAttribute', 'ParticleSpiral', 'FallingAttribute', 'SetAllowFlight', 'SetMaxHealth', ' RemoveBossBar ', 'SetFogDistance', 'AdventureMode', 'GmAdventure', 'SpectatorMode', 'DispHeadTexture', 'ClearPotions', 'ClearEffects', 'SetTabListInfo', 'EnablePvp', 'HideDisguise', 'ScoreLineFormat', ' SetBossBar ', 'SetSkin', 'SpectatorCollision', 'SetNameVisible', 'SetInvulTicks', 'EnableFlight', 'SetStingsStuck', 'RemoveScore', 'DisallowDrops', 'SetExhaustion', 'ParticleCircle', 'DisplayBlock', 'RideEntity', 'WeatherRain', 'RmWorldBorder', 'ResourcePack', ' SetInvName ', 'GiveExhaustion', 'Teleport', 'SetAllowPVP', 'DisableFlight', 'SetVisualFire', 'SetDisguiseVisible', 'SetArrowsStuck', 'GetItemCooldown', 'SetItems', 'KeepInv', 'ReplaceItems', 'ReplaceItem', 'SendMessage', 'SetSlotItem', 'PlaySoundSeq', 'ParticleLineA', 'Respawn', 'SetInvName', 'SetItemCooldown', 'SetPlayerWeather', 'SendHover', 'SetShoulder', 'SetAirTicks', 'DisplayPickup', 'SetWorldBorder', 'SetPlayerTime', 'GiveFood', 'NatRegen', 'GivePotion', 'GiveEffect', 'RemoveItems', 'BoostElytra', 'SaveInv', 'OpenBook', 'SetHealth', 'BlockDisguise', 'RollbackBlocks', 'NoDeathDrops', 'WalkSpeed', 'SetCollidable', 'LaunchFwd', 'SetFallDistance', 'CreativeMode', 'AttackAnimation', 'DisplayHologram', ' SetAbsorption ', 'DeathDrops', 'ShowInv', 'SetFoodLevel', 'PlayerDisguise', 'SetSaturation', 'WeatherClear', 'SendTitle', 'Title', 'ScoreDefFormat', 'StopSound', 'HealthAttribute', 'ParticleLine']
4
+ ENTITY_ACTION_ACTION = Literal['DispRotationEuler', 'Shear', 'SetVelocity', 'SetGlowSquidDark', 'SetFrogType', 'DispRotAxisAngle', 'Damage', 'SetMobSitting', 'SendAnimation', 'DisableGlowing', 'SetWardenAnger', 'SetHorsePattern', 'Heal', 'SetPandaSadTicks', 'SetItemOwner', 'SetDyeColor', 'LaunchUp', 'SetAge', ' SetName ', 'NoGravity', 'SetArmsRaised', 'SetMoveSpeed', 'SetInvulnerable', 'SetFriction', 'ProjColl', 'ArmorStandTags', 'SetPickupDelay', 'DropItems', 'MiscAttribute', 'SetCreeperPower', 'SetMarker', 'RemoveCustomTag', 'SetAbsorption', 'CreeperCharged', 'SetFireTicks', 'CombatAttribute', 'SetName', 'Jump', 'BDisplayBlock', 'SetFreezeTicks', 'TDisplaySeeThru', 'SetGliding', 'SetRotation', 'SetPandaRolling', 'SetFishPattern', 'SetWolfType', 'DispInterpolation', 'SetHandItem', 'SetEndermanBlock', 'LaunchToward', 'SetArmor', ' SetArmor ', 'GetCustomTag', 'InteractionSize', 'FaceLocation', 'SetCatType', 'SetArrowDamage', 'DisplayScale', 'TDisplayAlign', 'LaunchProj', 'EnableAI', 'DisplayBillboard', 'NoProjColl', 'Tame', 'SetGoatScreaming', 'SetBeeStinger', 'MobDisguise', 'SetMinecartBlock', 'FoxSleeping', 'SetEquipment', 'SetSilenced', 'SetBeeNectar', 'AttachLead', 'RemovePotion', 'RemoveEffect', 'ShearSheep', 'ArmorStandSlots', 'SetAllayDancing', 'SetRabbitType', 'SetSize', 'ShowName', 'SetAngry', 'SetAngerTicks', 'Undisguise', 'SetDeathDrops', 'SetPersistent', 'ProjectileItem', 'SetNameColor', 'SetCarryingChest', 'SetParrotColor', 'DispTranslation', 'Remove', 'TDispBackground', 'DisplayCullingSize', 'HideName', 'SetAxolotlColor', 'GetAllEntityTags', 'SetAI', 'KBAttribute', 'MovementAttribute', 'SetRiptiding', 'SetArrowNoClip', 'FallingAttribute', 'SetProjSource', 'SetFoxLeaping', 'SetPandaGene', 'SetMaxHealth', 'SetFishingTime', 'EndCrystalBeam', 'FrogEat', 'DisplayBrightness', 'SetProfession', 'ClearPotions', 'ClearEffects', 'ArmorStandParts', ' SetNameVisible ', 'SetTarget', 'TDisplayShadow', 'SetNameVisible', 'SetInvulTicks', 'SetShulkerPeek', ' SetPose ', 'SetRearing', 'SetCloudRadius', 'SetGravity', 'DispTPDuration', 'SetWitherInvul', 'Silence', 'SetArrowPierce', 'DisplayShadow', 'InteractResponse', 'UseItem', 'RideEntity', 'DisplayMatrix', 'NoDrops', 'SnifferState', 'EnableGlowing', 'Teleport', 'DisplayGlowColor', 'SetVisualFire', 'SetAge/Size', 'L SetArmor', 'SetSaddle', 'SetBulletTarget', 'TDisplayLineWidth', 'SetDragonPhase', 'SetLlamaColor', 'SetVillagerBiome', 'SetCreeperFuse', 'SetBaby', 'MooshroomType', 'SetInvisible', 'SheepEat', 'SetCatResting', 'GivePotion', 'GiveEffect', 'SetGoatHorns', 'SetGlowing', 'SetPandaOnBack', 'IDisplayModelType', 'SetHealth', 'BlockDisguise', 'SetCollidable', 'ArmorStandPose', 'SetPose', 'LaunchFwd', 'SetFallDistance', 'MoveToLoc', 'TDisplayOpacity', 'IDisplayItem', 'AttackAnimation', 'SnowmanPumpkin', 'SetCustomTag', 'Gravity', 'DisplayViewRange', 'NoAI', 'PlayerDisguise', 'SetItem', 'Explode', 'ExplodeCreeper', 'SetDigging', 'MoveTo', 'SetArrowHitSound', 'SetVexCharging', 'SetVillagerExp', 'IgniteCreeper', 'SetCelebrating', 'TDisplayText', 'SetHorseJump', 'Unsilence', 'HealthAttribute', 'Ram', 'SetFoxType']
5
+ GAME_ACTION_ACTION = Literal['FillContainer', 'BreakBlock', 'L PFX Spiral', 'ParticleSphere', 'PFX Sphere', 'ChangeSign', 'WebRequest', 'ClearScBoard', 'HideSidebar', 'SpawnItemDisplay', 'WriteTransaction', 'ParticleSpiral', 'PFX Spiral', 'SetBlockData', 'Firework', 'SetEventDamage', 'SpawnItem', 'SignColor', 'ShulkerBullet', 'FireworkEffect', 'SetContainer', 'SpawnInteraction', 'SetItemInSlot', 'CloneRegion', 'CopyBlocks', 'UncancelEvent', 'SetLecternBook', 'SpawnArmorStand', 'SpawnBlockDisp', 'ClearContainer', 'CancelEvent', 'ParticleEffect', 'Particle FX', 'SpawnFangs', 'SetEventSound', 'SetEventXP', 'LockContainer', 'RemoveScore', 'CreateHologram', 'SetExhaustion', 'ParticleCircle', 'PFX Circle', 'PFX Line [A]', 'ClearItems', 'StartLoop', 'SetFurnaceSpeed', 'BlockDropsOn', 'BoneMeal', 'DebugStackTrace', 'FallingBlock', 'DiscordWebhook', 'TickBlock', 'ReplaceItems', 'SetEventProj', 'Explosion', 'SpawnMob', 'SetBrushableItem', 'ParticleLineA', 'SpawnEnderEye', 'ShowSidebar', 'SpawnPotionCloud', 'LaunchProj', ' SetBlock ', 'SpawnItemDisp', 'SetBlockGrowth', 'Wait', 'SetContainerName', 'SetHead', 'RemoveHologram', 'RemoveItems', 'SpawnRngItem', 'SetRegion', 'SetBlock', 'ParticleCircleA', 'PFX Circle [A]', 'SpawnTNT', 'SpawnExpOrb', 'SetBiome', 'SetEventHeal', 'PFX Path', 'ApplyTransaction', 'ParticleRay', 'PFX Ray', 'GenerateTree', 'StopLoop', 'SetScObj', 'SpawnCrystal', 'SetCampfireItem', 'SpawnTextDisplay', 'SpawnVehicle', 'Lightning', 'ParticleSpiralA', 'PFX Spiral [A]', 'SetScore', 'ParticleCluster', 'PFX Cluster', 'L PFX Cluster', 'BlockDropsOff', 'ParticleLine', 'PFX Line']
6
+ SET_VAR_ACTION = Literal['GetItemFood', 'String', 'Text', 'SetParticleType', 'SetItemEnchants', 'ClearItemTag', 'PurgeVars', 'ShiftAllAxes', 'ShiftLocCoord', 'GetParticleMat', 'SetParticleSprd', 'AbsoluteValue', 'AppendValue', '%', 'ShiftOnVector', 'AddVectorLoc', 'GetItemAttribute', 'ClearDict', '+', 'ShiftRotation', 'RotateLocation', '-', ' GetItemName ', 'GetItemRarity', 'MultiplyVector', '/', 'GetSignText', 'Bitwise', 'GetLecternPage', 'ParseX', 'ShiftOnAxis', 'ShiftAxis', 'ParseY', 'VectorBetween', 'ParseZ', 'GetVectorComp', '=', 'RmText', 'AddItemAttribute', 'GetCenterLoc', 'FindCenter', 'AlignLoc', 'GetSoundVolume', 'RandomNumber', 'ContainerName', 'Raycast', 'RotateAroundVec', 'SetItemFood', 'GetParticleMotion', 'SetParticleMotion', 'Average', 'WrapNumber', 'ClampLoc', 'SetY', 'SetMapTexture', 'GetBlockData', 'SetX', 'SortDict', 'GetLecternBook', 'GetCustomSound', 'CrossProduct', 'x', 'GetParticleRoll', 'ParseYaw', 'DotProduct', 'SetZ', 'SetArmorTrim', 'PopListValue', 'SetParticleOpac', 'Noise', 'MinNumber', 'MinValue', 'Min', 'GetPotionType', 'SetItemName', 'ListLength', 'Sine', 'DirectionName', 'RepeatString', 'DuplicateText', 'RepeatText', 'GetItemLore', 'JoinString', 'JoinText', 'ReverseList', 'DedupList', 'CreateDict', 'GetBlockByMCTag', 'RoundNumber', 'FaceLocation', 'GetItemLoreLine', 'SetVectorLength', 'SetPotionDur', 'BlockResistance', 'SplitString', 'SplitText', 'NormalRandom', 'SetPotionType', 'AlignVector', 'SetItemDura', 'SetBreakability', 'SetMaxAmount', ' GetSignText ', 'RaycastEntity', 'SetDictValue', 'SetAllCoords', 'RGBColor', 'SetCanDestroy', 'HSLColor', ' GetDirection ', ' GetItemLore ', 'RemoveListIndex', 'CellularNoise', 'Logarithm', 'SetItemTag', 'TrimString', 'TrimText', 'ParseMiniMessageExpr', 'GetItemAmount', 'SetPotionAmp', 'GetCanDestroy', 'RotateAroundAxis', 'GetItemName', 'GetItemDura', 'ShiftInDirection', 'WrapNum', 'ReplaceString', 'ReplaceText', 'SetItemGlowing', ' SetItemName ', 'SetLodestoneLoc', 'FlattenList', 'BlockHardness', 'GetPotionAmp', 'GetParticleAmount', 'GetDictSize', 'SetItemAmount', 'SubtractVectors', 'SetCase', 'SetParticleColor', 'GetLight', ' GetBookText ', 'GetDictValues', 'Vector', 'Distance', 'SetItemLore', 'Root', 'SquareRoot', 'SetParticleAmount', 'AddItemEnchant', 'AddItemToolRule', 'GetItemType', 'GetDirection', 'GetLoreLine', 'GetParticleType', 'SetItemMaxDura', 'RemoveString', 'RemoveText', 'GetAllBlockData', 'MaxNumber', 'MaxValue', 'Max', 'GetDictKeys', 'TrimStyledText', 'SetParticleMat', 'GetCoord', 'RemoveItemTag', 'SetParticleSize', 'GetPotionDur', 'RandomLoc', 'SetSoundType', 'GetLodestoneLoc', 'ShiftDirection', 'GetContainerName', 'GetParticleSprd', 'ReflectVector', 'GetHeadOwner', 'GetItemEnchants', 'AppendDict', 'GetMaxItemAmount', 'GetColorChannels', ' SetDirection ', 'SetListValue', ' SetItemEnchants ', 'SetBookText', 'RandomValue', 'RandomObj', ' SetItemFlags ', 'SetItemType', 'GetSoundType', 'GetListValue', 'BounceNum', 'Tangent', 'VoronoiNoise', 'SetDirection', 'FaceDirection', 'HSBColor', 'HSVColor', '+=', 'GetSoundVariant', 'GetItemColor', 'ClearFormatting', 'InsertListValue', 'InsertListIndex', 'SetSoundVolume', 'SetCoord', 'AddVectors', 'SetPitch', 'GetParticleFade', 'RaycastBlock', 'SetItemTool', ' GetItemEnchants ', 'SetHeadTexture', 'SetHeadOwner', 'PerlinNoise', 'WorleyNoise', 'SetItemColor', 'SetLeatherColor', 'GetParticleColor', 'SetSoundPitch', ' RoundNumber ', 'GetCanPlaceOn', 'SortList', 'SetCustomSound', 'RemoveDictEntry', 'FormatTime', 'SetItemFlags', 'StringLength', 'TextLength', 'GetItemEffects', 'StyledText', 'GetMiniMessageExpr', 'SetYaw', ' SetItemLore ', 'SetItemEffects', '-=', 'GetItemTag', 'CreateList', 'AppendList', 'GetContainerItems', 'ShiftToward', 'ShiftTowards', 'ShiftLocTowards', 'TrimList', 'GradientNoise', 'SetItemHideTooltip', 'GetBlockDrops', 'ClearEnchants', 'Cosine', 'GetParticleOpac', 'GetItemByMCTag', 'SetParticleFade', 'SetVectorComp', 'ParseNumber', 'Exponent', 'ShiftAllDirs', 'GetValueIndex', 'RemItemEnchant', 'AddItemLore', 'GetBookText', 'SetParticleRoll', 'SetSoundVariant', 'ShiftLocation', 'RandomizeList', 'ClampNumber', 'Round', 'GetSoundPitch', 'TranslateColors', 'GetBlockGrowth', 'GetAllItemTags', 'RemoveListValue', 'ShiftAllDirections', 'ValueNoise', 'SetCanPlaceOn', 'GetBlockType', 'ParsePitch', 'GetDictValue', 'ContainerLock', 'GetBlockPower', 'GetVectorLength', 'ContentLength', 'SetModelData', 'SetCoords', 'GetMaxAmount', 'GetParticleSize']
7
+ IF_PLAYER_ACTION = Literal['IsLookingAt', 'InWorldBorder', 'IsInGameMode', 'HasRoomForItem', 'PHasRoomForItem', 'IsHoldingOff', 'UsingPack', 'NoItemCooldown', 'IsUsingItem', 'HasAllItems', 'IsSwimming', 'HasItem', 'BlockEquals', 'IsWearing', 'PIsWearing', 'IsNear', 'PIsNear', 'IsRiding', 'StandingOn', 'PStandingOn', 'CmdEquals', ' StandingOn ', ' PStandingOn ', 'IsGrounded', 'CursorItem', 'SlotEquals', 'ItemEquals', 'IsHoldingMain', 'IsHolding', 'MenuSlotEquals', 'IsBlocking', 'HasPermission', ' IsRiding ', 'MainHandEquals', 'IsSneaking', 'IsFlying', 'HasPotion', 'HasEffect', 'NameEquals', 'PNameEquals', 'InvOpen', 'HasSlotItem', 'IsSprinting', 'IsGliding', 'CmdArgEquals']
8
+ IF_ENTITY_ACTION = Literal['IsVehicle', 'IsGrounded', 'EIsGrounded', 'IsType', 'IsProj', 'IsMob', 'HasCustomTag', 'IsSheared', 'IsItem', ' IsRiding ', 'Exists', 'IsNear', 'EIsNear', 'HasPotion', 'IsRiding', 'StandingOn', 'EStandingOn', 'NameEquals', 'ENameEquals', ' StandingOn ', ' EStandingOn ']
9
+ IF_GAME_ACTION = Literal['SignHasTxt', 'HasRoomForItem', 'EventBlockEquals', 'CommandEquals', 'EventItemEquals', ' SignHasTxt ', 'AttackIsCrit', 'ContainerHas', 'BlockEquals', 'GBlockEquals', 'InBlock', 'BlockPowered', 'HasPlayer', 'ContainerHasAll', 'CmdArgEquals', 'EventCancelled', 'IsChunkLoaded']
10
+ IF_VAR_ACTION = Literal['<=', 'ItemHasEnchant', 'ItemIsBlock', 'DictValueEquals', 'ItemHasTag', 'StringMatches', ' TextMatches ', 'ListIsEmpty', 'StartsWith', 'ListValueEq', 'VarIsType', 'TextMatches', 'EqIgnoreCase', 'IsNear', 'VIsNear', ' InRange ', 'VarExists', 'BlockIsSolid', 'ItemEquals', 'VItemEquals', 'ListContains', 'InRange', 'LocIsNear', 'Contains', '!=', '<', '=', ' = ', '>', 'EndsWith', '>=', 'DictHasKey']
11
+ REPEAT_ACTION = Literal['Adjacent', 'Path', 'Multiple', 'N Times', 'Grid', 'While', 'WhileCond', 'Range', 'ForEach', 'Sphere', 'Forever', ' Range ', 'ForEachEntry']
12
+ SELECT_OBJ_ACTION = Literal['LastMob', 'RandomPlayer', 'LastEntity', 'Shooter', 'AllMobs', 'EntityName', 'FilterRandom', 'RandomSelected', 'DefaultEntity', 'PlayerName', 'AllEntities', 'Damager', 'FilterDistance', 'FilterRay', 'Reset', 'None', 'EventTarget', 'Killer', 'Victim', 'EntitiesCond', 'AllPlayers', 'Invert', 'RandomEntity', 'FilterCondition', 'FilterSelect', 'MobsCond', 'FilterSort', 'Projectile', 'DefaultPlayer', 'PlayersCond', 'MobName']
13
+ CONTROL_ACTION = Literal['StopRepeat', 'Return', 'ReturnNTimes', 'Skip', 'End', 'Wait']
14
+ EVENT_ACTION = Literal['ClickContainerSlot', 'CloseInv', 'StartFly', 'BreakBlock', 'StartSprint', 'MobKillPlayer', 'Teleport', 'ShootBow', 'StopFly', 'TameEntity', 'LeftClick', 'PlayerTakeDmg', 'ProjHit', 'KillPlayer', 'VehicleJump', 'ClickInvSlot', 'ClickOwnInv', 'Respawn', 'SwapHands', 'PackLoad', 'DamageEntity', 'Sneak', 'PlayerHeal', 'ClickPlayer', 'Consume', 'Death', 'PlaceBlock', 'Walk', 'PickUpItem', 'PickupItem', 'Dismount', 'CloudImbuePlayer', 'Leave', 'Quit', 'DropItem', 'LeftClickPlayer', 'ChangeSlot', 'ClickEntity', 'HorseJump', 'ShootProjectile', 'Move', 'Unsneak', 'Fish', 'FishEvent', 'FallDamage', 'BreakItem', 'LoopEvent', 'PlayerResurrect', 'RightClick', 'ClickMenuSlot', 'ClickItem', 'Riptide', 'KillMob', 'Join', 'EntityDmgPlayer', 'StopSprint', 'Jump', 'LoadCrossbow', 'ProjDmgPlayer', 'Command', 'LeftClickEntity', 'Exhaustion', 'PackDecline', 'PlayerDmgPlayer']
15
+ ENTITY_EVENT_ACTION = Literal['EntityKillEntity', 'BlockFall', 'ProjKillEntity', 'EntityDmgEntity', 'FallingBlockLand', 'EntityResurrect', 'ItemMerge', 'EntityHeal', 'Teleport', 'ShootBow', 'EntityDmg', 'ProjDmgEntity', 'EntityExplode', 'EntityDeath', 'VehicleDamage', 'Transform', 'RegrowWool']
16
+ REPEAT_SUBACTION = IF_PLAYER_ACTION | IF_ENTITY_ACTION | IF_GAME_ACTION | IF_VAR_ACTION
@@ -13,6 +13,7 @@ from dfpyre.util import *
13
13
  from dfpyre.items import *
14
14
  from dfpyre.scriptgen import generate_script, GeneratorFlags
15
15
  from dfpyre.actiondump import CODEBLOCK_DATA, get_default_tags
16
+ from dfpyre.action_literals import *
16
17
 
17
18
 
18
19
  VARIABLE_TYPES = {'txt', 'comp', 'num', 'item', 'loc', 'var', 'snd', 'part', 'pot', 'g_val', 'vec', 'pn_el'}
@@ -349,47 +350,124 @@ def _assemble_template(starting_block: CodeBlock, codeblocks: list[CodeBlock], a
349
350
  return DFTemplate(template_codeblocks, author)
350
351
 
351
352
 
352
- def player_event(event_name: str, codeblocks: list[CodeBlock]=(), author: str|None=None) -> DFTemplate:
353
+ def player_event(event_name: EVENT_ACTION, codeblocks: list[CodeBlock]=(), author: str|None=None) -> DFTemplate:
354
+ """
355
+ Represents a Player Event codeblock.
356
+
357
+ :param str event_name: The name of the event. (Ex: "Join")
358
+ :param list[CodeBlock] codeblocks: The list of codeblocks in this template.
359
+ :param str|None author: The author of this template.
360
+ """
353
361
  starting_block = CodeBlock.new_action('event', event_name, (), {})
354
362
  return _assemble_template(starting_block, codeblocks, author)
355
363
 
356
364
 
357
- def entity_event(event_name: str, codeblocks: list[CodeBlock]=[], author: str|None=None) -> DFTemplate:
365
+ def entity_event(event_name: ENTITY_EVENT_ACTION, codeblocks: list[CodeBlock]=[], author: str|None=None) -> DFTemplate:
366
+ """
367
+ Represents an Entity Event codeblock.
368
+
369
+ :param str event_name: The name of the event. (Ex: "EntityDmg")
370
+ :param list[CodeBlock] codeblocks: The list of codeblocks in this template.
371
+ :param str|None author: The author of this template.
372
+ """
358
373
  starting_block = CodeBlock.new_action('entity_event', event_name, (), {})
359
374
  return _assemble_template(starting_block, codeblocks, author)
360
375
 
361
376
 
362
377
  def function(function_name: str, *args, tags: dict[str, str]={}, codeblocks: list[CodeBlock]=[], author: str|None=None) -> DFTemplate:
378
+ """
379
+ Represents a Function codeblock.
380
+
381
+ :param str event_name: The name of the function.
382
+ :param tuple args: The argument items to include.
383
+ :param dict[str, str] tags: The tags to include.
384
+ :param list[CodeBlock] codeblocks: The list of codeblocks in this template.
385
+ :param str|None author: The author of this template.
386
+ """
363
387
  starting_block = CodeBlock.new_data('func', function_name, args, tags)
364
388
  return _assemble_template(starting_block, codeblocks, author)
365
389
 
366
390
 
367
391
  def process(process_name: str, *args, tags: dict[str, str]={}, codeblocks: list[CodeBlock]=[], author: str|None=None) -> DFTemplate:
392
+ """
393
+ Represents a Process codeblock.
394
+
395
+ :param str event_name: The name of the process.
396
+ :param tuple args: The argument items to include.
397
+ :param dict[str, str] tags: The tags to include.
398
+ :param list[CodeBlock] codeblocks: The list of codeblocks in this template.
399
+ :param str|None author: The author of this template.
400
+ """
368
401
  starting_block = CodeBlock.new_data('process', process_name, args, tags)
369
402
  return _assemble_template(starting_block, codeblocks, author)
370
403
 
371
404
 
372
405
  def call_function(function_name: str, *args) -> CodeBlock:
406
+ """
407
+ Represents a Call Function codeblock.
408
+
409
+ :param str event_name: The name of the function.
410
+ :param tuple args: The argument items to include.
411
+ """
373
412
  return CodeBlock.new_data('call_func', function_name, args, {})
374
413
 
375
414
 
376
415
  def start_process(process_name: str, *args, tags: dict[str, str]={}) -> CodeBlock:
416
+ """
417
+ Represents a Call Function codeblock.
418
+
419
+ :param str event_name: The name of the function.
420
+ :param tuple args: The argument items to include.
421
+ """
377
422
  return CodeBlock.new_data('start_process', process_name, args, tags)
378
423
 
379
424
 
380
- def player_action(action_name: str, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}) -> CodeBlock:
425
+ def player_action(action_name: PLAYER_ACTION_ACTION, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}) -> CodeBlock:
426
+ """
427
+ Represents a Player Action codeblock.
428
+
429
+ :param str action_name: The name of the action.
430
+ :param tuple args: The argument items to include.
431
+ :param Target target: The target for the action.
432
+ :param dict[str, str] tags: The tags to include.
433
+ """
381
434
  return CodeBlock.new_action('player_action', action_name, args, tags, target=target)
382
435
 
383
436
 
384
- def entity_action(action_name: str, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}) -> CodeBlock:
437
+ def entity_action(action_name: ENTITY_ACTION_ACTION, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}) -> CodeBlock:
438
+ """
439
+ Represents an Entity Action codeblock.
440
+
441
+ :param str action_name: The name of the action.
442
+ :param tuple args: The argument items to include.
443
+ :param Target target: The target for the action.
444
+ :param dict[str, str] tags: The tags to include.
445
+ """
385
446
  return CodeBlock.new_action('entity_action', action_name, args, tags, target=target)
386
447
 
387
448
 
388
- def game_action(action_name: str, *args, tags: dict[str, str]={}) -> CodeBlock:
449
+ def game_action(action_name: GAME_ACTION_ACTION, *args, tags: dict[str, str]={}) -> CodeBlock:
450
+ """
451
+ Represents a Game Action codeblock.
452
+
453
+ :param str action_name: The name of the action.
454
+ :param tuple args: The argument items to include.
455
+ :param dict[str, str] tags: The tags to include.
456
+ """
389
457
  return CodeBlock.new_action('game_action', action_name, args, tags)
390
458
 
391
459
 
392
- def if_player(action_name: str, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
460
+ def if_player(action_name: IF_PLAYER_ACTION, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
461
+ """
462
+ Represents an If Player codeblock.
463
+
464
+ :param str action_name: The name of the condition.
465
+ :param tuple args: The argument items to include.
466
+ :param Target target: The target for the condition.
467
+ :param dict[str, str] tags: The tags to include.
468
+ :param bool inverted: Whether the condition should be inverted.
469
+ :param list[CodeBlock] codeblocks: The list of codeblocks inside the brackets.
470
+ """
393
471
  return [
394
472
  CodeBlock.new_conditional('if_player', action_name, args, tags, inverted, target),
395
473
  CodeBlock.new_bracket('open', 'norm')
@@ -397,7 +475,17 @@ def if_player(action_name: str, *args, target: Target=DEFAULT_TARGET, tags: dict
397
475
  CodeBlock.new_bracket('close', 'norm')
398
476
  ]
399
477
 
400
- def if_entity(action_name: str, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
478
+ def if_entity(action_name: IF_ENTITY_ACTION, *args, target: Target=DEFAULT_TARGET, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
479
+ """
480
+ Represents an If Entity codeblock.
481
+
482
+ :param str action_name: The name of the condition.
483
+ :param tuple args: The argument items to include.
484
+ :param Target target: The target for the condition.
485
+ :param dict[str, str] tags: The tags to include.
486
+ :param bool inverted: Whether the condition should be inverted.
487
+ :param list[CodeBlock] codeblocks: The list of codeblocks inside the brackets.
488
+ """
401
489
  return [
402
490
  CodeBlock.new_conditional('if_entity', action_name, args, tags, inverted, target),
403
491
  CodeBlock.new_bracket('open', 'norm')
@@ -406,7 +494,16 @@ def if_entity(action_name: str, *args, target: Target=DEFAULT_TARGET, tags: dict
406
494
  ]
407
495
 
408
496
 
409
- def if_game(action_name: str, *args, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
497
+ def if_game(action_name: IF_GAME_ACTION, *args, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
498
+ """
499
+ Represents an If Game codeblock.
500
+
501
+ :param str action_name: The name of the condition.
502
+ :param tuple args: The argument items to include.
503
+ :param dict[str, str] tags: The tags to include.
504
+ :param bool inverted: Whether the condition should be inverted.
505
+ :param list[CodeBlock] codeblocks: The list of codeblocks inside the brackets.
506
+ """
410
507
  return [
411
508
  CodeBlock.new_conditional('if_game', action_name, args, tags, inverted),
412
509
  CodeBlock.new_bracket('open', 'norm')
@@ -415,7 +512,16 @@ def if_game(action_name: str, *args, tags: dict[str, str]={}, inverted: bool=Fal
415
512
  ]
416
513
 
417
514
 
418
- def if_variable(action_name: str, *args, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
515
+ def if_variable(action_name: IF_VAR_ACTION, *args, tags: dict[str, str]={}, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
516
+ """
517
+ Represents an If Variable codeblock.
518
+
519
+ :param str action_name: The name of the condition.
520
+ :param tuple args: The argument items to include.
521
+ :param dict[str, str] tags: The tags to include.
522
+ :param bool inverted: Whether the condition should be inverted.
523
+ :param list[CodeBlock] codeblocks: The list of codeblocks inside the brackets.
524
+ """
419
525
  return [
420
526
  CodeBlock.new_conditional('if_var', action_name, args, tags, inverted),
421
527
  CodeBlock.new_bracket('open', 'norm')
@@ -425,6 +531,11 @@ def if_variable(action_name: str, *args, tags: dict[str, str]={}, inverted: bool
425
531
 
426
532
 
427
533
  def else_(codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
534
+ """
535
+ Represents an Else codeblock.
536
+
537
+ :param list[CodeBlock] codeblocks: The list of codeblocks inside the brackets.
538
+ """
428
539
  return [
429
540
  CodeBlock.new_else(),
430
541
  CodeBlock.new_bracket('open', 'norm')
@@ -433,7 +544,17 @@ def else_(codeblocks: list[CodeBlock]=[]) -> list[CodeBlock]:
433
544
  ]
434
545
 
435
546
 
436
- def repeat(action_name: str, *args, tags: dict[str, str]={}, sub_action: str|None=None, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> CodeBlock:
547
+ def repeat(action_name: REPEAT_ACTION, *args, tags: dict[str, str]={}, sub_action: REPEAT_SUBACTION|None=None, inverted: bool=False, codeblocks: list[CodeBlock]=[]) -> CodeBlock:
548
+ """
549
+ Represents a Repeat codeblock.
550
+
551
+ :param str action_name: The name of the action.
552
+ :param tuple args: The argument items to include.
553
+ :param dict[str, str] tags: The tags to include.
554
+ :param str|None sub_action: The sub-action for the repeat action (Only relevant for `While`)
555
+ :param bool inverted: Whether the sub-action condition should be inverted.
556
+ :param list[CodeBlock] codeblocks: The list of codeblocks inside the brackets.
557
+ """
437
558
  return [
438
559
  CodeBlock.new_repeat(action_name, args, tags, sub_action, inverted),
439
560
  CodeBlock.new_bracket('open', 'repeat')
@@ -442,13 +563,34 @@ def repeat(action_name: str, *args, tags: dict[str, str]={}, sub_action: str|Non
442
563
  ]
443
564
 
444
565
 
445
- def control(action_name: str, *args, tags: dict[str, str]={}) -> CodeBlock:
566
+ def control(action_name: CONTROL_ACTION, *args, tags: dict[str, str]={}) -> CodeBlock:
567
+ """
568
+ Represents a Control codeblock.
569
+
570
+ :param str action_name: The name of the action.
571
+ :param tuple args: The argument items to include.
572
+ :param dict[str, str] tags: The tags to include.
573
+ """
446
574
  return CodeBlock.new_action('control', action_name, args, tags)
447
575
 
448
576
 
449
- def select_object(action_name: str, *args, tags: dict[str, str]={}) -> CodeBlock:
577
+ def select_object(action_name: SELECT_OBJ_ACTION, *args, tags: dict[str, str]={}) -> CodeBlock:
578
+ """
579
+ Represents a Select Object codeblock.
580
+
581
+ :param str action_name: The name of the action.
582
+ :param tuple args: The argument items to include.
583
+ :param dict[str, str] tags: The tags to include.
584
+ """
450
585
  return CodeBlock.new_action('select_obj', action_name, args, tags)
451
586
 
452
587
 
453
- def set_variable(action_name: str, *args, tags: dict[str, str]={}) -> CodeBlock:
588
+ def set_variable(action_name: SET_VAR_ACTION, *args, tags: dict[str, str]={}) -> CodeBlock:
589
+ """
590
+ Represents a Set Variable codeblock.
591
+
592
+ :param str action_name: The name of the action.
593
+ :param tuple args: The argument items to include.
594
+ :param dict[str, str] tags: The tags to include.
595
+ """
454
596
  return CodeBlock.new_action('set_var', action_name, args, tags)
@@ -28,7 +28,7 @@ TEMPLATE_FUNCTION_LOOKUP = {
28
28
  }
29
29
 
30
30
  TARGET_CODEBLOCKS = {'player_action', 'entity_action', 'if_player', 'if_entity'}
31
- CONTAINER_CODEBLOCKS = {'event', 'entity_event', 'func', 'process', 'if_player', 'if_entity', 'if_game', 'if_variable', 'else', 'repeat'}
31
+ CONTAINER_CODEBLOCKS = {'event', 'entity_event', 'func', 'process', 'if_player', 'if_entity', 'if_game', 'if_var', 'else', 'repeat'}
32
32
  VAR_SCOPES = {'unsaved': 'g', 'saved': 's', 'local': 'l', 'line': 'i'}
33
33
 
34
34
 
@@ -129,10 +129,15 @@ def add_script_line(flags: GeneratorFlags, script_lines: list[str], indent_level
129
129
  def generate_script(template, flags: GeneratorFlags) -> str:
130
130
  indent_level = 0
131
131
  script_lines = []
132
+
133
+ def remove_comma_from_last_line():
134
+ script_lines[-1] = script_lines[-1][:-1]
135
+
132
136
  for codeblock in template.codeblocks:
133
137
  # Handle closing brackets
134
138
  if codeblock.type == 'bracket':
135
139
  if codeblock.data['direct'] == 'close':
140
+ remove_comma_from_last_line()
136
141
  indent_level -= 1
137
142
  add_script_line(flags, script_lines, indent_level, '])')
138
143
  continue
@@ -182,6 +187,7 @@ def generate_script(template, flags: GeneratorFlags) -> str:
182
187
  line = f'{function_name}({", ".join(function_args)})'
183
188
  add_script_line(flags, script_lines, indent_level, line)
184
189
 
190
+ remove_comma_from_last_line()
185
191
  indent_level -= 1
186
192
  add_script_line(flags, script_lines, indent_level, '])') # add final closing brackets
187
193
  return SCRIPT_START + '\n'.join(script_lines)
@@ -1,13 +1,13 @@
1
1
  [tool.poetry]
2
2
  name = "dfpyre"
3
- version = "0.8.0"
3
+ version = "0.8.2"
4
4
  description = "A package for creating and modifying code templates for the DiamondFire Minecraft server."
5
5
  authors = ["Amp"]
6
6
  readme = "README.md"
7
7
  license = "MIT"
8
8
  repository = "https://github.com/Amp63/pyre"
9
9
  keywords = ["diamondfire", "minecraft", "template", "item"]
10
- exclude = ['examples']
10
+ exclude = ['examples', 'extra']
11
11
 
12
12
 
13
13
  [tool.poetry.dependencies]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes