[Mod] Torches [3.0.1] [torches]

Iqualfragile
Member
Posts: 160
Joined: Tue Sep 18, 2012 22:11

by Iqualfragile » Post

You made a mistake when redefining the torch, better use this diff:

Code: Select all

diff --git a/init.lua b/init.lua
index ea88ee8..96e0038 100644
--- a/init.lua
+++ b/init.lua
@@ -77,13 +77,8 @@ local function is_wall(wallparam)
 end

 --node_boxes
-minetest.register_craftitem(":default:torch", {
-       description = "Torch",
-       inventory_image = "torches_torch.png",
-       wield_image = "torches_torch.png",
-       wield_scale = {x=1,y=1,z=1+1/16},
-       liquids_pointable = false,
-       on_place = function(itemstack, placer, pointed_thing)
+minetest.override_item("default:torch",{
+       on_place = function(itemstack, placer, pointed_thing)
                if pointed_thing.type ~= "node" or string.find(minetest.env:get_node(pointed_thing.above).name, "torch") then
                        return itemstack
                end
@@ -92,20 +87,18 @@ minetest.register_craftitem(":default:torch", {
                local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z})
                local u_n = minetest.get_node(under)
                if u_n and not minetest.registered_nodes[u_n.name].walkable then above = under end
-               local u_n = minetest.get_node(above)
+                       local u_n = minetest.get_node(above)
                if u_n and minetest.registered_nodes[u_n.name].walkable then return itemstack end
                if wdir == 1 then
-                       minetest.env:add_node(above, {name = "torches:floor"})
-               else
+                       minetest.env:add_node(above, {name = "torches:floor"})
+               else   
                        minetest.env:add_node(above, {name = "torches:wand", param2 = is_wall(wdir)})
                end
                if not wdir == 0 or not minetest.setting_getbool("creative_mode") then
                        itemstack:take_item()
                end
                return itemstack
-
        end
-
 })

 minetest.register_node("torches:floor", {
Gr8 b8, m8. I rel8, str8 appreci8, and congratul8. I r8 this b8 an 8/8. Plz no h8, I'm str8 ir8. Cr8 more, can't w8. We should convers8, I won't ber8, my number is 8888888, ask for N8. No calls l8 or out of st8. If on a d8, ask K8 to loc8. Even with a full pl8, I always have time to communic8 so don't hesit8.

gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

Hmm... I was about to say it's working a lot better, although there is still the problem of torches sometimes falling for no apparent reason at times.

Image

I'm a little nuts with the torches here, but I think limiting the add_particle within 13 is a good optimization. I think this many torches would have made me lag quite a bit in the old vesion.

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

by BlockMen » Post

Iqualfragile wrote:You made a mistake when redefining the torch, better use this diff:
Spoiler

Code: Select all

diff --git a/init.lua b/init.lua
index ea88ee8..96e0038 100644
--- a/init.lua
+++ b/init.lua
@@ -77,13 +77,8 @@ local function is_wall(wallparam)
 end

 --node_boxes
-minetest.register_craftitem(":default:torch", {
-       description = "Torch",
-       inventory_image = "torches_torch.png",
-       wield_image = "torches_torch.png",
-       wield_scale = {x=1,y=1,z=1+1/16},
-       liquids_pointable = false,
-       on_place = function(itemstack, placer, pointed_thing)
+minetest.override_item("default:torch",{
+       on_place = function(itemstack, placer, pointed_thing)
                if pointed_thing.type ~= "node" or string.find(minetest.env:get_node(pointed_thing.above).name, "torch") then
                        return itemstack
                end
@@ -92,20 +87,18 @@ minetest.register_craftitem(":default:torch", {
                local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z})
                local u_n = minetest.get_node(under)
                if u_n and not minetest.registered_nodes[u_n.name].walkable then above = under end
-               local u_n = minetest.get_node(above)
+                       local u_n = minetest.get_node(above)
                if u_n and minetest.registered_nodes[u_n.name].walkable then return itemstack end
                if wdir == 1 then
-                       minetest.env:add_node(above, {name = "torches:floor"})
-               else
+                       minetest.env:add_node(above, {name = "torches:floor"})
+               else   
                        minetest.env:add_node(above, {name = "torches:wand", param2 = is_wall(wdir)})
                end
                if not wdir == 0 or not minetest.setting_getbool("creative_mode") then
                        itemstack:take_item()
                end
                return itemstack
-
        end
-
 })

 minetest.register_node("torches:floor", {
First: Its no mistake, it the "old" way of redefining.
Second: I will stay at that to allow people with older Minetest versions use this mod to, IMO the "overwrite" function is not necessary at all.

gsmanners wrote:Hmm... I was about to say it's working a lot better, although there is still the problem of torches sometimes falling for no apparent reason at times.

http://i.imgur.com/APxUnvS.jpg

I'm a little nuts with the torches here, but I think limiting the add_particle within 13 is a good optimization. I think this many torches would have made me lag quite a bit in the old vesion.
Ok, thanks for your feedback. I will look for the "dropping"-issue by time and use the limiting in next release then.

Iqualfragile
Member
Posts: 160
Joined: Tue Sep 18, 2012 22:11

by Iqualfragile » Post

BlockMen wrote:
Iqualfragile wrote:You made a mistake when redefining the torch, better use this diff:
Spoiler

Code: Select all

diff --git a/init.lua b/init.lua
index ea88ee8..96e0038 100644
--- a/init.lua
+++ b/init.lua
@@ -77,13 +77,8 @@ local function is_wall(wallparam)
 end

 --node_boxes
-minetest.register_craftitem(":default:torch", {
-       description = "Torch",
-       inventory_image = "torches_torch.png",
-       wield_image = "torches_torch.png",
-       wield_scale = {x=1,y=1,z=1+1/16},
-       liquids_pointable = false,
-       on_place = function(itemstack, placer, pointed_thing)
+minetest.override_item("default:torch",{
+       on_place = function(itemstack, placer, pointed_thing)
                if pointed_thing.type ~= "node" or string.find(minetest.env:get_node(pointed_thing.above).name, "torch") then
                        return itemstack
                end
@@ -92,20 +87,18 @@ minetest.register_craftitem(":default:torch", {
                local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z})
                local u_n = minetest.get_node(under)
                if u_n and not minetest.registered_nodes[u_n.name].walkable then above = under end
-               local u_n = minetest.get_node(above)
+                       local u_n = minetest.get_node(above)
                if u_n and minetest.registered_nodes[u_n.name].walkable then return itemstack end
                if wdir == 1 then
-                       minetest.env:add_node(above, {name = "torches:floor"})
-               else
+                       minetest.env:add_node(above, {name = "torches:floor"})
+               else   
                        minetest.env:add_node(above, {name = "torches:wand", param2 = is_wall(wdir)})
                end
                if not wdir == 0 or not minetest.setting_getbool("creative_mode") then
                        itemstack:take_item()
                end
                return itemstack
-
        end
-
 })

 minetest.register_node("torches:floor", {
First: Its no mistake, it the "old" way of redefining.
Second: I will stay at that to allow people with older Minetest versions use this mod to, IMO the "overwrite" function is not necessary at all.
It actually has a mistake which i avoided by just overriding one single value: you did not define the torch as diggable at all.
overriding helps do avoid those mistakes, keep up with changes in the original mod and reduce collisions between mods, maybe it would be best to publish two seperate versions of your mod for different minetest versions (you could use mmdb for that).
Gr8 b8, m8. I rel8, str8 appreci8, and congratul8. I r8 this b8 an 8/8. Plz no h8, I'm str8 ir8. Cr8 more, can't w8. We should convers8, I won't ber8, my number is 8888888, ask for N8. No calls l8 or out of st8. If on a d8, ask K8 to loc8. Even with a full pl8, I always have time to communic8 so don't hesit8.

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

by BlockMen » Post

Iqualfragile wrote: It actually has a mistake which i avoided by just overriding one single value: you did not define the torch as diggable at all.
overriding helps do avoid those mistakes, keep up with changes in the original mod and reduce collisions between mods, maybe it would be best to publish two seperate versions of your mod for different minetest versions (you could use mmdb for that).
I would have been able to just override/add the on_place function before, but i decided to override the complete definition to have a craft item instead. By that i missed that craft item-nodes (or whatever you want call then old torches) are not diggable.

So this mistake would not been prevented since my intention was to to change the definiton at all, not just that particular function.

But thanks for pointing out that old torches are not diggable.

gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

I was looking through the code for this again and noticed this:

Code: Select all

    local p2 = {x=p.x+d.x, y=p.y+d.y, z=p.z+d.z}
    local nn = minetest.env:get_node(p2).name
    local def2 = minetest.registered_nodes[nn]
    if def2 and not def2.walkable then
        return false
    end
It's pretty cool that you can tell where the torch should attach to, but I was wondering whether you can count on the neighbor node actually residing in the environment during an ABM event. That may be the iffy part I've been running into.

electricface
New member
Posts: 1
Joined: Wed Jan 22, 2014 12:26

by electricface » Post

I find a bug, Put a torch in the water, Can not see that the torch

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

by BlockMen » Post

Update. Version 1.3 released

Changelog:
- flames are only shown if a player is near a torch (13 blocks)
- stopped random dropping of torches
- old torches are converted now, ceiling placed removed

---
gsmanners wrote:It's pretty cool that you can tell where the torch should attach to, but I was wondering whether you can count on the neighbor node actually residing in the environment during an ABM event. That may be the iffy part I've been running into.
Removed the dropping part from abm, so they shouldnt drop randomly anymore. Thanks for pointing out problems, new bug reports and improvement ideas are always welcome ;)
electricface wrote:I find a bug, Put a torch in the water, Can not see that the torch
Do you mean that the flames are not shown correct near water? If so i cant do anything since its a know bug in engine.

But in general I'm not sure whether allowing to place torches in water or not. Some feedback would be nice.

gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

Ah, I see. Yes, I think register_on_dignode should work much more reliably than an ABM event. It does raise the question of what is going on with the old design, though.

I was thinking that maybe it's a corner case or possibly something esoteric like a timing issue. Now I'm wondering whether I should be worried about where I happen to find flowing water or lava.

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

by PilzAdam » Post

I noticed that the torches always drop when you dig/place a node somewhere next to them (i.e. if nodeupdate() runs).

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

/me confirms the bug.

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

by BlockMen » Post

PilzAdam wrote:I noticed that the torches always drop when you dig/place a node somewhere next to them (i.e. if nodeupdate() runs).
4aiman wrote:/me confirms the bug.
Thanks for reporting, fixed in 1.3.1

gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

Just saw another one:

Code: Select all

11:03:29: ERROR[main]: ServerError: /home/genma/.minetest/mods/minetest/torches/init.lua:228: attempt to index local 'n' (a nil value)
11:03:29: ERROR[main]: stack traceback:
11:03:29: ERROR[main]:     /home/genma/.minetest/mods/minetest/torches/init.lua:228: in function 'callback'
11:03:29: ERROR[main]:     ...ome/genma/src/minetest-0.4.9/bin/../builtin/item.lua:442: in function <...ome/genma/src/minetest-0.4.9/bin/../builtin/item.lua:380>
11:03:29: ERROR[main]:     (tail call): ?
I think the below is what's relevant:
minetest.get_node_or_nil(pos)
^ Returns nil for unloaded area

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

by BlockMen » Post

gsmanners wrote:Just saw another one:

Code: Select all

11:03:29: ERROR[main]: ServerError: /home/genma/.minetest/mods/minetest/torches/init.lua:228: attempt to index local 'n' (a nil value)
11:03:29: ERROR[main]: stack traceback:
11:03:29: ERROR[main]:     /home/genma/.minetest/mods/minetest/torches/init.lua:228: in function 'callback'
11:03:29: ERROR[main]:     ...ome/genma/src/minetest-0.4.9/bin/../builtin/item.lua:442: in function <...ome/genma/src/minetest-0.4.9/bin/../builtin/item.lua:380>
11:03:29: ERROR[main]:     (tail call): ?
I think the below is what's relevant:
minetest.get_node_or_nil(pos)
^ Returns nil for unloaded area
Could you check if this issue still occurs with lastest git version?
https://github.com/BlockMen/torches/

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

The error won't happen with the current version.
However, you shouldn't return at line #228.
It's possible, that some part of a map is still loaded. Thus you won't check "further" positions if one of your checks would return a nil. Thus some of nodes won't update.

gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

BlockMen wrote:Could you check if this issue still occurs with lastest git version?
https://github.com/BlockMen/torches/
I don't think the problem I saw is all that common or altogether easy to reproduce, but your fix there looks very similar to mine:

Code: Select all

        local p = {x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}
        local n = minetest.get_node_or_nil(p)
        if n then
            local fd = minetest.registered_nodes[n.name].update or nil
etc...

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

gsmanners wrote:...
Now this is a better solution.
Last edited by 4aiman on Mon Apr 07, 2014 06:32, edited 1 time in total.

xaGe
New member
Posts: 1
Joined: Wed Apr 09, 2014 02:49

by xaGe » Post

Thanks for the mod. The latest git version seems to work just fine so far with latest minetest compiled from git.

User avatar
JPRuehmann
Member
Posts: 334
Joined: Fri Mar 21, 2014 21:40
Location: Germany
Contact:

by JPRuehmann » Post

have just installed the latest version of torches
got the following error by hitting an unknown block.

12:09:15: ERROR[main]: ServerError: /home/ruehmann/.minetest/mods/torches/init.lua:229: attempt to index field '?' (a nil value)
12:09:15: ERROR[main]: stack traceback:
12:09:15: ERROR[main]: /home/ruehmann/.minetest/mods/torches/init.lua:229: in function 'callback'
12:09:15: ERROR[main]: /usr/share/minetest/builtin/item.lua:455: in function </usr/share/minetest/builtin/item.lua:393>
12:09:15: ERROR[main]: (tail call): ?

Thanks,
JPR

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

by BlockMen » Post

gsmanners wrote:Just saw another one:

Code: Select all

11:03:29: ERROR[main]: ServerError: /home/genma/.minetest/mods/minetest/torches/init.lua:228: attempt to index local 'n' (a nil value)
11:03:29: ERROR[main]: stack traceback:
11:03:29: ERROR[main]:     /home/genma/.minetest/mods/minetest/torches/init.lua:228: in function 'callback'
11:03:29: ERROR[main]:     ...ome/genma/src/minetest-0.4.9/bin/../builtin/item.lua:442: in function <...ome/genma/src/minetest-0.4.9/bin/../builtin/item.lua:380>
11:03:29: ERROR[main]:     (tail call): ?
JPRuehmann wrote:have just installed the latest version of torches
got the following error by hitting an unknown block.

12:09:15: ERROR[main]: ServerError: /home/ruehmann/.minetest/mods/torches/init.lua:229: attempt to index field '?' (a nil value)
12:09:15: ERROR[main]: stack traceback:
12:09:15: ERROR[main]: /home/ruehmann/.minetest/mods/torches/init.lua:229: in function 'callback'
12:09:15: ERROR[main]: /usr/share/minetest/builtin/item.lua:455: in function </usr/share/minetest/builtin/item.lua:393>
12:09:15: ERROR[main]: (tail call): ?

Thanks,
JPR
Both fixed in 1.3.2

Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

Re: [Mod] Torches [1.3.2] [torches]

by Minetestforfun » Post

Please, look at my screenshots, this is normal ?
I haven't the same texture like you in your first post...
I really prefer your textures ! :)

http://imgur.com/nZIOjVQ
http://imgur.com/AzqKbi5

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

Re: [Mod] Torches [1.3.2] [torches]

by BlockMen » Post

Minetestforfun wrote:Please, look at my screenshots, this is normal ?
I haven't the same texture like you in your first post...
I really prefer your textures ! :)

http://imgur.com/nZIOjVQ
http://imgur.com/AzqKbi5
Do you mean that everything looks blurred? If so, turn off the anisotropic filter, bilinear filter and trilinear filter

Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

Re: [Mod] Torches [1.3.2] [torches]

by Minetestforfun » Post

Indeed, my bad... Sorry...

Rochambeau
Member
Posts: 119
Joined: Tue Sep 23, 2014 11:37

Re: [Mod] Torches [1.3.2] [torches]

by Rochambeau » Post

I think i found a bug: when i right click a door while holding a torch, the torch is placed at the door.

It doesn't happen with default torches or carbones torches for example.

User avatar
stormchaser3000
Member
Posts: 422
Joined: Sun Oct 06, 2013 21:02
GitHub: stormchaser3000

Re: [Mod] Torches [1.3.2] [torches]

by stormchaser3000 » Post

how about uinsg the mesh drawtype

Post Reply

Who is online

Users browsing this forum: No registered users and 45 guests