Page 1 of 1
Flint and steel

Posted:
Mon Apr 16, 2012 07:23
by jordan4ibanez
Very simple. You use the flint and steel to light fires, giving some real purpose for fire. I'm sure I will improve on this eventually. Also it would be great if someone could tell me how to add health to a craftitem.

Download:
http://ubuntuone.com/50skCvr06V62lclyd4ln6p

Posted:
Mon Apr 16, 2012 08:06
by neko259
I think I found the new use for matches in my fire mod :3

Posted:
Wed Apr 18, 2012 08:25
by Ragnarok
Amazing! I've just burned down almost whole jungle. What do you think about crafting recipe like:
nothing, nothing, nothing
sandstone, sandstone, steel_ingot
sandstone, sandstone, steel_ingot

Posted:
Thu Apr 19, 2012 02:33
by MikoMiko
Is there a way to override the definition of the gravel node in {Minetest_Directory}/games/minetest-game/mods/default/init.lua? I'd to like make them give them flint instead of a gravel block sometimes. I added the following to {Minetest_Directory}/mods/minetest/flint_and_steel/init.lua, but much to my disappoint it didn't redefine default:gravel. Is there a way to do this without editing /default/init.lua?
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_node("flint_and_steel:gravel", {
description = "Gravel",
tile_images = {"default_gravel.png"},
is_ground_content = true,
groups = {crumbly=2, falling_node=1},
drop = {
max_items = 1,
items = {
{
items = {'flint_and_steel:flint'},
rarity = 5,
},
{
items = {'default:gravel'},
}
}
},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_gravel_footstep", gain=0.45},
}),
})
minetest.register_craft({
output = 'flint_and_steel:flint_and_steel 1',
recipe = {
{'default:steel_ingot', '', ''},
{'', 'flint_and_steel:flint', ''},
}
})

Posted:
Thu Apr 19, 2012 02:39
by lkjoel
Try changing flint_and_steel:gravel to default:gravel, and see what you come up with (hoping it's not an error)

Posted:
Thu Apr 19, 2012 02:42
by MikoMiko
Thanks for the suggestion, but I had tried that before posting, it raises the following error. I guess using default:gravel in mods isn't allowed.
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
21:41:02: ERROR[main]: ========== ERROR FROM LUA ===========
21:41:02: ERROR[main]: Failed to load and run script from
21:41:02: ERROR[main]: /home/UserName/Downloads/minetest-git/bin/../mods/minetest/flint_and_steel/init.lua:
21:41:02: ERROR[main]: ...nloads/minetest-git/bin/../builtin/misc_register.lua:62: Name default:gravel does not follow naming conventions: "modname:" or ":" prefix required
21:41:02: ERROR[main]: stack traceback:
21:41:02: ERROR[main]: [C]: in function 'error'
21:41:02: ERROR[main]: ...nloads/minetest-git/bin/../builtin/misc_register.lua:62: in function 'check_modname_prefix'
21:41:02: ERROR[main]: ...nloads/minetest-git/bin/../builtin/misc_register.lua:98: in function 'register_item'
21:41:02: ERROR[main]: ...nloads/minetest-git/bin/../builtin/misc_register.lua:154: in function 'register_node'
21:41:02: ERROR[main]: ...st-git/bin/../mods/minetest/flint_and_steel/init.lua:27: in main chunk
21:41:02: ERROR[main]: =======END OF ERROR FROM LUA ========

Posted:
Thu Apr 19, 2012 02:58
by lkjoel
yep, I knew it would output an error :S. I'm clueless now

Posted:
Thu Apr 19, 2012 03:00
by jordan4ibanez

Posted:
Thu Apr 19, 2012 03:04
by MikoMiko
Yeah, but I looked and you had to edit /default/init.lua. I was hoping there would be a way to avoid doing that and override in the mod but that doesn't seem to possible.

Posted:
Fri Aug 17, 2012 20:57
by minecraft64
when i used the flint mod i had to copy the part of the code that makes it breakable to the mod so it would work

Posted:
Sat Aug 18, 2012 09:40
by PilzAdam
MikoMiko wrote:Is there a way to override the definition of the gravel node in {Minetest_Directory}/games/minetest-game/mods/default/init.lua? I'd to like make them give them flint instead of a gravel block sometimes. I added the following to {Minetest_Directory}/mods/minetest/flint_and_steel/init.lua, but much to my disappoint it didn't redefine default:gravel. Is there a way to do this without editing /default/init.lua?
This is a bit late but you can redefine nodes by setting a : in front of their name:
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_node(":default:gravel", {...})

Posted:
Sat Aug 18, 2012 09:42
by PilzAdam
jordan4ibanez wrote:Also it would be great if someone could tell me how to add health to a craftitem.
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
itemstack:add_wear(65535/[number of uses])

Posted:
Sat Aug 18, 2012 21:52
by leo_rockway
PilzAdam wrote:MikoMiko wrote:Is there a way to override the definition of the gravel node in {Minetest_Directory}/games/minetest-game/mods/default/init.lua? I'd to like make them give them flint instead of a gravel block sometimes. I added the following to {Minetest_Directory}/mods/minetest/flint_and_steel/init.lua, but much to my disappoint it didn't redefine default:gravel. Is there a way to do this without editing /default/init.lua?
This is a bit late but you can redefine nodes by setting a : in front of their name:
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_node(":default:gravel", {...})
Even overriding default:gravel I'm not getting drops of flint... either something is not working or the flint drops are very very very very rare.

Posted:
Mon Oct 01, 2012 11:50
by cornernote
awesome mod!
i added a drop from gravel (tested and it works), and also a shapeless craft. grab the code here:
https://github.com/cornernote/minetest-flint_and_steelplease merge my changes back into this code

Posted:
Mon Oct 01, 2012 14:26
by Mito551
i'm using your code to add flint and steel to dwarves. but i'll go a bit other, my way...

Posted:
Mon Oct 01, 2012 16:32
by Mito551


it's dangerous to go alone! take this!

Posted:
Mon Oct 01, 2012 18:23
by jordan4ibanez
This is the code for flint and strike in fancy game mode
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
--The igniter tool
minetest.register_tool("flint_and_strike:flint_and_strike", {
description = "Flint and Strike",
inventory_image = "flint_and_steel.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type=="node" then
if minetest.env:get_node(pointed_thing.under).name == "torch_plus:torch_unlit" then
minetest.sound_play("flint", {pos=pointed_thing.under, loop=false})
node = minetest.env:get_node(pointed_thing.under)
minetest.env:add_node(pointed_thing.under, {name="torch_plus:torch_lit", param2 = node.param2})
itemstack:add_wear(1000)
return itemstack
else
if minetest.env:get_node(pointed_thing.above).name == "air" then
minetest.sound_play("flint", {pos=pointed_thing.under, loop=false})
itemstack:add_wear(1000)
minetest.env:add_node(pointed_thing.above, {name="fire:basic_flame"})
return itemstack
end
end
end
end,
})
minetest.register_craft({
type = "shapeless",
output = 'flint_and_strike:flint_and_strike 1',
recipe = {
'flint_and_strike:stone_piece',
'flint_and_strike:flint',
}
})
minetest.register_craftitem("flint_and_strike:flint", {
description = "Flint",
inventory_image = "flint.png",
})
minetest.register_craftitem("flint_and_strike:stone_piece", {
description = "Stone Piece",
inventory_image = "stone_piece.png",
})
minetest.register_craft({
output = 'flint_and_strike:flint',
recipe = {
{'default:gravel'},
}
})
minetest.register_craft({
output = 'flint_and_strike:flint',
recipe = {
{'default:sandstone'},
}
})
minetest.register_craft({
output = 'flint_and_strike:flint',
recipe = {
{'default:desert_stone'},
}
})
minetest.register_craft({
output = 'flint_and_strike:stone_piece',
recipe = {
{'default:cobble'},
}
})

Posted:
Mon Oct 01, 2012 18:30
by Mito551
isn't it a bit more compex than yours? does it worth it?

Posted:
Mon Oct 01, 2012 18:38
by jordan4ibanez
Mito551 wrote:isn't it a bit more compex than yours? does it worth it?
i don't understand the first question, and yes, try out fancy game mode to see it in action