dfpyre 0.4.6__py3-none-any.whl → 0.6.0__py3-none-any.whl

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/scriptgen.py ADDED
@@ -0,0 +1,144 @@
1
+ import dataclasses
2
+ import re
3
+ from dfpyre.items import *
4
+
5
+ SCRIPT_START = '''from dfpyre import *
6
+ t = DFTemplate()
7
+ '''
8
+
9
+ TEMPLATE_METHOD_LOOKUP = {
10
+ 'event': 'player_event',
11
+ 'entity_event': 'entity_event',
12
+ 'func': 'function',
13
+ 'process': 'process',
14
+ 'call_func': 'call_function',
15
+ 'start_process': 'start_process',
16
+ 'player_action': 'player_action',
17
+ 'game_action': 'game_action',
18
+ 'entity_action': 'entity_action',
19
+ 'if_player': 'if_player',
20
+ 'if_var': 'if_variable',
21
+ 'if_game': 'if_game',
22
+ 'if_entity': 'if_entity',
23
+ 'else': 'else_',
24
+ 'repeat': 'repeat',
25
+ 'control': 'control',
26
+ 'select_obj': 'select_object',
27
+ 'set_var': 'set_variable'
28
+ }
29
+
30
+ TARGET_CODEBLOCKS = {'player_action', 'entity_action', 'if_player', 'if_entity'}
31
+ SINGLE_NAME_CODEBLOCKS = {'func', 'process', 'call_func', 'start_process'}
32
+ VAR_SCOPES = {'unsaved': 'g', 'saved': 's', 'local': 'l', 'line': 'i'}
33
+
34
+
35
+ @dataclasses.dataclass
36
+ class GeneratorFlags:
37
+ indent_size: int
38
+ literal_shorthand: bool
39
+ var_shorthand: bool
40
+
41
+
42
+ def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
43
+ class_name = arg_item.__class__.__name__
44
+ if isinstance(arg_item, item):
45
+ return f'{class_name}.from_nbt("""{arg_item.get_nbt()}""")'
46
+
47
+ if isinstance(arg_item, string):
48
+ return f'{class_name}("{arg_item.value}")'
49
+
50
+ if isinstance(arg_item, text):
51
+ if flags.literal_shorthand:
52
+ return f'"{arg_item.value}"'
53
+ return f'{class_name}("{arg_item.value}")'
54
+
55
+ if isinstance(arg_item, num):
56
+ if not re.match(NUMBER_REGEX, str(arg_item.value)):
57
+ return f'{class_name}("{arg_item.value}")'
58
+ if flags.literal_shorthand:
59
+ return str(arg_item.value)
60
+ return f'{class_name}({arg_item.value})'
61
+
62
+ if isinstance(arg_item, loc):
63
+ loc_components = [arg_item.x, arg_item.y, arg_item.z]
64
+ if arg_item.pitch != 0:
65
+ loc_components.append(arg_item.pitch)
66
+ if arg_item.yaw != 0:
67
+ loc_components.append(arg_item.yaw)
68
+ return f'{class_name}({", ".join(str(c) for c in loc_components)})'
69
+
70
+ if isinstance(arg_item, var):
71
+ if flags.var_shorthand:
72
+ return f'"${VAR_SCOPES[arg_item.scope]}{arg_item.name}"'
73
+ if arg_item.scope == 'unsaved':
74
+ return f'{class_name}("{arg_item.name}")'
75
+ return f'{class_name}("{arg_item.name}", "{arg_item.scope}")'
76
+
77
+ if isinstance(arg_item, sound):
78
+ return f'{class_name}("{arg_item.name}", {arg_item.pitch}, {arg_item.vol})'
79
+
80
+ if isinstance(arg_item, particle):
81
+ return f'{class_name}({arg_item.particle_data})'
82
+
83
+ if isinstance(arg_item, potion):
84
+ return f'{class_name}("{arg_item.name}", {arg_item.dur}, {arg_item.amp})'
85
+
86
+ if isinstance(arg_item, gamevalue):
87
+ return f'{class_name}("{arg_item.name}", "{arg_item.target}")'
88
+
89
+ if isinstance(arg_item, parameter):
90
+ param_type_class_name = arg_item.param_type.__class__.__name__
91
+ param_args = [f'"{arg_item.name}"', f'{param_type_class_name}.{arg_item.param_type.name}']
92
+ if arg_item.plural:
93
+ param_args.append('plural=True')
94
+ if arg_item.optional:
95
+ param_args.append('optional=True')
96
+ if arg_item.default_value is not None:
97
+ param_args.append(f'default_value={argument_item_to_string(arg_item.default_value)}')
98
+ if arg_item.description:
99
+ param_args.append(f'description="{arg_item.description}"')
100
+ if arg_item.note:
101
+ param_args.append(f'note="{arg_item.note}"')
102
+ return f'{class_name}({", ".join(param_args)})'
103
+
104
+ if isinstance(arg_item, vector):
105
+ return f'{class_name}({arg_item.x}, {arg_item.y}, {arg_item.z})'
106
+
107
+
108
+ def add_script_line(flags: GeneratorFlags, script_lines: list[str], indent_level: int, line: str, add_comma: bool=True):
109
+ added_line = ' '*flags.indent_size*indent_level + line
110
+ if add_comma and indent_level > 0:
111
+ added_line += ','
112
+ script_lines.append(added_line)
113
+
114
+
115
+ def generate_script(template, flags: GeneratorFlags) -> str:
116
+ indent_level = 0
117
+ script_lines = []
118
+ for codeblock in template.codeblocks:
119
+ if codeblock.name == 'bracket':
120
+ if codeblock.data['direct'] == 'open':
121
+ add_script_line(flags, script_lines, indent_level, 't.bracket(', False)
122
+ indent_level += 1
123
+ elif codeblock.data['direct'] == 'close':
124
+ indent_level -= 1
125
+ add_script_line(flags, script_lines, indent_level, ')')
126
+ continue
127
+ if codeblock.name == 'else':
128
+ add_script_line(flags, script_lines, indent_level, 't.else_()')
129
+ continue
130
+
131
+ method_name = TEMPLATE_METHOD_LOOKUP[codeblock.data['block']]
132
+ method_args = [f'"{codeblock.name}"']
133
+ if codeblock.name in SINGLE_NAME_CODEBLOCKS:
134
+ method_args[0] = f'"{codeblock.data["data"]}"'
135
+
136
+ codeblock_args = [argument_item_to_string(flags, i) for i in codeblock.args]
137
+ if codeblock_args:
138
+ method_args.extend(codeblock_args)
139
+ if method_name in TARGET_CODEBLOCKS:
140
+ method_args.append(f'target=Target.{codeblock.target.name}')
141
+
142
+ line = f't.{method_name}({", ".join(method_args)})'
143
+ add_script_line(flags, script_lines, indent_level, line)
144
+ return SCRIPT_START + '\n'.join(script_lines)
dfpyre/style.py CHANGED
@@ -1,22 +1,22 @@
1
1
  import re
2
2
  from mcitemlib.style import STYLE_CODE_REGEX, FORMAT_CODES, StyledString
3
3
 
4
- def isAmpersandCoded(s: str) -> bool:
4
+ def is_ampersand_coded(s: str) -> bool:
5
5
  return bool(re.match(STYLE_CODE_REGEX, s))
6
6
 
7
7
 
8
- def ampersandToMinimessage(ampersand_code: str) -> str:
8
+ def ampersand_to_minimessage(ampersand_code: str) -> str:
9
9
  ampersand_code = ampersand_code.replace('&r', '<reset>') # bad but should work most of the time
10
- styledString = StyledString.from_codes(ampersand_code)
11
- formattedStringList = []
12
- for substring in styledString.substrings:
13
- formattedSubstringList = []
14
- for styleType, value in substring.data.items():
15
- if styleType in FORMAT_CODES.values() and value:
16
- formattedSubstringList.append(f'<{styleType}>')
17
- if styleType == 'color':
18
- formattedSubstringList.append(f'<{value}>')
10
+ styled_string = StyledString.from_codes(ampersand_code)
11
+ formatted_string_list = []
12
+ for substring in styled_string.substrings:
13
+ formatted_substring_list = []
14
+ for style_type, value in substring.data.items():
15
+ if style_type in FORMAT_CODES.values() and value:
16
+ formatted_substring_list.append(f'<{style_type}>')
17
+ if style_type == 'color':
18
+ formatted_substring_list.append(f'<{value}>')
19
19
 
20
- formattedSubstringList.append(substring.data['text'])
21
- formattedStringList.append(''.join(formattedSubstringList))
22
- return ''.join(formattedStringList)
20
+ formatted_substring_list.append(substring.data['text'])
21
+ formatted_string_list.append(''.join(formatted_substring_list))
22
+ return ''.join(formatted_string_list)
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Amp
3
+ Copyright (c) 2024 Amp
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dfpyre
3
- Version: 0.4.6
3
+ Version: 0.6.0
4
4
  Summary: A package for external creation of code templates for the DiamondFire Minecraft server.
5
5
  Home-page: https://github.com/Amp63/pyre
6
6
  License: MIT
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
- Requires-Dist: mcitemlib (>=0.1.0,<0.2.0)
15
+ Requires-Dist: mcitemlib (>=0.2.4,<0.3.0)
16
16
  Project-URL: Repository, https://github.com/Amp63/pyre
17
17
  Description-Content-Type: text/markdown
18
18
 
@@ -32,7 +32,7 @@ pip install dfpyre
32
32
  ## Features
33
33
  - All code block types
34
34
  - All code item types
35
- - Direct sending to DF via recode
35
+ - Direct sending to DF via recode or codeclient
36
36
  - Automatic type conversion (int to num, str to text)
37
37
  - Name checking ("did you mean ___?" for close matches)
38
38
  - Default tag values
@@ -41,7 +41,7 @@ pip install dfpyre
41
41
  ## Basics
42
42
 
43
43
  - [Setting up a program](#setup)
44
- - [Events and Actions](#eventsactions)
44
+ - [Events and Actions](#events-and-actions)
45
45
  - [Building](#building)
46
46
 
47
47
  ## Var Items
@@ -56,19 +56,22 @@ pip install dfpyre
56
56
  - [Potion](#potion)
57
57
  - [Game Value](#game-value)
58
58
  - [Vector](#vector)
59
+ - [Parameter](#parameter)
59
60
 
60
61
  ## Conditionals and Loops
61
62
 
62
- - [Conditionals and Brackets](#conditionalsbrackets)
63
+ - [Conditionals and Brackets](#conditionals-and-brackets)
63
64
  - [Loops](#loops)
64
65
 
65
66
  ## Functions and Procedures
66
67
 
67
- - [Creating Functions and Procedures](#create-functionsprocedures)
68
- - [Calling Functions and Procedures](#call-functionsprocedures)
68
+ - [Creating Functions and Processes](#creating-functions-and-processes)
69
+ - [Calling Functions and Processes](#calling-functions-and-processes)
69
70
 
70
71
  ## Extras
71
72
 
73
+ - [Importing from Code](#importing-from-code)
74
+ - [Script Generation](#script-generation)
72
75
  - [Method List](#method-list)
73
76
 
74
77
  ___
@@ -101,12 +104,12 @@ Here's a complete program that prints a message to every player when a player jo
101
104
  ```py
102
105
  from dfpyre import *
103
106
  t = DFTemplate()
104
- t.playerEvent('Join')
105
- t.playerAction('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
106
- t.buildAndSend()
107
+ t.player_event('Join')
108
+ t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
109
+ t.build_and_send('codeclient')
107
110
  ```
108
111
 
109
- ### Events/Actions
112
+ ### Events and Actions
110
113
 
111
114
  You can find a list of events and actions [here](#method-list)
112
115
 
@@ -117,14 +120,14 @@ The following program sends a message to all players and gives a player 10 apple
117
120
  ```py
118
121
  from dfpyre import *
119
122
  t = DFTemplate()
120
- t.playerEvent('Join')
121
- t.playerAction('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
122
- t.playerAction('GiveItems', item('apple', 10))
123
+ t.player_event('Join')
124
+ t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
125
+ t.player_action('GiveItems', item('apple', 10))
123
126
  ```
124
127
 
125
128
  ### Building
126
129
 
127
- You basically have 2 different options for building your code line.
130
+ You have 2 different options for building your code line.
128
131
  You can either:
129
132
 
130
133
  1. Save the compressed template code to a variable and send it to minecraft later
@@ -135,11 +138,9 @@ If you choose the first option, the code would look something like this:
135
138
  ```py
136
139
  from dfpyre import *
137
140
  t = DFTemplate()
138
- t.playerEvent('Join')
139
- t.playerAction('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
140
- templateCode = t.build()
141
-
142
- sendToDf(code, name='myJoinTemplate') # Send to minecraft client via recode item api
141
+ t.player_event('Join')
142
+ t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
143
+ template_code = t.build() # do whatever you want with this
143
144
  ```
144
145
 
145
146
  If you choose the second option, you can do this:
@@ -147,9 +148,9 @@ If you choose the second option, you can do this:
147
148
  ```py
148
149
  from dfpyre import *
149
150
  t = DFTemplate()
150
- t.playerEvent('Join')
151
- t.playerAction('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
152
- t.buildAndSend() # builds and sends automatically to minecraft
151
+ t.player_event('Join')
152
+ t.player_action('SendMessage', '%default has joined!', target=Target.ALL_PLAYERS)
153
+ t.build_and_send('codeclient') # builds and sends automatically to minecraft
153
154
  ```
154
155
 
155
156
  ### Variable Items
@@ -166,8 +167,8 @@ If a regular string is passed to a method as a chest parameter, it will automati
166
167
 
167
168
  ```py
168
169
  # These do the same thing:
169
- t.playerAction('SendMessage', text('%default joined.'))
170
- t.playerAction('SendMessage', '%default joined.')
170
+ t.player_action('SendMessage', text('%default joined.'))
171
+ t.player_action('SendMessage', '%default joined.')
171
172
  ```
172
173
 
173
174
  ### Number
@@ -183,8 +184,8 @@ If a regular integer or float is passed to a method as a chest parameter, it wil
183
184
 
184
185
  ```py
185
186
  # These do the same thing:
186
- t.setVariable('=', var('number'), num(10))
187
- t.setVariable('=', var('number'), 10)
187
+ t.set_variable('=', var('number'), num(10))
188
+ t.set_variable('=', var('number'), 10)
188
189
  ```
189
190
 
190
191
  ### Variable
@@ -196,19 +197,19 @@ var('num')
196
197
  var('text1')
197
198
  ```
198
199
 
199
- You can set variable values by using the `setVariable` method:
200
+ You can set variable values by using the `set_variable` method:
200
201
 
201
202
  ```py
202
- t.setVariable('=', var('num'), 12) # sets 'num' to 12
203
- t.setVariable('x', var('doubled'), var('num'), 2) # sets 'doubled' to 24
203
+ t.set_variable('=', var('num'), 12) # sets 'num' to 12
204
+ t.set_variable('x', var('doubled'), var('num'), 2) # sets 'doubled' to 24
204
205
  ```
205
206
 
206
207
  You can set the scope of the variable by using the `scope` argument:
207
208
 
208
209
  ```py
209
- t.setVariable('=', var(num1, scope='unsaved'), 12) # `unsaved` is the same as a game variable.
210
- t.setVariable('=', var(num1, scope='saved'), 12)
211
- t.setVariable('=', var(num1, scope='local'), 12)
210
+ t.set_variable('=', var(num1, scope='unsaved'), 12) # `unsaved` is the same as a game variable.
211
+ t.set_variable('=', var(num1, scope='saved'), 12)
212
+ t.set_variable('=', var(num1, scope='local'), 12)
212
213
  ```
213
214
 
214
215
  #### Shorthand Variables
@@ -216,8 +217,8 @@ t.setVariable('=', var(num1, scope='local'), 12)
216
217
  You can also use the variable shorthand format like this:
217
218
  ```py
218
219
  # These do the same thing:
219
- t.setVariable('=', var('lineVar', scope='line'), 5)
220
- t.setVariable('=', '$ilineVar', 5)
220
+ t.set_variable('=', var('lineVar', scope='line'), 5)
221
+ t.set_variable('=', '$ilineVar', 5)
221
222
  ```
222
223
 
223
224
  Shorthand vars should be formatted like this: `$[scope id][var name]`
@@ -233,7 +234,6 @@ Here's a list of the scope IDs:
233
234
  Represents a diamondfire location item:
234
235
 
235
236
  ```py
236
- # (var= is not required if numbers are in order, but is more readable)
237
237
  loc(x=25.5, y=50, z=25.5, pitch=0, yaw=-90)
238
238
  ```
239
239
 
@@ -243,8 +243,8 @@ Example:
243
243
  # teleport player on join
244
244
  from dfpyre import *
245
245
  t = DFTemplate()
246
- t.playerEvent('Join')
247
- t.playerAction('Teleport', loc(10, 50, 10))
246
+ t.player_event('Join')
247
+ t.player_action('Teleport', loc(10, 50, 10))
248
248
  ```
249
249
 
250
250
  ### Item
@@ -256,7 +256,7 @@ item('stick', count=5)
256
256
  item('stone', 64)
257
257
  ```
258
258
 
259
- Extra nbt (enchants, lore, etc.) is not supported right now.
259
+ To add extra data to an item, you can use any methods from the [mcitemlib](https://github.com/Amp63/mcitemlib) library
260
260
 
261
261
  ### Sound
262
262
 
@@ -272,8 +272,8 @@ Example:
272
272
  # plays 'Grass Place' sound on join
273
273
  from dfpyre import *
274
274
  t = DFTemplate()
275
- t.playerEvent('Join')
276
- t.playerAction('PlaySound', sound('Grass Place'))
275
+ t.player_event('Join')
276
+ t.player_action('PlaySound', sound('Grass Place'))
277
277
  ```
278
278
 
279
279
  ### Particle
@@ -281,7 +281,7 @@ t.playerAction('PlaySound', sound('Grass Place'))
281
281
  Represents a diamondfire particle item:
282
282
 
283
283
  ```py
284
- particle(name='Cloud', amount=10, horizontal=1.0, vertical=0.5, x=1.0, y=0.0, z=0.0, motionVariation=100)
284
+ particle({'particle':'Cloud','cluster':{'amount':1,'horizontal':0.0,'vertical':0.0},'data':{'x':1.0,'y':0.0,'z':0.0,'motionVariation':100}})
285
285
  ```
286
286
 
287
287
  Example:
@@ -290,8 +290,9 @@ Example:
290
290
  # plays a white cloud particle effect at 5, 50, 5
291
291
  from dfpyre import *
292
292
  t = DFTemplate()
293
- t.playerEvent('Join')
294
- t.playerAction('Particle', particle('Cloud'), loc(5, 50, 5))
293
+ t.player_event('Join')
294
+ 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}})
295
+ t.player_action('Particle', part, loc(5, 50, 5))
295
296
  ```
296
297
 
297
298
  Currently, the particle object does not support colors.
@@ -311,8 +312,8 @@ Example:
311
312
  # gives the player infinite saturation 255
312
313
  from dfpyre import *
313
314
  t = DFTemplate()
314
- t.playerEvent('Join')
315
- t.playerAction('GivePotion', potion('Saturation', amp=254))
315
+ t.player_event('Join')
316
+ t.player_action('GivePotion', potion('Saturation', amp=254))
316
317
  ```
317
318
 
318
319
  ### Game Value
@@ -331,7 +332,7 @@ Example:
331
332
  from dfpyre import *
332
333
  t = DFTemplate()
333
334
  t.function('printData')
334
- t.playerAction('SendMessage', gamevalue('Player Count'), gamevalue('CPU Usage'))
335
+ t.player_action('SendMessage', gamevalue('Player Count'), gamevalue('CPU Usage'))
335
336
  ```
336
337
 
337
338
  ### Vector
@@ -348,8 +349,8 @@ Example:
348
349
  # sets the player's x velocity to 1.0 on join
349
350
  from dfpyre import *
350
351
  t = DFTemplate()
351
- t.playerEvent('Join')
352
- t.playerAction('SetVelocity', vector(x=1.0, y=0.0, z=0.0))
352
+ t.player_event('Join')
353
+ t.player_action('SetVelocity', vector(x=1.0, y=0.0, z=0.0))
353
354
  ```
354
355
 
355
356
  ### Parameter
@@ -366,12 +367,12 @@ Example:
366
367
  # builds a function that says "Hello, [name]" where `name` is the inputted parameter.
367
368
  from dfpyre import *
368
369
  t = DFTemplate()
369
- nameParameter = parameter('name', ParameterType.TEXT)
370
- t.function('SayHi', nameParameter)
371
- t.playerAction('SendMessage', 'Hello, ', var('name', 'line'))
370
+ name_parameter = parameter('name', ParameterType.TEXT)
371
+ t.function('SayHi', name_parameter)
372
+ t.player_action('SendMessage', 'Hello, ', var('name', 'line'))
372
373
  ```
373
374
 
374
- ### Conditionals/Brackets
375
+ ### Conditionals and Brackets
375
376
 
376
377
  A list of conditionals and loops can be found [here](#commands).
377
378
 
@@ -381,10 +382,10 @@ A specific syntax must be followed when creating conditionals and loops. Each co
381
382
  # prints 'clicked' when a player right clicks with a stick in their hand
382
383
  from dfpyre import *
383
384
  t = DFTemplate()
384
- t.playerEvent('RightClick')
385
- t.ifPlayer('IsHolding', item('stick'))
385
+ t.player_event('RightClick')
386
+ t.if_player('IsHolding', item('stick'))
386
387
  t.bracket(
387
- t.playerAction('SendMessage', 'clicked')
388
+ t.player_action('SendMessage', 'clicked')
388
389
  )
389
390
  ```
390
391
 
@@ -395,13 +396,13 @@ To create an `else` statement, use the `else_` method:
395
396
  from dfpyre import *
396
397
  t = DFTemplate()
397
398
  t.function('grounded')
398
- t.ifPlayer('IsGrounded')
399
+ t.if_player('IsGrounded')
399
400
  t.bracket(
400
- t.playerAction('ActionBar', 'on the ground')
401
+ t.player_action('ActionBar', 'on the ground')
401
402
  )
402
403
  t.else_()
403
404
  t.bracket(
404
- t.playerAction('ActionBar', 'in the air')
405
+ t.player_action('ActionBar', 'in the air')
405
406
  )
406
407
  t.build()
407
408
  ```
@@ -414,14 +415,14 @@ As for loops, the bracket syntax is the same and will automatically change to "r
414
415
  # prints numbers 1-5
415
416
  from dfpyre import *
416
417
  t = DFTemplate()
417
- t.playerEvent('Join')
418
+ t.player_event('Join')
418
419
  t.repeat('Multiple', var('i'), 5)
419
420
  t.bracket(
420
- t.playerAction('SendMessage', var('i'))
421
+ t.player_action('SendMessage', var('i'))
421
422
  )
422
423
  ```
423
424
 
424
- ### Creating Functions/Processes
425
+ ### Creating Functions and Processes
425
426
 
426
427
  To create a function or process, just start the template with a `function` or `process` method:
427
428
 
@@ -430,45 +431,70 @@ To create a function or process, just start the template with a `function` or `p
430
431
  from dfpyre import *
431
432
  t = DFTemplate()
432
433
  t.function('doStuff')
433
- t.playerAction('GiveItems', item('golden_apple', 64))
434
+ t.player_action('GiveItems', item('golden_apple', 64))
434
435
  ```
435
436
 
436
- ### Calling Functions/Processes
437
+ ### Calling Functions and Processes
437
438
 
438
439
  Calling Functions and processes is also simple:
439
440
 
440
441
  ```py
441
442
  from dfpyre import *
442
443
  t = DFTemplate()
443
- t.playerEvent('Join')
444
- t.callFunction('doStuff')
444
+ t.player_event('Join')
445
+ t.call_function('doStuff')
446
+ ```
447
+
448
+ ### Importing from Code
449
+
450
+ You can import existing templates from their built code using the `from_code` method:
451
+
452
+ ```py
453
+ from dfpyre import *
454
+ template_code = 'H4sIAGVyIGYC/3WOMQ7CMAxFz4LnDsw5AhITI6qQSaw2IrGrxkJCVe5eh3boAJP9n/Kfs8AziX8VcPcFYgC3Zej26YDexGoZvUZhAxeJ3PI8WMtKSrnV+1q7P4op4Yfmx244qG7E4Uql4EA/jNv2Jc3qJU/2KqBiY4yZjI6UkpzAjkNJouDO1X7S1xUDaGUl2QAAAA=='
455
+
456
+ t = DFTemplate.from_code(template_code)
457
+ # add onto the template from here
458
+ ```
459
+
460
+
461
+ ### Script Generation
462
+
463
+ You can also generate an equivalent python script for a template from a template object:
464
+
465
+ ```py
466
+ from dfpyre import *
467
+ template_code = 'H4sIAGVyIGYC/3WOMQ7CMAxFz4LnDsw5AhITI6qQSaw2IrGrxkJCVe5eh3boAJP9n/Kfs8AziX8VcPcFYgC3Zej26YDexGoZvUZhAxeJ3PI8WMtKSrnV+1q7P4op4Yfmx244qG7E4Uql4EA/jNv2Jc3qJU/2KqBiY4yZjI6UkpzAjkNJouDO1X7S1xUDaGUl2QAAAA=='
468
+
469
+ t = DFTemplate.from_code(template_code)
470
+ t.generate_script('my_template.py') # generated python script will be written to my_template.py
445
471
  ```
446
472
 
447
473
  ### Method List
448
474
 
449
475
  - Events / Function / Process
450
- - playerEvent
451
- - entityEvent
476
+ - player_event
477
+ - entity_event
452
478
  - function
453
479
  - process
454
- - callFunction
455
- - startProcess
480
+ - call_function
481
+ - start_process
456
482
 
457
483
  - Actions
458
- - playerAction
459
- - gameAction
460
- - entityAction
484
+ - player_action
485
+ - game_action
486
+ - entity_action
461
487
 
462
488
  - Conditionals / Loops
463
- - ifPlayer
464
- - ifVariable
465
- - ifGame
466
- - ifEntity
467
- - else_ (don't forget underscore)
489
+ - if_player
490
+ - if_variable
491
+ - if_game
492
+ - if_entity
493
+ - else_
468
494
  - repeat
469
495
  - bracket
470
496
 
471
497
  - Other
472
498
  - control
473
- - selectObject
474
- - setVariable
499
+ - select_object
500
+ - set_variable
@@ -0,0 +1,10 @@
1
+ dfpyre/__init__.py,sha256=apPsSxJ1Tztfl71MoORoSmDfX7LyKLYlLwOGeLQUitw,25
2
+ dfpyre/data/data.json,sha256=M4EHXKkh7Cx7y3BQ6c3csvmNmSqP2oE4txLI9MZcDDA,30347
3
+ dfpyre/items.py,sha256=t9KsvhPOEe36_E7CNdgxNmEKtOF6nMvNZURyYFiXJb4,9215
4
+ dfpyre/pyre.py,sha256=wn75bzj4dteAMtOELuV7Q0Xe46FBcFbdzHlcc7yRnU4,16970
5
+ dfpyre/scriptgen.py,sha256=OS9VfFSTjIaxa28FqMxfIQ0bdfIJsI0ZqJo3UhHTYJ4,5450
6
+ dfpyre/style.py,sha256=mLW1CFvvi8_9fk8JaH10I5S4WI0YBdQIXHtI3G_4sR8,980
7
+ dfpyre-0.6.0.dist-info/LICENSE,sha256=_vuDskB0ja2c-Fgm7Gt8Q8cO9NsLNpZAVyvmZwX7E6o,1060
8
+ dfpyre-0.6.0.dist-info/METADATA,sha256=c0t4TVbXxz_KB-kYtz7MjJP_4kqIU463b156zMJJKD8,11344
9
+ dfpyre-0.6.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
10
+ dfpyre-0.6.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- dfpyre/__init__.py,sha256=apPsSxJ1Tztfl71MoORoSmDfX7LyKLYlLwOGeLQUitw,25
2
- dfpyre/data/data.json,sha256=M4EHXKkh7Cx7y3BQ6c3csvmNmSqP2oE4txLI9MZcDDA,30347
3
- dfpyre/items.py,sha256=2cinNNMBgpGA8cU25RsLyp_TllBUfR2k7vXGjUi5Xjs,8862
4
- dfpyre/pyre.py,sha256=p-3k8AHJNvCH2g9FNYslaWMD4TNB0X51vkZzuAUlIv8,16363
5
- dfpyre/style.py,sha256=8ueN_l94oKWnqKJRLMgC3cOWhj7hfmlHhGuZHm7Rzjg,954
6
- dfpyre-0.4.6.dist-info/LICENSE,sha256=atkly29RNUY2evLoPyurzCJeQnhP-VCAD-JZEbq3mno,1060
7
- dfpyre-0.4.6.dist-info/METADATA,sha256=BPp1Fh0PvNFpy1RITc-hnoRrOT3LG_RZV4WZnDnedUs,10079
8
- dfpyre-0.4.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
9
- dfpyre-0.4.6.dist-info/RECORD,,
File without changes