[SOLVED] collision and selection

Post Reply
User avatar
Steamed_Punk
Member
Posts: 156
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

[SOLVED] collision and selection

by Steamed_Punk » Post

I understand that this would give a 1m box from the centre.

collisionbox = {-0.5,-0.5,-0.5, 0.5, 0.5 , 0.5},

I have used collision and selection on my tepee and it works just fine and on 5.3.0 so it's not broken.

I have tried with collisionbox & collision_box and no matter what I try the box stays 1m in size.

In fact I have just created a simple column that has a top and bottom and 8 sides. It is exactly 2m high and 1m in diameter. The centre point is in the centre but sat at 1m high (being the centre of a 2m high block). I have even copied the code from the tepee (that works) and still no change.

How do I code collision for a mesh that is 1 node by 2 in height? I am running out of keyboard numbers and combinations and now hair to pull out :-D

cheers
Last edited by Steamed_Punk on Mon Oct 05, 2020 20:36, edited 1 time in total.
The sky is not the limit - It's my playground

User avatar
Steamed_Punk
Member
Posts: 156
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

[SOLVED]Re: collision and selection

by Steamed_Punk » Post

OK, I found my problem.

My other mod relied on api's whereas this model doesn't.
With the centre lowered I did this if it's any use to anyone else. (If not, a mod can delete this)



selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
},
},

The sky is not the limit - It's my playground

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [SOLVED] collision and selection

by Sokomine » Post

I've already created some nodes that are intended for your huts. There are two shapes; texture doesn't really matter (just for visualization). They're a bit thicker than they ought to be in the end (again, for visualization). I had no time yet to add code that places these nodes automaticly in the necessry positions.

The advantage of this solution is that these nodes will be invisible inside the wall of your huts, they will block passage for players through walls, and a player who places a node on the inside or outside can do so. It's not a perfect solution as the wall can be perforated this way if the node is digged again or if nodes are placed on both sides that let the player through.

There are also further shapes needed for the roof.

[Edit] It'd be nice if the windows of the huts could be transparent.

Code: Select all

minetest.register_node("mt_buildings:wall", {
        description = "housewall",
        tiles = {"default_wood.png"}, --"default_glass.png", "default_glass_detail.png"},
        is_ground_content = false,
        sounds = default.node_sound_glass_defaults(),
        -- cannot be digged, does not appear in creative inventory
        groups = {not_in_creative_inventory = 1},
        -- if a player tries to place a node here, this one will be replaced by it
        buildable_to = true,
        -- water shall not wash it away
        floodable = false,
        paramtype = "light",
        paramtype2 = "facedir",
        sunlight_propagates = true,
        drawtype = "nodebox",
        -- small enough so that it disappears inside the house wall object
        node_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/32}, --128},
                },
        },
        -- the collision box is slightly larger than the nodebox because the
        -- collision box is what this node exists for
        collision_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/16},
                },
        },
})

-- corner node for the larger-than-one-node-house-tents
minetest.register_node("mt_buildings:wall_edge", {
        description = "housewall",
        tiles = {"default_wood.png"}, --"default_glass.png", "default_glass_detail.png"},
        paramtype = "light",
        paramtype2 = "facedir",
        sunlight_propagates = true,
        is_ground_content = false,
        groups = {not_in_creative_inventory = 1},
        sounds = default.node_sound_glass_defaults(),

        buildable_to = true,
        floodable = false,
        drawtype = "nodebox",
        node_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/32}, --128},
                        {0.5, -0.5, 0.5,  0.5-1/32, 0.5,-0.5}, --128},
                },
        },
        collision_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/16},
                },
        },
})
A list of my mods can be found here.

User avatar
Steamed_Punk
Member
Posts: 156
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: [SOLVED] collision and selection

by Steamed_Punk » Post

Now this is not what I was expecting as a reply. Mainly because this thread is for another project (straight conversion and import) of a whole bunch of new models and objects for the community. The idea is to be able to build indestructible pathways and obstacles (parcour games for example) which can then have a skin overlay to re-look the game. Just playing with ideas, nothing fixed.

Don't get me wrong, I am not knocking your post, in fact it's quite the opposite and I can see how this thread could eventually be associated with the other one ;-)
Sokomine wrote:
Tue Oct 06, 2020 01:57
I've already created some nodes that are intended for your huts. There are two shapes; texture doesn't really matter (just for visualization). They're a bit thicker than they ought to be in the end (again, for visualization). I had no time yet to add code that places these nodes automaticly in the necessry positions.
WOW This is just fantastic, (the fact you are doing this) the exact size and shapes or auto placement isn't important yet, just having this as a starting point (if you haven't time to go further) will both teach me something new and give me a base to work on.
The advantage of this solution is that these nodes will be invisible inside the wall of your huts, they will block passage for players through walls, and a player who places a node on the inside or outside can do so. It's not a perfect solution as the wall can be perforated this way if the node is digged again or if nodes are placed on both sides that let the player through.
Is there no way to make a node indestructible? I have been looking into this but it's seems like people use the properties of obsidian or mese (i think it's called), which from what I can tell only makes the objects super hard to break but not indestructible.
There are also further shapes needed for the roof.
Obviously that's up to you and the time you have and yes I would appreciate any further help you have to offer. If not and based on what you have done I will have to learn. :-D
[Edit] It'd be nice if the windows of the huts could be transparent.
I have been toying with the best way to do this and finally I think I will just remove them as I did with the door. You glass walls will then have a double purpose.

Code: Select all

minetest.register_node("mt_buildings:wall", {
        description = "housewall",
        tiles = {"default_wood.png"}, --"default_glass.png", "default_glass_detail.png"},
        is_ground_content = false,
        sounds = default.node_sound_glass_defaults(),
        -- cannot be digged, does not appear in creative inventory
        groups = {not_in_creative_inventory = 1},
        -- if a player tries to place a node here, this one will be replaced by it
        buildable_to = true,
        -- water shall not wash it away
        floodable = false,
        paramtype = "light",
        paramtype2 = "facedir",
        sunlight_propagates = true,
        drawtype = "nodebox",
        -- small enough so that it disappears inside the house wall object
        node_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/32}, --128},
                },
        },
        -- the collision box is slightly larger than the nodebox because the
        -- collision box is what this node exists for
        collision_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/16},
                },
        },
})

-- corner node for the larger-than-one-node-house-tents
minetest.register_node("mt_buildings:wall_edge", {
        description = "housewall",
        tiles = {"default_wood.png"}, --"default_glass.png", "default_glass_detail.png"},
        paramtype = "light",
        paramtype2 = "facedir",
        sunlight_propagates = true,
        is_ground_content = false,
        groups = {not_in_creative_inventory = 1},
        sounds = default.node_sound_glass_defaults(),

        buildable_to = true,
        floodable = false,
        drawtype = "nodebox",
        node_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/32}, --128},
                        {0.5, -0.5, 0.5,  0.5-1/32, 0.5,-0.5}, --128},
                },
        },
        collision_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/16},
                },
        },
})
I haven't the time right now to try this, I have to go out for the afternoon, but just wanted to reply and thank you before leaving. be back onto it around 21h00 gmt+1

It's just GREAT. THANK YOU :-D
The sky is not the limit - It's my playground

User avatar
Steamed_Punk
Member
Posts: 156
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: [SOLVED] collision and selection

by Steamed_Punk » Post

@Sokomine, I hope you don't mind, just to keep things organized I have followed this up on the other thread.
Sokomine wrote:
Tue Oct 06, 2020 01:57
Spoiler
I've already created some nodes that are intended for your huts. There are two shapes; texture doesn't really matter (just for visualization). They're a bit thicker than they ought to be in the end (again, for visualization). I had no time yet to add code that places these nodes automaticly in the necessry positions.

The advantage of this solution is that these nodes will be invisible inside the wall of your huts, they will block passage for players through walls, and a player who places a node on the inside or outside can do so. It's not a perfect solution as the wall can be perforated this way if the node is digged again or if nodes are placed on both sides that let the player through.

There are also further shapes needed for the roof.

[Edit] It'd be nice if the windows of the huts could be transparent.

Code: Select all

minetest.register_node("mt_buildings:wall", {
        description = "housewall",
        tiles = {"default_wood.png"}, --"default_glass.png", "default_glass_detail.png"},
        is_ground_content = false,
        sounds = default.node_sound_glass_defaults(),
        -- cannot be digged, does not appear in creative inventory
        groups = {not_in_creative_inventory = 1},
        -- if a player tries to place a node here, this one will be replaced by it
        buildable_to = true,
        -- water shall not wash it away
        floodable = false,
        paramtype = "light",
        paramtype2 = "facedir",
        sunlight_propagates = true,
        drawtype = "nodebox",
        -- small enough so that it disappears inside the house wall object
        node_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/32}, --128},
                },
        },
        -- the collision box is slightly larger than the nodebox because the
        -- collision box is what this node exists for
        collision_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/16},
                },
        },
})

-- corner node for the larger-than-one-node-house-tents
minetest.register_node("mt_buildings:wall_edge", {
        description = "housewall",
        tiles = {"default_wood.png"}, --"default_glass.png", "default_glass_detail.png"},
        paramtype = "light",
        paramtype2 = "facedir",
        sunlight_propagates = true,
        is_ground_content = false,
        groups = {not_in_creative_inventory = 1},
        sounds = default.node_sound_glass_defaults(),

        buildable_to = true,
        floodable = false,
        drawtype = "nodebox",
        node_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/32}, --128},
                        {0.5, -0.5, 0.5,  0.5-1/32, 0.5,-0.5}, --128},
                },
        },
        collision_box = {
                type = "fixed",
                fixed = {
                        {0.5, -0.5, 0.5, -0.5, 0.5, 0.5-1/16},
                },
        },
})
HERE: viewtopic.php?f=9&t=25444
The sky is not the limit - It's my playground

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [SOLVED] collision and selection

by Sokomine » Post

Steamed_Punk wrote: Is there no way to make a node indestructible? I have been looking into this but it's seems like people use the properties of obsidian or mese (i think it's called), which from what I can tell only makes the objects super hard to break but not indestructible.
Obsidian and Mese are just hard to dig. Some nodes are relatively indestructable - i.e. chests with something in, or locked iron doors. If no groups are set that allow digging, the node is also indestructable. That apples to the invisible nodes for your mod as well. But they're also buildable_to - which means that players can't dig them - but they can place another node there, thus destroying the node.
A list of my mods can be found here.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests