KCoombes wrote:I wasn't aware there was a soft limit for lines of code, but I have one file that's 3179 lines that works just fine. If it really bothers you, I'd say break it into a second .lua file (or perhaps one file for stone, 1 for glass, 1 for clay, etc.... just to keep it organized).
Byakuren wrote:If there is a lot of boilerplate in your code you may be able to refactor it so that it does not take that much code. If you are creating the same nodes just with different textures, you can put all the textures in a list, and then use a loop to register a new set of arched/angled things with each texture.
Sokomine wrote:Over 2000 lines of code for angled walls seems a bit much. Just out of curiosity I counted the lines in my mg_villages mod: 5985 lines alltogether, with mapgen.lua (longest one) consisting of 1241 lines.
Try to avoid repetitions in your code. From first glance: Take the collision_box definitions and pack them up into one variable (provided you need them that one at all!). Grab values for the new nodes (group, texture, description, ...) from the original block's definition. See what all these definitions have in common, check where they vary, and build a function that gets supplied with all that's different from node to node as an extra parameter.
Nathan.S wrote:As Sokomine said, try using a table and looping through that to set up the nodes if they are mostly all the same. I have a video explaining the process on my website. http://nathansalapat.com/minetest/using-tables-and-loops-minetest
TumeniNodes wrote:Byakuren wrote:If there is a lot of boilerplate in your code you may be able to refactor it so that it does not take that much code. If you are creating the same nodes just with different textures, you can put all the textures in a list, and then use a loop to register a new set of arched/angled things with each texture.
Thank you...
the only problem I would have had with this is, these are customized textures and would not be able to use the textures in the way you describe.
If/when you see the textures you will see what I mean. It is the same for angledglass nodes. I only wish it were that simple to do that way... :P would have been very nice
pithy wrote:With the new angledglass model I gave you, you would not need customized textures.
TumeniNodes wrote:pithy wrote:With the new angledglass model I gave you, you would not need customized textures.
I was not aware of that... how so?
If a texture (say, cobble) is set to the angled glass model... won't the whole node be covered with cobble?
The angled glass nodes use a filler on each side of the glass to blend with whichever texture the user wishes. If there actually is a way around that with the new model you gave me, please explain how I can implement this feature... (in layman's terms please :D )
If it truly is possible to use the same code for the other nodes to use all the textures..., for the newest glass node, I would be literally thrilled to be able to cut all the extra registered nodes : )
Then again... I will also be really bummed because all that work I did was for not... : /
tiles = {{name='default_wood.png'},{name='default_clay.png'}},pithy wrote:You would still need all of those nodes, but not your custom textures, and it would require change in code.
Nathan.S wrote:You would probably end up doing something like this,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
tiles = {{name='default_wood.png'},{name='default_clay.png'}},
replacing default_wood.png and default_clay.png with your glass and cobble texture.
Of course I didn't make the mesh models, so I couldn't say exactly how they were unwrapped but if pithy created the meshes with two texture slots on them, you'd just switch around whichever textures you needed and everything would just work TM.
Users browsing this forum: No registered users and 2 guests