code wont work!

Post Reply
User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

code wont work!

by Stix » Post

when i install the mod: better_bread it doesnt show up in-game, why? here is the code:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
descrition = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread"
recipie = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = function(itemstack, user, pointed_thing),
hp_change = 20
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipie = {"farming:bread", "farming:bread", "farming:bread"}
})
see attahments for download.
Attachments
better_bread.tar.gz
version 0.1
(1.79 KiB) Downloaded 34 times
Hey, what can i say? I'm the bad guy.

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: code wont work!

by Hamlet » Post

Stix wrote:when i install the mod: better_bread it doesnt show up in-game, why? here is the code:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
descrition = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread"
recipie = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = function(itemstack, user, pointed_thing),
hp_change = 20
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipie = {"farming:bread", "farming:bread", "farming:bread"}
})
see attahments for download.
I haven't tested the code, but I think that the issue might be a typo: "recipie" instead of "recipe".
My repositories: Codeberg.org | My ContentDB's page

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

i feel dum as its my code
Hey, what can i say? I'm the bad guy.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

would you like to see the updated code?
ive updated it alot before you pointed that error out.
Hey, what can i say? I'm the bad guy.

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: code wont work!

by TumeniNodes » Post

Stix wrote:i feel dum as its my code
don't feel dumb, it's just the process of learning
A Wonderful World

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: code wont work!

by maikerumine » Post

Stix wrote:i feel dum as its my code
Welcome to coding!

We ALL feel dumb when we code, it is the process of learning as Tumeninodes said. Think of it as falling while learning how to snowboard the first time.

I have been "coding" <--more like copy paste and editing for over a year and STILL feel like poop when I cannot figure out something. My excuse is that I am not a coder! HA! then my poopyness goes away. :)

After a while experimenting with minetest codes you will get the hang of how the basic things work, keep on working at it, take a copy of existing code and edit it, repeat this a few hundred times and it becomes like memory.

Then when trouble shooting errors, always read the error message, see which line the error was on and in what mod, without closing the window, go peek at the code and try to figure where the comma was missing or the spelling was wrong, edit, save, reload, repeat. :)

At least that is how I figure it out, it works for me.

Hope that helps, and keep on coding!
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

User avatar
Peppy
Member
Posts: 34
Joined: Sun Nov 06, 2016 07:34
IRC: Peppy
In-game: Peppy
Location: France

Re: code wont work!

by Peppy » Post

I suggest you give a try to Atom editor with luacheck integration.

To install Atom editor, just download and install the .deb package from the offical website.

To install luacheck and the luacheck module for Atom, execute those four commands in a terminal :

Code: Select all

sudo apt-get install luarocks

sudo luarocks install luacheck

apm install linter

apm install linter-luacheck
No terminal wizardry needed after that ;)

----

To use it, you'll need a .luacheckrc file in your mod directory (notice the dot at the beginning of the filename).

Here is an example :
Spoiler

Code: Select all

unused_args = false
allow_defined_top = true

read_globals = {
	"DIR_DELIM",
	"minetest", "core",
	"dump",
	"vector", "nodeupdate",
	"VoxelManip", "VoxelArea",
	"PseudoRandom", "ItemStack",
	"intllib",
	"default",
}
This (and Rubenwardy's moding book ) helped me a lot, I hope it will help you too !

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: code wont work!

by Hamlet » Post

Stix wrote:would you like to see the updated code?
ive updated it alot before you pointed that error out.
Sure, upload the zip or even better put it on a git repo.
My repositories: Codeberg.org | My ContentDB's page

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: code wont work!

by sofar » Post

Did you install and enable the mod? When you load the game, are there errors? Does "/mods" list your mod?

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

sofar wrote:Did you install and enable the mod? When you load the game, are there errors? Does "/mods" list your mod?
yes its installed and there are no errors when i load the game, it just doesnt show up.
Hey, what can i say? I'm the bad guy.

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: code wont work!

by maikerumine » Post

Stix wrote:
sofar wrote:Did you install and enable the mod? When you load the game, are there errors? Does "/mods" list your mod?
yes its installed and there are no errors when i load the game, it just doesnt show up.
Does the depends have a missing MOD?
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

maikerumine wrote:
Stix wrote:
sofar wrote:Did you install and enable the mod? When you load the game, are there errors? Does "/mods" list your mod?
yes its installed and there are no errors when i load the game, it just doesnt show up.
Does the depends have a missing MOD?
nope, all it depends on is default and farming and ive already put that in the depends.txt
Hey, what can i say? I'm the bad guy.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: code wont work!

by sofar » Post

Stix wrote:nope, all it depends on is default and farming and ive already put that in the depends.txt
... does the mod appear by name in "/mods" ?

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: code wont work!

by Napiophelios » Post

you have several typos and misspelled words: recipe and description
if you don't spell 'description' correctly it won't show in the creative inventory.
not sure if the proper spelling of 'recipe' matters or not.

Minetest should tell you in the debug file what needs to be fixed;
at least if you are missing punctuations.

If it just abruptly crashes without starting,
it's usually problems with crafting recipes

also your depends text should list the dependencies one by one/ line by line
I don't think you should have any puncuations except for a '?' in the depends.txt either

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: code wont work!

by Napiophelios » Post

sofar wrote:... does the mod appear by name in "/mods" ?
If it does make sure you use the configure button
to enable it for the world you are using


EDIT: oops sorry about the double post :(

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

Napiophelios wrote:you have several typos and misspelled words: recipe and description
if you don't spell 'description' correctly it won't show in the creative inventory.
not sure if the proper spelling of 'recipe' matters or not.

Minetest should tell you in the debug file what needs to be fixed;
at least if you are missing punctuations.

If it just abruptly crashes without starting,
it's usually problems with crafting recipes

also your depends text should list the dependencies one by one/ line by line
I don't think you should have any puncuations except for a '?' in the depends.txt either
yes that code it old i havent released my newer version withouy typos. but the new code still wont work!
Hey, what can i say? I'm the bad guy.

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: code wont work!

by maikerumine » Post

Stix wrote:
Napiophelios wrote:you have several typos and misspelled words: recipe and description
if you don't spell 'description' correctly it won't show in the creative inventory.
not sure if the proper spelling of 'recipe' matters or not.
Please post it.
Minetest should tell you in the debug file what needs to be fixed;
at least if you are missing punctuations.

If it just abruptly crashes without starting,
it's usually problems with crafting recipes

also your depends text should list the dependencies one by one/ line by line
I don't think you should have any puncuations except for a '?' in the depends.txt either
yes that code it old i havent released my newer version withouy typos. but the new code still wont work!
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: code wont work!

by Napiophelios » Post

maikerumine wrote:
Stix wrote: yes that code it old i havent released my newer version withouy typos. but the new code still wont work!
Please post it.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

here we go:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
groups = {doublebaked_bread = 99},
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread"
recipe = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = function(itemstack, user, pointed_thing),
hp_change = 20
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
})
Hey, what can i say? I'm the bad guy.

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: code wont work!

by maikerumine » Post

Stix wrote:here we go:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
groups = {doublebaked_bread = 99},
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread"
recipe = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = function(itemstack, user, pointed_thing),
hp_change = 20
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
})
Try this:


better_bread = {}

put that on the top line.

ALSO

Make sure the .lua is named:
lua


AND


your depends has:

default
farming

and the folder name that it sits in is named:
better_bread
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: code wont work!

by sofar » Post

maikerumine wrote:Try this:

better_bread = {}

put that on the top line.
why? he's not using it anywhere, so you're just polluting the global namespace.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

maikerumine wrote:
Stix wrote:here we go:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
groups = {doublebaked_bread = 99},
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread"
recipe = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = function(itemstack, user, pointed_thing),
hp_change = 20
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
})
Try this:


better_bread = {}

put that on the top line.

ALSO

Make sure the .lua is named:
lua


AND


your depends has:

default
farming

and the folder name that it sits in is named:
better_bread
done all that already except this:better_bread = {}
Hey, what can i say? I'm the bad guy.

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: code wont work!

by maikerumine » Post

Use this code:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10),
groups = {doublebaked_bread = 99},
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread",
recipe = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = minetest.item_eat(20),
minetest.item_eat(20)
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
})
You were missing some commas and the line on_use for your bread block confused me.
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: code wont work!

by Stix » Post

maikerumine wrote:Use this code:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10),
groups = {doublebaked_bread = 99},
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread",
recipe = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = minetest.item_eat(20),
minetest.item_eat(20)
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
})
You were missing some commas and the line on_use for your bread block confused me.
THANK YOU!!!! it now works!!!!
Hey, what can i say? I'm the bad guy.

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 14 guests