A crude patch to craft string

User avatar
LazerRay
Member
 
Posts: 146
Joined: Sun Jul 27, 2014 01:32
GitHub: LazerRay

A crude patch to craft string

by LazerRay » Tue Aug 19, 2014 20:55

While playing Minetest I came across several items that needed string to craft them, but there is a glitch in the farming section making string listed but unable to be obtained normaly.

So, I did a crude patch to the init.lua file in the farming folder to allow for crafting of string and I also included a way to get the cotton back from the string.

The bottom two sections are my current fix to the bug, if anyone can come up with a better way to fix it, go right ahead.

(Path to the glitched init.lua file: <where ever you put Minetest>\minetest-0.4.10\games\minetest_game\mods\farming)

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
-- Global farming namespace
farming = {}
farming.path = minetest.get_modpath("farming")

-- Load files
dofile(farming.path .. "/api.lua")
dofile(farming.path .. "/nodes.lua")
dofile(farming.path .. "/hoes.lua")

-- WHEAT
farming.register_plant("farming:wheat", {
   description = "Wheat seed",
   inventory_image = "farming_wheat_seed.png",
   steps = 8,
   minlight = 13,
   maxlight = LIGHT_MAX,
   fertility = {"grassland"}
})
minetest.register_craftitem("farming:flour", {
   description = "Flour",
   inventory_image = "farming_flour.png",
})

minetest.register_craftitem("farming:bread", {
   description = "Bread",
   inventory_image = "farming_bread.png",
   on_use = minetest.item_eat(4),
})

minetest.register_craft({
   type = "shapeless",
   output = "farming:flour",
   recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"}
})

minetest.register_craft({
   type = "cooking",
   cooktime = 15,
   output = "farming:bread",
   recipe = "farming:flour"
})

-- Cotton
farming.register_plant("farming:cotton", {
   description = "Cotton seed",
   inventory_image = "farming_cotton_seed.png",
   steps = 8,
   minlight = 13,
   maxlight = LIGHT_MAX,
   fertility = {"grassland", "desert"}
})

minetest.register_craftitem("farming:string", {
   description = "String",
   inventory_image = "farming_cotton.png",
})

minetest.register_craft({
   output = "wool:white",
   recipe = {
      {"farming:cotton", "farming:cotton"},
      {"farming:cotton", "farming:cotton"},
   }
})

--Patch for missing item
minetest.register_craft({
   type = "shapeless",
   output = "farming:string",
   recipe = {"farming:cotton"}
})

--Reversing the patch
minetest.register_craft({
   type = "shapeless",
   output = "farming:cotton",
   recipe = {"farming:string"}
})
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

Re: A crude patch to craft string

by jojoa1997 » Wed Aug 20, 2014 10:00

You could make a mod. Also if you want it to be added to the game make a pull request to github.
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
LazerRay
Member
 
Posts: 146
Joined: Sun Jul 27, 2014 01:32
GitHub: LazerRay

Re: A crude patch to craft string

by LazerRay » Wed Aug 20, 2014 14:09

This code is already in Minetest with the exception of the parts I added, I currently don't know how to do pull requests on Github and right now that is a temp fix for the bug.

I'm not that much of a coder, I just know enough to make crude patches or simple features.

And like I said in the begining, if anyone can come up with a better fix, go right ahead, that is the fun part about opensource programing.
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 14 guests

cron