How to register nodes in-game.

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

How to register nodes in-game.

by kpo » Thu May 09, 2013 22:40

I hope some clever member can answer me this riddle:

I am attempting to make an in-game node designer featuring a 3x 16x16 grid for the top and side views.
The idea is that it must be possible to design some shabe in-game, put a material on it and be ready for prodigtion of the new block.
Of course it would be saved in the particular world and be editable but so far I am stuck at simply registering a new node dynamically with textures and all.

This is my test code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local node_registered = false

minetest.register_node("kpomod:register_node", {
    description = "Register a new node type when punched",
    tiles = {"kpomod_white_brick.png"},
    inventory_image = minetest.inventorycube("kpomod_white_brick.png"),
    is_ground_content = true,
    groups = {cracky=3},
    sounds = default.node_sound_stone_defaults(),

    on_punch = function(pos, node, puncher)
              if node_registered == false then
             print("Registering new node: kpomod:new_node")
              new_node()
             print("Registering new node: kpomod:new_node done")
             node_registered = true
              end
           end
})


new_node = function()
          minetest.register_node(
         ":kpomod:new_node",
         { description = "Register a new node type when punched",
           drawtype = "nodebox",
           tiles = {"kpomod_white_brick.png"},
           inventory_image = minetest.inventorycube("kpomod_white_brick.png"),
           is_ground_content = true,
           groups = {cracky=3},
           node_box = {
              type = "fixed",
              fixed = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
           },
           on_punch = function(pos, node, puncher)
                 print("New node punched")
                  end
        })
       end


I works nicely in the sende that I can give myself the register_node block, place it and punch it to get the "new_node" registered with minetest.
However it is pictures as an "unkown block" and does not seem to care about the node box, textures or anything else for that matter except the name.

My question is this: What do I do to make minetest process the new node - like any nodes are processed on world startup - to get textures, nodebox etc. registered?

I could be fun to "liberate" minetest from having to only provide shapes which are predefined and allow (priviledged) users to create new shapes in-game.

I hope someone knows the answer to this.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu May 09, 2013 23:31

Not possible.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri May 10, 2013 10:58

He means that would it be possible with a modification?

Nodes are stored in def tables, and sent to the client on connection.
Is it possible to edit the def tables after they have been created?
If it is, the server can send a packet to the client to add a node.

This would be useful for players to make ingame mod makers.
Last edited by rubenwardy on Fri May 10, 2013 10:58, edited 1 time in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri May 10, 2013 11:02

About the in-game nodebox designer, it would be nice to see EXACTLY how it would look ingame, but there would be problems.

For example, how would you edit it? On my nodebox editors there are drag and drop resizers. This would probably be impossible with HUD. (no rays to co-ordinates)

Command Line control would be stupid and difficult for the more artist people.

Over all it is more simple to use a third party program, like mine.
 

User avatar
Zeg9
Member
 
Posts: 608
Joined: Fri Sep 21, 2012 11:02

by Zeg9 » Fri May 10, 2013 11:34

rubenwardy wrote:About the in-game nodebox designer, it would be nice to see EXACTLY how it would look ingame, but there would be problems.

For example, how would you edit it? On my nodebox editors there are drag and drop resizers. This would probably be impossible with HUD. (no rays to co-ordinates)

Command Line control would be stupid and difficult for the more artist people.

Over all it is more simple to use a third party program, like mine.

You could place nodes to design it, and "scale them down" to a nodebox.
I made a few (a lot of?) mods for minetest: here is a list.
See also the MT-Faithful texture pack (work in progress).
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri May 10, 2013 13:34

Zeg9 wrote:
rubenwardy wrote:About the in-game nodebox designer, it would be nice to see EXACTLY how it would look ingame, but there would be problems.

For example, how would you edit it? On my nodebox editors there are drag and drop resizers. This would probably be impossible with HUD. (no rays to co-ordinates)

Command Line control would be stupid and difficult for the more artist people.

Over all it is more simple to use a third party program, like mine.

You could place nodes to design it, and "scale them down" to a nodebox.


That is true, but it is rather complicated.
 

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

by kpo » Sat May 11, 2013 18:27

My idea was raher simple actually:
Formspec or something akin to the painting mod depending if I can make the formspec work:

16x16 top view | 16x16 side view
16x16 side view| box for material

When selecting one of the grid positions I would have a coordinate in 3D space.
Some editing help could be done but basically all coordinates must be specified using a mark in each of the three views.

Illustrated using 2x2 grid:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Top   Side1   
x-   |   xx
xx   |   --

Side2
xx
--

This would create an angle shape in the upper part of the box. This way of viewing allows of course only for a subset of the shapes which can be designed but I think most of the basic shapes could be done like that. More advanced editing would come later allowing for placing individual "pixels" in 3D space. This would involve a sliced view or something. However I have a feeling that the stress on the PC drawing many of such shapes would be considerable just looking at the game performance when using lots of the "noncubic" (or technic indev) shaped blocks.
Building an online preview of the shape would use the very same mechanism as the finished block would need to enter the clients.
Programming node box optimizations etc. is just a matter of programming that can be handled. The blocker is if the game engine cannot handle sending block updates to the clients.
I'd like to understand more of how the engine works and sends updates to the client but I find it pretty hard to figure out the flow without some illustrations.

However. I think a middle ground can be achieved even without the server/client being updated. It would of course require a server restart after design which would be kind of lame on "production" servers. But maybe there the idea posted with making a large scale copy, and then shrinking it would actually work. If anyone is up for it it could be a fun project to team up on.

PS: I like the offline nodebox editor it is not that. I just find it more fun to stay in the game and have designwork being part of the game experience.
For mods providing a fixed set of nodes your program is most likely the best way to go.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 6 guests

cron