stujones11 / minetest-3d_armor

Visible player armor & wielded items for minetest
Other
56 stars 98 forks source link

Allow mod-defined wield item transformation via group #99

Closed Wuzzy2 closed 7 years ago

Wuzzy2 commented 7 years ago

This PR allows mods to define their own transformation via the new group wieldview_transform. The rating equals the number used for the texture modifier [transform. E.g. you can use wieldview_transform=3 for a rotation by 270 degrees. The group takes precedence over transform.lua, which is still supported.

Rationale: It is better to make the mods define the correct transformation instead of trying to support all items under the sun in a single mod.

This PR also removes the default dependency because this mod works without default.

stujones11 commented 7 years ago

To be fair, the wieldview.transform table is global so it is already possible for a mod to insert a new entry if it exists. However, this method is more convenient and does not require any dependencies or global checks. I am just wondering if the same idea could be extended to my wield3d mod, so perhaps a more generic group name like wield_rotation?

stujones11 commented 7 years ago

Since [transform is capable of more that just rotation I think the wieldview_transform group is fine. However, I may also add support for a wield_rotation group that can work with both mods at a later date.

stujones11 commented 7 years ago

I have just noticed something, the number needs to be prefixed with 'R' therefore it can only be used for rotations. I will fix this and re-name the group to wield_rotation after all, I hope you don't mind.

Wuzzy2 commented 7 years ago

Sigh. Read again:

  #### `[transform<t>`
  * `<t>` = transformation(s) to apply

  Rotates and/or flips the image.

  `<t>` can be a number (between 0 and 7) or a transform name.
  Rotations are counter-clockwise.

      0  I      identity
      1  R90    rotate by 90 degrees
      2  R180   rotate by 180 degrees
      3  R270   rotate by 270 degrees
      4  FX     flip X
      5  FXR90  flip X then rotate by 90 degrees
      6  FY     flip Y
      7  FYR90  flip Y then rotate by 90 degrees

And again:

 `<t>` can be a number (between 0 and 7) or a transform name.

This means, you can legally use [transform0, [transform1, [transform2, etc. for all 8 transformations (including flips). That's what the group rating was meant for.

stujones11 commented 7 years ago

Sorry, I was not aware of that usage. I have just hard reset the last commit, thanks for letting me know. I still do not understand your negative reaction to also recognising a wield_rotation group (or field even), that would then work with both mods which can indeed be used together.