Page 1 of 1

How to Make Mod Set Player Crafting Grid to be 2 by 2?

PostPosted: Fri Dec 01, 2017 07:39
by PUMPKINIDOLATER
Question: How to Make Mod Set Player Crafting Grid to be 2 by 2?
Reason: Trying to cobble together the many various broken workbench mods into one simple working workbench mod.

I have tried to find/create this for hours. I think I found one, can someone please help with the last major step?

Goals: Player Inventory set to a 2 by 2 crafting space; thus necessitating the workbench. A workbench that brings up the traditional 3 by 3 crafting area when right clicked on.

Help Needed: How do I force the Player Inventory to be just a two by two crafting area?

The mods says:

-- uncomment the next 6 lines to restrict players to a 2x2 inventory craft grid
minetest.register_on_joinplayer(function(player)
player:set_inventory_formspec("size[8,7.5]"..
"list[current_player;main;0,3.5;8,4;]"..
"list[current_player;craft;3,0.5;2,2;]"..
"list[current_player;craftpreview;6,1;1,1;]")
end)

Why is this not working? I'm assuming it's changes to Minetest sense this mod was made. Does anyone know the proper code to do this in Minetest today?

I think I should be able to cobble together a simple working workbench out of the pieces of code in the non-working workbenches if someone can help me with this code here. I kind of want to strip the other two tables out of this mod and just have the basic table. That should be easy to do as well; just find and delete the node creating and recipe creating lines from the lua file.

I also can move the code from other workbenches that tell the node to be able to be burned as fuel and to be able to be set on fire and be broken by hand. I've seen the lua code for this in the other files and I think I can copy and paste it into the right places to make it work.

I've already changed the crafting recipe in the DarkRose mod to group:wood instead of one specific type of wood. That way I can use it on Ethereal biomes without being stranded for looking for one specific type of tree.

The DarkRose workbench mod does already bring up a standard 3 by 3 working crafting area when right clicked on. But, even with the code uncommitted, it still gives me a 3 by 3 crafting grid in my standard inventory; thus defeating the point of having the workbench at all.

I prefer the workbench because I'm migrating from minecraft and I miss it. It gives extra stress to the first few minutes of a new game; and locks crafting to an item and thus a locality in the world. I'm used to crafting my workbench, and then placing it somewhere nice in my castle/house, and then crafting. I feel a massive level of tension and charm is lost when I can just craft everything in the inventory.

Update:

I tried pasting:

local inv = player:get_inventory()
inv:set_width("craft", 2)
inv:set_size("craft", 4)

It gives me this weird L shape that is rotated 90 degrees to the right. Other than that, it does only give me four crafting spaces and they work.

Does anyone know how to cluster these into a 2 by 2 grid? Thank you.

Update: in mintest-game I can modify sfinv lua file from

list[current_player;craft;1.75,0.5;3,3;]

to

list[current_player;craft;1.75,0.5;2,2;]

This works, but just for me, not as a mod. How do I make the mod change the crafting inventory to be 2 by 2 instead of 3 by 3?

Re: Post your modding questions here

PostPosted: Fri Dec 01, 2017 16:55
by sofar
PUMPKINIDOLATER wrote:Question: How to Make Mod Set Player Crafting Grid to be 2 by 2?
Reason: Trying to cobble together the many various broken workbench mods into one simple working workbench mod.


You're probably better off making a new inventory for 2x2 crafts and keeping the 3x3 one intact. You can also peek at MCL2 which should have a 2x2 and a 3x3 version.

Re: Post your modding questions here

PostPosted: Sat Dec 02, 2017 04:11
by PUMPKINIDOLATER
Maybe I ramble too much and don't get directly to the point. My question is:


How do I make -- uncomment the next 6 lines to restrict players to a 2x2 inventory craft grid
minetest.register_on_joinplayer(function(player)
player:set_inventory_formspec("size[8,7.5]"..
"list[current_player;main;0,3.5;8,4;]"..
"list[current_player;craft;3,0.5;2,2;]"..
"list[current_player;craftpreview;6,1;1,1;]")
end)

work in modern stable Minetest?


Your answer is a paste of the functioning six lines of code; or a direct answers to what I need to change exactly to make these six lines functional.

I do not know how to program. Clearly this used to work; and something about how Minetest does its menus in the modern game has broken old lines of code like this.

Re: How to Make Mod Set Player Crafting Grid to be 2 by 2?

PostPosted: Sat Dec 02, 2017 20:42
by orwell
Are you using any inventory enhancement mod?
Such as unified inventory, inventory plus...

Re: How to Make Mod Set Player Crafting Grid to be 2 by 2?

PostPosted: Sat Dec 02, 2017 20:44
by rubenwardy
Depend on sfinv. Then use this code:

Code: Select all
sfinv.override_page("sfinv:crafting", {
   title = "Crafting",
   get = function(self, player, context)
      return sfinv.make_formspec(player, context, [[
            list[current_player;craft;3,0.5;2,2;]
            list[current_player;craftpreview;6,1.5;1,1;]
            image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
            listring[current_player;main]
            listring[current_player;craft]
            image[0,4.75;1,1;gui_hb_bg.png]
            image[1,4.75;1,1;gui_hb_bg.png]
            image[2,4.75;1,1;gui_hb_bg.png]
            image[3,4.75;1,1;gui_hb_bg.png]
            image[4,4.75;1,1;gui_hb_bg.png]
            image[5,4.75;1,1;gui_hb_bg.png]
            image[6,4.75;1,1;gui_hb_bg.png]
            image[7,4.75;1,1;gui_hb_bg.png]
         ]], true)
   end
})


Don't uncomment those 6 lines

Re: How to Make Mod Set Player Crafting Grid to be 2 by 2?

PostPosted: Sun Dec 03, 2017 03:21
by PUMPKINIDOLATER
rubenwardy wrote:Depend on sfinv. Then use this code:

Code: Select all
sfinv.override_page("sfinv:crafting", {
   title = "Crafting",
   get = function(self, player, context)
      return sfinv.make_formspec(player, context, [[
            list[current_player;craft;3,0.5;2,2;]
            list[current_player;craftpreview;6,1.5;1,1;]
            image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
            listring[current_player;main]
            listring[current_player;craft]
            image[0,4.75;1,1;gui_hb_bg.png]
            image[1,4.75;1,1;gui_hb_bg.png]
            image[2,4.75;1,1;gui_hb_bg.png]
            image[3,4.75;1,1;gui_hb_bg.png]
            image[4,4.75;1,1;gui_hb_bg.png]
            image[5,4.75;1,1;gui_hb_bg.png]
            image[6,4.75;1,1;gui_hb_bg.png]
            image[7,4.75;1,1;gui_hb_bg.png]
         ]], true)
   end
})


Don't uncomment those 6 lines


Hello. Thank you for your time. I have tried to use this code, but I keep getting the same error. I tried it within the mod, and then I tried to use it with just this code itself in the lua file to see if it was something in the mod making it not work. It has the same error in and out of the mod.

It says: "init.lua 2 '}' expected to close '{' at line 1 near' title'"

I tried to look the error up online and someone with a similar error in unrelated code got the reply that there might be too many closing }? I tried to delete many } and this created random new errors. Sorry, I don't really know much to anything about code. Could it be that something was opened with a { and not closed later?

Thank you for your time and sorry to ask again about the same thing. I was just so excited to get this working and so sad when it keeps saying error.

Re: How to Make Mod Set Player Crafting Grid to be 2 by 2?

PostPosted: Fri Apr 20, 2018 21:12
by csirolli
Made any progress on that mod?

Re: How to Make Mod Set Player Crafting Grid to be 2 by 2?

PostPosted: Fri Apr 27, 2018 21:27
by csirolli
I found a slightly better way to do it. Instead of where is says in Reuben's example above
Code: Select all
list[current_player;craft;3,0.5;2,2;]

Use these two lines:
Code: Select all
list[current_player;craft;2,1;2,1;0]
list[current_player;craft;2,2;2,1;3]

It isn't perfect, but it works better.