dfpyre 0.6.3__tar.gz → 0.7.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.
- {dfpyre-0.6.3 → dfpyre-0.7.0}/PKG-INFO +16 -3
- {dfpyre-0.6.3 → dfpyre-0.7.0}/README.md +15 -2
- dfpyre-0.7.0/dfpyre/actiondump.py +72 -0
- dfpyre-0.7.0/dfpyre/data/actiondump_min.json +1 -0
- {dfpyre-0.6.3 → dfpyre-0.7.0}/dfpyre/items.py +22 -8
- {dfpyre-0.6.3 → dfpyre-0.7.0}/dfpyre/pyre.py +129 -159
- {dfpyre-0.6.3 → dfpyre-0.7.0}/dfpyre/scriptgen.py +10 -2
- dfpyre-0.7.0/dfpyre/util.py +28 -0
- {dfpyre-0.6.3 → dfpyre-0.7.0}/pyproject.toml +1 -1
- dfpyre-0.6.3/dfpyre/data/data.json +0 -1
- {dfpyre-0.6.3 → dfpyre-0.7.0}/LICENSE +0 -0
- {dfpyre-0.6.3 → dfpyre-0.7.0}/dfpyre/__init__.py +0 -0
- {dfpyre-0.6.3 → dfpyre-0.7.0}/dfpyre/style.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dfpyre
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.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
|
|
@@ -70,6 +70,7 @@ pip install dfpyre
|
|
|
70
70
|
|
|
71
71
|
## Extras
|
|
72
72
|
|
|
73
|
+
- [Editing Tags](#editing-tags)
|
|
73
74
|
- [Importing from Code](#importing-from-code)
|
|
74
75
|
- [Script Generation](#script-generation)
|
|
75
76
|
- [Method List](#method-list)
|
|
@@ -374,7 +375,7 @@ t.player_action('SendMessage', 'Hello, ', var('name', 'line'))
|
|
|
374
375
|
|
|
375
376
|
### Conditionals and Brackets
|
|
376
377
|
|
|
377
|
-
A list of conditionals and loops can be found [here](#
|
|
378
|
+
A list of conditionals and loops can be found [here](#method-list).
|
|
378
379
|
|
|
379
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:
|
|
380
381
|
|
|
@@ -404,7 +405,6 @@ t.else_()
|
|
|
404
405
|
t.bracket(
|
|
405
406
|
t.player_action('ActionBar', 'in the air')
|
|
406
407
|
)
|
|
407
|
-
t.build()
|
|
408
408
|
```
|
|
409
409
|
|
|
410
410
|
### Loops
|
|
@@ -444,6 +444,19 @@ t = DFTemplate()
|
|
|
444
444
|
t.player_event('Join')
|
|
445
445
|
t.call_function('doStuff')
|
|
446
446
|
```
|
|
447
|
+
|
|
448
|
+
### Editing Tags
|
|
449
|
+
You can edit an action's tags by passing the `tags` argument to a template method:
|
|
450
|
+
|
|
451
|
+
```py
|
|
452
|
+
from dfpyre import *
|
|
453
|
+
t = DFTemplate()
|
|
454
|
+
t.player_event('Join')
|
|
455
|
+
t.player_action('SendMessage', 'hello', tags={'Alignment Mode': 'Centered'})
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
If you choose not to modify a specific tag, its default value will be used.
|
|
459
|
+
Order does not matter when adding multiple tag entries.
|
|
447
460
|
|
|
448
461
|
### Importing from Code
|
|
449
462
|
|
|
@@ -52,6 +52,7 @@ pip install dfpyre
|
|
|
52
52
|
|
|
53
53
|
## Extras
|
|
54
54
|
|
|
55
|
+
- [Editing Tags](#editing-tags)
|
|
55
56
|
- [Importing from Code](#importing-from-code)
|
|
56
57
|
- [Script Generation](#script-generation)
|
|
57
58
|
- [Method List](#method-list)
|
|
@@ -356,7 +357,7 @@ t.player_action('SendMessage', 'Hello, ', var('name', 'line'))
|
|
|
356
357
|
|
|
357
358
|
### Conditionals and Brackets
|
|
358
359
|
|
|
359
|
-
A list of conditionals and loops can be found [here](#
|
|
360
|
+
A list of conditionals and loops can be found [here](#method-list).
|
|
360
361
|
|
|
361
362
|
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:
|
|
362
363
|
|
|
@@ -386,7 +387,6 @@ t.else_()
|
|
|
386
387
|
t.bracket(
|
|
387
388
|
t.player_action('ActionBar', 'in the air')
|
|
388
389
|
)
|
|
389
|
-
t.build()
|
|
390
390
|
```
|
|
391
391
|
|
|
392
392
|
### Loops
|
|
@@ -426,6 +426,19 @@ t = DFTemplate()
|
|
|
426
426
|
t.player_event('Join')
|
|
427
427
|
t.call_function('doStuff')
|
|
428
428
|
```
|
|
429
|
+
|
|
430
|
+
### Editing Tags
|
|
431
|
+
You can edit an action's tags by passing the `tags` argument to a template method:
|
|
432
|
+
|
|
433
|
+
```py
|
|
434
|
+
from dfpyre import *
|
|
435
|
+
t = DFTemplate()
|
|
436
|
+
t.player_event('Join')
|
|
437
|
+
t.player_action('SendMessage', 'hello', tags={'Alignment Mode': 'Centered'})
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
If you choose not to modify a specific tag, its default value will be used.
|
|
441
|
+
Order does not matter when adding multiple tag entries.
|
|
429
442
|
|
|
430
443
|
### Importing from Code
|
|
431
444
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
from dfpyre.util import warn
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
ACTIONDUMP_PATH = os.path.join(os.path.dirname(__file__), 'data/actiondump_min.json')
|
|
7
|
+
|
|
8
|
+
CODEBLOCK_NAME_LOOKUP = {
|
|
9
|
+
'PLAYER ACTION': 'player_action',
|
|
10
|
+
'ENTITY ACTION': 'entity_action',
|
|
11
|
+
'GAME ACTION': 'game_action',
|
|
12
|
+
'SET VARIABLE': 'set_var',
|
|
13
|
+
'IF PLAYER': 'if_player',
|
|
14
|
+
'IF ENTITY': 'if_entity',
|
|
15
|
+
'IF GAME': 'if_game',
|
|
16
|
+
'IF VARIABLE': 'if_var',
|
|
17
|
+
'REPEAT': 'repeat',
|
|
18
|
+
'SELECT OBJECT': 'select_object',
|
|
19
|
+
'CONTROL': 'control',
|
|
20
|
+
'PLAYER EVENT': 'event',
|
|
21
|
+
'ENTITY EVENT': 'entity_event',
|
|
22
|
+
'FUNCTION': 'func',
|
|
23
|
+
'CALL FUNCTION': 'call_func',
|
|
24
|
+
'PROCESS': 'process',
|
|
25
|
+
'START PROCESS': 'start_process',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_action_tags(action_data: dict) -> list[dict]:
|
|
30
|
+
action_tags = []
|
|
31
|
+
for tag_data in action_data['tags']:
|
|
32
|
+
options = [o['name'] for o in tag_data['options']]
|
|
33
|
+
converted_tag_data = {
|
|
34
|
+
'name': tag_data['name'],
|
|
35
|
+
'options': options,
|
|
36
|
+
'default': tag_data['defaultOption'],
|
|
37
|
+
'slot': tag_data['slot']
|
|
38
|
+
}
|
|
39
|
+
action_tags.append(converted_tag_data)
|
|
40
|
+
return action_tags
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def parse_actiondump():
|
|
44
|
+
codeblock_data = {n: {} for n in CODEBLOCK_NAME_LOOKUP.values()}
|
|
45
|
+
codeblock_data['else'] = {'tags': []}
|
|
46
|
+
|
|
47
|
+
if not os.path.exists(ACTIONDUMP_PATH):
|
|
48
|
+
warn('data.json not found -- Item tags and error checking will not work.')
|
|
49
|
+
return {}, set()
|
|
50
|
+
|
|
51
|
+
with open(ACTIONDUMP_PATH, 'r', encoding='utf-8') as f:
|
|
52
|
+
actiondump = json.loads(f.read())
|
|
53
|
+
|
|
54
|
+
for action_data in actiondump['actions']:
|
|
55
|
+
action_tags = get_action_tags(action_data)
|
|
56
|
+
parsed_action_data = {'tags': action_tags}
|
|
57
|
+
if dep_note := action_data['icon']['deprecatedNote']:
|
|
58
|
+
parsed_action_data['deprecatedNote'] = ' '.join(dep_note)
|
|
59
|
+
|
|
60
|
+
codeblock_name = CODEBLOCK_NAME_LOOKUP[action_data['codeblockName']]
|
|
61
|
+
codeblock_data[codeblock_name][action_data['name']] = parsed_action_data
|
|
62
|
+
|
|
63
|
+
return codeblock_data
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def get_default_tags(codeblock_type: str|None, codeblock_action: str|None) -> dict[str, str]:
|
|
67
|
+
if codeblock_type is None or codeblock_action is None:
|
|
68
|
+
return {}
|
|
69
|
+
return {t['name']: t['default'] for t in CODEBLOCK_DATA[codeblock_type][codeblock_action]['tags']}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
CODEBLOCK_DATA = parse_actiondump()
|