[Solved] How do i rotate nodeboxes in degrees

Post Reply
User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

[Solved] How do i rotate nodeboxes in degrees

by Jeksta » Post

I know that you can rotate nodeboxes using.

Code: Select all

paramtype2 = "facedir"
But then you can only rotate the node in 90° steps.
So is it possible to do this with numbers between 90° or do i have to create "transition nodeboxes"?
Last edited by Jeksta on Fri Sep 06, 2019 15:52, edited 1 time in total.

User avatar
Andrey01
Member
Posts: 2371
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: How do i rotate nodeboxes in degrees

by Andrey01 » Post

It's impossible to rotate nodeboxes at an oblique angle. Only at the right one.

User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

Re: How do i rotate nodeboxes in degrees

by Jeksta » Post

Hm, would be a nice feature to have, like animating a nodebox.

Thanks anyways.

neoh4x0r
Member
Posts: 74
Joined: Wed Aug 29, 2018 20:16
GitHub: neoh4x0r

Re: How do i rotate nodeboxes in degrees

by neoh4x0r » Post

Jeksta wrote:I know that you can rotate nodeboxes using.

Code: Select all

paramtype2 = "facedir"
But then you can only rotate the node in 90° steps.
So is it possible to do this with numbers between 90° or do i have to create "transition nodeboxes"?
I wonder if you rotated the node fast enough -- you might be able to take advantage of persistence of vision and maybe give the illusion of it rotating through smaller angles.

User avatar
duane
Member
Posts: 1612
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: How do i rotate nodeboxes in degrees

by duane » Post

Jeksta wrote:Hm, would be a nice feature to have, like animating a nodebox.

Thanks anyways.
If you turn the node into an entity, you can put it at any angle you want, then turn it back. Of course you'd have to have a situation where the node will be facing a cardinal point at the end of its motion, and there won't be very many in motion at once.
Believe in people and you don't need to believe anything else.

User avatar
AiTechEye
Member
Posts: 780
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: How do i rotate nodeboxes in degrees

by AiTechEye » Post

Code: Select all

minetest.register_node("mod:test", {
	tiles={"default_wood.png","default_wood.png","default_wood.png^default_stick.png",},
	paramtype2 = "facedir",
	groups = {dig_immediate = 3},
	on_rightclick = function(pos, node, player, itemstack, pointed_thing)
		print(node.param2+1)
		minetest.set_node(pos,{name="mod:test",param2=node.param2+1})
	end,
})

User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

Re: How do i rotate nodeboxes in degrees

by Jeksta » Post

AiTechEye wrote:

Code: Select all

minetest.register_node("mod:test", {
	tiles={"default_wood.png","default_wood.png","default_wood.png^default_stick.png",},
	paramtype2 = "facedir",
	groups = {dig_immediate = 3},
	on_rightclick = function(pos, node, player, itemstack, pointed_thing)
		print(node.param2+1)
		minetest.set_node(pos,{name="mod:test",param2=node.param2+1})
	end,
})
Thats the solution i currently have too.

Code: Select all

node.param2 = (node.param2 + 1) % 4
minetest.set_node(pos, node)
Basically i'm trying to simulate a crank, but 90° turns look really harsh.
The entity solution would probably work, but my knowledge of entities is kind of non existent.

Atm i'm going for a toggle method between a straight crank and a crooked one, because this seems like a problem i could solve.

ShadMOrdre
Member
Posts: 619
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: How do i rotate nodeboxes in degrees

by ShadMOrdre » Post

What if you used gears_3d mod?

What if, as an alternative to gears_3d, you used an item_stand like setup, where the node below spawns an entity above, that can be set to rotate yaw. This only works for gears/sprockets that horizontal, as vertically aligned gears aren't possible without pitch rotation for entities.

Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

User avatar
AiTechEye
Member
Posts: 780
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: How do i rotate nodeboxes in degrees

by AiTechEye » Post

Code: Select all

minetest.register_entity("default:entity",{
	visual = "cube",
	textures={"default_dirt.png","default_dirt.png","default_dirt.png","default_dirt.png","default_dirt.png","default_dirt.png",},
	on_activate=function(self, staticdata)
		--while entity is spawned/loaded
	end,
	on_step=function(self,dtime)
		local r = self.object:get_rotation()
		r.y = r.y + 0.1
		self.object:set_rotation(r)
	end,
})

minetest.add_entity(pos, "default:entity")
https://dev.minetest.net/minetest.register_entity

ShadMOrdre
Member
Posts: 619
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: How do i rotate nodeboxes in degrees

by ShadMOrdre » Post

That's the spirit AITechEye!
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

Re: How do i rotate nodeboxes in degrees

by Jeksta » Post

Ok, for people who might have the same problem. This is the solution i came up with (including solutions from this post):

The node spawns an attached entity above itself, (on_consturct)
then the entity saves its handle and the node position in the table local attached_entity = {} (on_activation)
If the node is destroyed, it deletes the entity handle and entry in the attached_entity table. (on_destruct)

Code: Select all

local attached_entity = {}

minetest.register_entity(
   "mod:attached_entity",
   {
    on_activate = function(self, staticdata, dtime_s)
       local entity_pos = self.object:get_pos()
       local node_pos = {
          x = math.floor(entity_pos.x),
          y = math.floor(entity_pos.y) - 1,
          z = math.floor(entity_pos.z)
       }
       local ser_pos = minetest.serialize(node_pos)

       attached_entity[ser_pos] = self.object
    end,
})

minetest.register_node(
   "mod:node",
   {
   on_construct = function(pos)
      local ser_pos = minetest.serialize(pos)
      minetest.add_entity({x = pos.x, y = pos.y + 1, z = pos.z}, "mod:attached_entity")
   end,

   on_destruct = function(pos)
   local ser_pos = minetest.serialize(pos)
      if attached_entity[ser_pos] then
         attached_entity[ser_pos]:remove()
         attached_entity[ser_pos] = nil
      end
   end
})
Not sure whether it's an elegant solution, but that's what i'm going with for now.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest