Can someone tell me how to make my mod work?

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

Can someone tell me how to make my mod work?

by Chinchow » Thu Oct 11, 2012 19:14

Ok so some of you may have noticed I got some code from Pilzadams farming mod so how do I get this to work? here is the 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
minetest.register_tool("hatchet:hatchet_wood", {
    description = "Wood Hatchet",
    inventory_image = "hatchet_hatchet_wood.png",
    on_use = function(itemstack, user, pointed_thing)
        if create_tree(pointed_thing.under,  user:get:inventory
(tree), 1) then
            itemstack:add_wear(35535/50)
            return itemstack
        end
    end
})
minetest.register_craft({
    output = "hatchet:hatchet_wood",
    recipe = {
        {"default:wood", "default:wood"},
        {"", "default:stick", "default:wood"}
    }
})
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Thu Oct 11, 2012 19:33

You mean how to make and install the mod? Create a folder called "hatchet" in mods/minetest and paste the code into a file named "init.lua" in that folder.
Last edited by Menche on Thu Oct 11, 2012 19:34, edited 1 time in total.
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Thu Oct 11, 2012 19:46

No what I mean is i made it but when I try and use it and start the game it says there is an error did i write my parts wrong?
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Thu Oct 11, 2012 19:58

Could you post the last dozen lines from your debug.txt? The debug.txt usually tells what line of what file the error was on.
Last edited by Menche on Thu Oct 11, 2012 19:59, edited 1 time in total.
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Thu Oct 11, 2012 20:09

of course i have no idea what the actual meaning of this post is, here, this will add damage to your hatchet and remove the node and add an item where the tree block used to be
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
minetest.register_tool("hatchet:hatchet_wood", {
    description = "Wood Hatchet",
    inventory_image = "hatchet_hatchet_wood.png",
    on_use = function(itemstack, user, pointed_thing)
        local below = minetest.env:get_node(pointed_thing.under).name
        --THIS WILL ADD DAMAGE TO YOUR HATCHET WHEN YOU USE IT WHILE POINTING TO DIRT
        if below == "default:tree" then
            minetest.env:remove_node(pointed_thing.under, {name="default:air"})
            itemstack:add_wear(50)
            minetest.env:add_item(pointed_thing.under, "default:wood")
            return itemstack
        end
    end
})

minetest.register_craft({
    output = "hatchet:hatchet_wood",
    recipe = {
        {"default:wood", "default:wood"},
        {"", "default:stick", "default:wood"}
    }
})
Last edited by jordan4ibanez on Thu Oct 11, 2012 20:09, edited 1 time in total.
If you can think it, you can make it.
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Thu Oct 11, 2012 20:18

16:18:20: INFO[main]: Waiting for other menus
16:18:20: INFO[main]: Waited for other menus
16:18:20: VERBOSE[main]: error_message = ModError: Failed to load and run C:\Users\Cameron\Downloads\minetest-0.4.3-4a11323-meta_set_nodedef-win32\minetest-0.4.3-4a11323-meta_set_nodedef-win32\bin\..\mods\minetest\hatchet\init.lua
16:18:20: VERBOSE[main]: Check debug.txt for details.
16:18:20: INFO[main]: Created main menu
16:18:20: INFO[main]: locale has been set to:English_United States.1252
16:18:20: INFO[main]: locale has been set to:C
16:18:22: INFO[main]: locale has been set to:English_United States.1252
16:18:22: INFO[main]: locale has been set to:C
16:18:23: INFO[main]: Dropping main menu
16:18:23: INFO[main]: Updating configuration file: "C:\Users\Cameron\Downloads\minetest-0.4.3-4a11323-meta_set_nodedef-win32\minetest-0.4.3-4a11323-meta_set_nodedef-win32\bin\..\minetest.conf"
16:18:23: INFO[main]: Skipping writing of C:\Users\Cameron\Downloads\minetest-0.4.3-4a11323-meta_set_nodedef-win32\minetest-0.4.3-4a11323-meta_set_nodedef-win32\bin\..\minetest.conf because content wouldn't be modified
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Thu Oct 11, 2012 20:36

Replace "user:get:inventory(tree)" on line 5 with "user:get_inventory(tree)", and double check the crafting recipe. I think each line in the recipe definition has to have the same number of items; you have 2 on the first line and 3 on the second.
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Thu Oct 11, 2012 20:39

To get the right print of the debug.txt you must do the following:

Exit minetest completely, go to your home folder/directory, delete the debug.txt file, start minetest up again. Try to create/start a game, leave minetest again, go to your home folder, doubleclick on debug.txt to open it with your default text editor, search for ERROR (most of the time the bottom part), copy all those error lines and paste them here.

The text you posted doestn't look like the needed debug.txt

If you would like to stick to the code you made you must make 3 changes:

Chinchow wrote:Ok so some of you may have noticed I got some code from Pilzadams farming mod so how do I get this to work? here is the code


minetest.register_tool("hatchet:hatchet_wood", {
description = "Wood Hatchet",
inventory_image = "hatchet_hatchet_wood.png",
on_use = function(itemstack, user, pointed_thing)

2 errors in here:
if create_tree(pointed_thing.under, user:get: --> must be _ inventory You need to attach (tree) after inventory (enter is too much)
(tree), 1) then

So it becomes like this --> if create_tree(pointed_thing.under, user:get_inventory(tree), 1) then
itemstack:add_wear(35535/50)
return itemstack
end
end
})
minetest.register_craft({
output = "hatchet:hatchet_wood",
recipe = {
{"default:wood", "default:wood"}, --> the rows must have the same amount of items, so change this in: {"", "default:wood", "default:wood"},
{"", "default:stick", "default:wood"}
}
})


Edit: Deleted the -code- to try to get colors
Last edited by Topywo on Thu Oct 11, 2012 20:45, edited 1 time in total.
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Thu Oct 11, 2012 21:21

Okay so I get a dummy version in the game but now I get a new error when I try to hit something



"17:20:38: VERBOSE[main]: error_message = ServerError: LuaError: error: ..._nodedef-win32\bin\..\mods\minetest\hatchet\init.lua:1: attempt to call global 'create_tree' (a nil value)"

can anyone fix this?
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Thu Oct 11, 2012 21:49

My LUA isn't that sophisticated, so sorry, but I really would like to know the answer too, so thanks for asking.
 

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

by PilzAdam » Fri Oct 12, 2012 13:49

Chinchow wrote:Okay so I get a dummy version in the game but now I get a new error when I try to hit something



"17:20:38: VERBOSE[main]: error_message = ServerError: LuaError: error: ..._nodedef-win32\bin\..\mods\minetest\hatchet\init.lua:1: attempt to call global 'create_tree' (a nil value)"

can anyone fix this?

There is no function create_tree() in the minetest API.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Fri Oct 12, 2012 15:15

Thanks for the answer PilzAdam!
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Fri Oct 12, 2012 20:32

Oh well woops
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 13 guests

cron