sm-blueprint-lib 0.0.11__tar.gz → 0.0.13__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.
Files changed (74) hide show
  1. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/PKG-INFO +7 -2
  2. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/README.md +4 -0
  3. sm_blueprint_lib-0.0.13/block_test.py +16 -0
  4. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/pyproject.toml +3 -1
  5. sm_blueprint_lib-0.0.13/rot_tests.py +27 -0
  6. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/__init__.py +7 -0
  7. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/bases/__init__.py +3 -0
  8. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/bases/controllers/__init__.py +5 -0
  9. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/controllers/sensorcontroller.py +2 -2
  10. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/bases/joints/__init__.py +6 -0
  11. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/joints/pistonjoint.py +2 -1
  12. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/joints/suspensionjoint.py +2 -1
  13. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/bases/parts/__init__.py +4 -0
  14. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/parts/baseboundablepart.py +1 -4
  15. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/parts/baseinteractablepart.py +3 -0
  16. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/parts/baselogicpart.py +1 -3
  17. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/parts/basepart.py +22 -3
  18. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/blueprint.py +12 -2
  19. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/body.py +4 -0
  20. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/constants.py +1092 -0
  21. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/id.py +8 -0
  22. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/__init__.py +4 -0
  23. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/barrierblock.py +3 -1
  24. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/bearing.py +3 -1
  25. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/parts/block.py +12 -0
  26. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/button.py +3 -1
  27. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/logicgate.py +3 -1
  28. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/parts/piston.py +39 -0
  29. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/parts/sensor.py +60 -0
  30. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/parts/suspension.py +74 -0
  31. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/switch.py +3 -1
  32. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/parts/timer.py +3 -1
  33. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/rot.py +17 -0
  34. sm_blueprint_lib-0.0.13/src/sm_blueprint_lib/utils.py +329 -0
  35. sm_blueprint_lib-0.0.13/test_connections.py +73 -0
  36. sm_blueprint_lib-0.0.13/test_joints.py +881 -0
  37. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/tests.py +2 -2
  38. sm_blueprint_lib-0.0.11/src/sm_blueprint_lib/constants.py +0 -45
  39. sm_blueprint_lib-0.0.11/src/sm_blueprint_lib/id.py +0 -5
  40. sm_blueprint_lib-0.0.11/src/sm_blueprint_lib/parts/piston.py +0 -9
  41. sm_blueprint_lib-0.0.11/src/sm_blueprint_lib/parts/sensor.py +0 -24
  42. sm_blueprint_lib-0.0.11/src/sm_blueprint_lib/parts/suspension.py +0 -14
  43. sm_blueprint_lib-0.0.11/src/sm_blueprint_lib/utils.py +0 -137
  44. sm_blueprint_lib-0.0.11/test_connections.py +0 -72
  45. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/.gitattributes +0 -0
  46. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/.gitignore +0 -0
  47. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/1to1andloop.png +0 -0
  48. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/LICENSE +0 -0
  49. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/manytooneandmanytomany.png +0 -0
  50. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/rowtorowand1tomany.png +0 -0
  51. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/controllers/basecontroller.py +0 -0
  52. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/controllers/baselogiccontroller.py +0 -0
  53. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/controllers/logicgatecontroller.py +0 -0
  54. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/controllers/timercontroller.py +0 -0
  55. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/joints/basejoint.py +0 -0
  56. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/joints/basejointcontroller.py +0 -0
  57. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/joints/pistonjointcontroller.py +0 -0
  58. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bases/joints/suspensionjointcontroller.py +0 -0
  59. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/bounds.py +0 -0
  60. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/pos.py +0 -0
  61. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/__init__.py +0 -0
  62. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/adder.py +0 -0
  63. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/barrel_shifter.py +0 -0
  64. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/clock40hz.py +0 -0
  65. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/comparator.py +0 -0
  66. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/counter.py +0 -0
  67. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/decoder.py +0 -0
  68. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/distance_sensor.py +0 -0
  69. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/ram.py +0 -0
  70. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/register.py +0 -0
  71. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/rom.py +0 -0
  72. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/timer_ram_cached.py +0 -0
  73. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/src/sm_blueprint_lib/prebuilds/timer_ram_multiclient.py +0 -0
  74. {sm_blueprint_lib-0.0.11 → sm_blueprint_lib-0.0.13}/test_prebuilds.py +0 -0
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sm_blueprint_lib
3
- Version: 0.0.11
3
+ Version: 0.0.13
4
4
  Summary: Scrap Mechanic Library for Blueprint manipulation.
5
5
  Project-URL: Homepage, https://github.com/MauriceTZ/sm_blueprint_lib
6
6
  Project-URL: Issues, https://github.com/MauriceTZ/sm_blueprint_lib/issues
7
- Author-email: Maurice <mauriciotorrez00@gmail.com>
7
+ Author: niknal357
8
+ Author-email: Maurice <mauriciotorrez00@gmail.com>, lnventorsteve <dylanv60431@gmail.com>
8
9
  License-Expression: MIT
9
10
  License-File: LICENSE
10
11
  Classifier: Operating System :: OS Independent
@@ -20,6 +21,10 @@ Description-Content-Type: text/markdown
20
21
  ```sh
21
22
  pip install sm_blueprint_lib
22
23
  ```
24
+ ## Updating version
25
+ ```sh
26
+ pip install --upgrade sm_blueprint_lib
27
+ ```
23
28
  ## Usage
24
29
  ```python
25
30
  import numpy as np
@@ -5,6 +5,10 @@
5
5
  ```sh
6
6
  pip install sm_blueprint_lib
7
7
  ```
8
+ ## Updating version
9
+ ```sh
10
+ pip install --upgrade sm_blueprint_lib
11
+ ```
8
12
  ## Usage
9
13
  ```python
10
14
  import numpy as np
@@ -0,0 +1,16 @@
1
+ from src.sm_blueprint_lib import *
2
+
3
+ bp = Blueprint()
4
+
5
+
6
+ ship = Block(SHAPEID.Spaceship_Block,(0,0,0),COLOR.Spaceship_Block)
7
+
8
+ print(ship.color)
9
+ print(ship.shapeId)
10
+ print(ship.pos)
11
+
12
+ wood = Block(SHAPEID.Wood_Block_1,(1,0,0),COLOR.Wood_Block_1)
13
+
14
+ print(wood.color)
15
+ print(wood.shapeId)
16
+ print(wood.pos)
@@ -4,10 +4,12 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sm_blueprint_lib"
7
- version = "0.0.11"
7
+ version = "0.0.13"
8
8
  dependencies = ["numpy"]
9
9
  authors = [
10
10
  { name="Maurice", email="mauriciotorrez00@gmail.com" },
11
+ { name="lnventorsteve", email="dylanv60431@gmail.com" },
12
+ { name="niknal357" },
11
13
  ]
12
14
  description = "Scrap Mechanic Library for Blueprint manipulation."
13
15
  readme = "README.md"
@@ -0,0 +1,27 @@
1
+ from pprint import pp
2
+
3
+ from src.sm_blueprint_lib import *
4
+
5
+ bp = Blueprint()
6
+
7
+ g0 = LogicGate((1, 0, 0), "ffffff") # .rotate("up", "right")
8
+ g1 = LogicGate((2, 0, 0), "ffffff").rotate("up", "left")
9
+ g2 = LogicGate((3, 0, 0), "ffffff").rotate("up", "up")
10
+ g3 = LogicGate((4, 0, 0), "ffffff").rotate("up", "down")
11
+ g4 = LogicGate((5, 0, 0), "ffffff").rotate("up", "right")
12
+
13
+ bp.add(g0,
14
+ g1,
15
+ g2,
16
+ g3,
17
+ g4,
18
+ # show the axis just for debugging
19
+ BarrierBlock((0, 0, -1), "ffffff", (1, 1, 1)),
20
+ BarrierBlock((1, -1, -1), "ff0000", (5, 3, 1)),
21
+ BarrierBlock((0, 1, -1), "00ff00", (1, 3, 1)),
22
+ BarrierBlock((0, 0, 0), "0000ff", (1, 1, 5)),
23
+ )
24
+ path = r"C:\Users\mauri\AppData\Roaming\Axolot Games\Scrap Mechanic\User\User_76561198400983548\Blueprints\c35f6e4e-52cb-4b00-8afa-f0ffd3fbb012\blueprint.json"
25
+
26
+ pp(bp)
27
+ save_blueprint(bp, path)
@@ -1,3 +1,8 @@
1
+ """
2
+ # sm_blueprint_lib
3
+ asdasdasdasds
4
+ """
5
+
1
6
  from .blueprint import *
2
7
  from .body import *
3
8
  from .bounds import *
@@ -8,3 +13,5 @@ from .utils import *
8
13
 
9
14
  from .parts import *
10
15
  from .prebuilds import *
16
+ from .rot import *
17
+ from .bases import *
@@ -0,0 +1,3 @@
1
+ from .controllers import *
2
+ from .joints import *
3
+ from .parts import *
@@ -0,0 +1,5 @@
1
+ from .basecontroller import *
2
+ from .baselogiccontroller import *
3
+ from .logicgatecontroller import *
4
+ from .sensorcontroller import *
5
+ from .timercontroller import *
@@ -7,7 +7,7 @@ from .basecontroller import BaseController
7
7
  class SensorController(BaseController):
8
8
  """Sensor's Controller
9
9
  """
10
- audioEnable: bool
10
+ audioEnabled: bool
11
11
  buttonMode: bool
12
12
  color: str
13
13
  colorMode: bool
@@ -19,6 +19,6 @@ class SensorController(BaseController):
19
19
  if not isinstance(self.color, str):
20
20
  self.color = "%02X%02X%02X" % (
21
21
  self.color[0], self.color[1], self.color[2])
22
- self.audioEnable = bool(self.audioEnable)
22
+ self.audioEnabled = bool(self.audioEnabled)
23
23
  self.buttonMode = bool(self.buttonMode)
24
24
  self.colorMode = bool(self.colorMode)
@@ -0,0 +1,6 @@
1
+ from .basejoint import *
2
+ from .basejointcontroller import *
3
+ from .pistonjoint import *
4
+ from .pistonjointcontroller import *
5
+ from .suspensionjoint import *
6
+ from .suspensionjointcontroller import *
@@ -10,4 +10,5 @@ class PistonJoint(BaseJoint):
10
10
 
11
11
  def __post_init__(self):
12
12
  super().__post_init__()
13
- self.controller = PistonJointController(**self.controller)
13
+ if not isinstance(self.controller, PistonJointController):
14
+ self.controller = PistonJointController(**self.controller)
@@ -10,4 +10,5 @@ class SuspensionJoin(BaseJoint):
10
10
 
11
11
  def __post_init__(self):
12
12
  super().__post_init__()
13
- self.controller = SuspensionJointController(**self.controller)
13
+ if not isinstance(self.controller, SuspensionJointController):
14
+ self.controller = SuspensionJointController(**self.controller)
@@ -0,0 +1,4 @@
1
+ from .baseboundablepart import *
2
+ from .baseinteractablepart import *
3
+ from .baselogicpart import *
4
+ from .basepart import *
@@ -2,16 +2,13 @@ from dataclasses import dataclass, field
2
2
 
3
3
  from .basepart import BasePart
4
4
  from ...bounds import Bounds
5
- from ...constants import AXIS
6
5
 
7
6
 
8
7
  @dataclass
9
8
  class BaseBoundablePart(BasePart):
10
9
  """Base class for all Boundable parts (those that are draggable)
11
10
  """
12
- bounds: Bounds
13
- xaxis: int = field(kw_only=True, default=AXIS.DEFAULT_XAXIS)
14
- zaxis: int = field(kw_only=True, default=AXIS.DEFAULT_ZAXIS)
11
+ bounds: Bounds = field(kw_only=True, default=(1,1,1))
15
12
 
16
13
  def __post_init__(self):
17
14
  super().__post_init__()
@@ -3,6 +3,7 @@ from dataclasses import dataclass, field
3
3
  from ..controllers.basecontroller import BaseController
4
4
  from .basepart import BasePart
5
5
  from ...id import ID
6
+ from ...constants import AXIS
6
7
 
7
8
 
8
9
  @dataclass
@@ -10,6 +11,8 @@ class BaseInteractablePart(BasePart):
10
11
  """Base class for Interactable parts
11
12
  """
12
13
  controller: BaseController = field(default_factory=BaseController)
14
+ xaxis: int = field(kw_only=True, default=AXIS.DEFAULT_XAXIS_INTERACTABLE)
15
+ zaxis: int = field(kw_only=True, default=AXIS.DEFAULT_ZAXIS_INTERACTABLE)
13
16
 
14
17
  def connect(self, o: "BaseInteractablePart"):
15
18
  if not self.controller.controllers:
@@ -8,6 +8,4 @@ from ..controllers.baselogiccontroller import BaseLogicController
8
8
  class BaseLogicPart(BaseInteractablePart):
9
9
  """Base class for Logic parts with active state (mostly Logic Gate and Timer)
10
10
  """
11
- controller: BaseLogicController = field(default_factory=BaseLogicController)
12
- xaxis: int = field(kw_only=True, default=1)
13
- zaxis: int = field(kw_only=True, default=-2)
11
+ controller: BaseLogicController = field(default_factory=BaseLogicController)
@@ -1,7 +1,7 @@
1
1
  from dataclasses import dataclass, field
2
2
  from typing import Optional
3
3
 
4
- from ...constants import AXIS, SHAPEID
4
+ from ...constants import ROTATION, SHAPEID, AXIS, COLOR
5
5
  from ...pos import Pos
6
6
  from ...id import ID
7
7
 
@@ -12,7 +12,7 @@ class BasePart:
12
12
  """
13
13
  shapeId: str
14
14
  pos: Pos
15
- color: str
15
+ color: str = field(kw_only=True, default=COLOR.DEFAULT)
16
16
  joints: Optional[list[ID]] = field(kw_only=True, default=None)
17
17
  xaxis: int = field(kw_only=True, default=AXIS.DEFAULT_XAXIS)
18
18
  zaxis: int = field(kw_only=True, default=AXIS.DEFAULT_ZAXIS)
@@ -24,12 +24,16 @@ class BasePart:
24
24
  self.pos = Pos(**self.pos)
25
25
  except TypeError:
26
26
  self.pos = Pos(self.pos[0], self.pos[1], self.pos[2])
27
+
27
28
  # if color given as (r, g, b) then convert to hex string
28
29
  if not isinstance(self.color, str):
29
30
  self.color = "%02X%02X%02X" % (
30
31
  self.color[0], self.color[1], self.color[2])
31
32
  if self.joints:
32
- self.joints = [ID(**id) for id in self.joints]
33
+ self.joints = [ID(**id)
34
+ if not isinstance(id, ID) else
35
+ id
36
+ for id in self.joints]
33
37
 
34
38
  def __init_subclass__(cls):
35
39
  super().__init_subclass__()
@@ -37,3 +41,18 @@ class BasePart:
37
41
  SHAPEID.SHAPEID_TO_CLASS[cls.shapeId.default] = cls
38
42
  except AttributeError:
39
43
  pass
44
+
45
+ def rotate(self, facing: ROTATION.FACING, rotated: ROTATION.ROTATED):
46
+ """Sets the rotation of a Part.
47
+
48
+ Args:
49
+ facing (ROTATION.FACING): String indicating facing direction of the Part.
50
+ rotated (ROTATION.ROTATED): String indicating rotated direction of the face.
51
+ """
52
+ x, y, z, x_axis, z_axis = ROTATION.ROTATION_TABLE[facing][rotated]
53
+ self.pos.x += x
54
+ self.pos.y += y
55
+ self.pos.z += z
56
+ self.xaxis = x_axis
57
+ self.zaxis = z_axis
58
+ return self
@@ -9,14 +9,24 @@ from .constants import VERSION, SHAPEID
9
9
 
10
10
  @dataclass
11
11
  class Blueprint:
12
+ """Class that represents a Blueprint structure.
13
+ It is type hinted, meaning you can access its members
14
+ with the dot syntax instead of direcly indexing a JSON object.
15
+ """
12
16
  bodies: list[Body] = field(default_factory=lambda: [{}])
13
17
  joints: Optional[list[BaseJoint]] = None
14
18
  version: int = VERSION.BLUEPRINT_VERSION
15
19
 
16
20
  def __post_init__(self):
17
- self.bodies = [Body(**body) for body in self.bodies]
21
+ self.bodies = [Body(**body)
22
+ if not isinstance(body, Body) else
23
+ body
24
+ for body in self.bodies]
18
25
  if self.joints:
19
- self.joints = [SHAPEID.JOINT_TO_CLASS[j["shapeId"]](**j) for j in self.joints]
26
+ self.joints = [SHAPEID.JOINT_TO_CLASS[j["shapeId"]](**j)
27
+ if not isinstance(j, BaseJoint) else
28
+ j
29
+ for j in self.joints]
20
30
 
21
31
  def add(self, *obj, body=0):
22
32
  """Adds the object(s) to the blueprint.
@@ -6,8 +6,12 @@ from .constants import SHAPEID
6
6
 
7
7
  @dataclass
8
8
  class Body:
9
+ """Class that represents a Body inside a Blueprint, each Joint defines a new Body.
10
+ """
9
11
  childs: list[BasePart] = field(default_factory=list)
10
12
 
11
13
  def __post_init__(self):
12
14
  self.childs = [SHAPEID.SHAPEID_TO_CLASS[child["shapeId"]](**child)
15
+ if not isinstance(child, BasePart) else
16
+ child
13
17
  for child in self.childs]