Again? Yep, again... More questions.

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

Again? Yep, again... More questions.

by Tedypig » Wed Mar 13, 2013 02:11

1. What is max_drop_level=# (tool)
2. What is max_level=# (also tool)
3. How (if possible) do you make a chat_send_all when a player digs a certain node?
4.How do you make a tool light up while you wield it? (like the mese pickaxe in the walking light mod)
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Wed Mar 13, 2013 03:06

I figured most of it out on my own. However, I did get this.

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
23:00:46: ERROR[main]: ========== ERROR FROM LUA ===========
23:00:46: ERROR[main]: Failed to load and run script from
23:00:46: ERROR[main]: C:\Users\Matt and Betty\Downloads\minetest-0.4.5\minetest-0.4.5\bin\..\worlds\test\worldmods\sits\init.lua:
23:00:46: ERROR[main]: ....4.5\minetest-0.4.5\bin\..\builtin/misc_register.lua:170: attempt to index local 'tooldef' (a nil value)
23:00:46: ERROR[main]: stack traceback:
23:00:46: ERROR[main]:     ....4.5\minetest-0.4.5\bin\..\builtin/misc_register.lua:170: in function 'register_tool'
23:00:46: ERROR[main]:     ...est-0.4.5\bin\..\worlds\test\worldmods\sits\init.lua:6: in main chunk
23:00:46: ERROR[main]: =======END OF ERROR FROM LUA ========
23:00:46: ERROR[main]: Server: Failed to load and run C:\Users\Matt and Betty\Downloads\minetest-0.4.5\minetest-0.4.5\bin\..\worlds\test\worldmods\sits\init.lua
23:00:46: ERROR[main]: ModError: Failed to load and run C:\Users\Matt and Betty\Downloads\minetest-0.4.5\minetest-0.4.5\bin\..\worlds\test\worldmods\sits\init.lua


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
--Sword In The Stone Mod By Tedypig.  --Licence: Not sure, You can use/modify/redistribute how you want,
--but please give me credit for the original mod in the supplied readme.

-- Sword in the stone - SWORD

minetest.register_tool("sits:sword_of_ultimate_power"){
description "Adds a sword that can cut/chop/dig/kill anything in one hit, and lights up like the sun.",
inventory_image="sword_of_ultimate_power.png",
light_source='LIGHT_MAX',
tool_capabilities={
    full_punch_interval=0.1,
    max_drop_level=1,
    groupcaps={
            fleshy={times={[1]=100.00}, uses=0, maxlevel=2},
            snappy={times={[1]=100.00}, uses=0, maxlevel=1},
            choppy={times={[1]=100.00}, uses=0, maxlevel=0},
                }
    }
}


--Crafting

--No crafting. You must find the "Sword In The Stone" to obtain this sword.

--Sword in the stone - NODE

minetest.register_node ("sits:swordinthestone"){
    description "The stone you must find to get the sword of ultimate power.",
    drawtype = 'draw',
    tiles = 'swordinthestone.png',
    inventory_image = 'swordinthestone.png',
    paramtype = 'light',
    walkable = false,
    sunlight_propagates = true,
    drop = 'sits:sword_of_ultimate_power',
        groups ={
        {crumbly=10}
        }
}

--Crafting
--No crafting, Must be placed by the server owner in creative mode.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Wed Mar 13, 2013 03:12

For max_drop_level and max_level I suggest reading the documentation for the groups and damage in the lua_api.txt file that comes with the game download. For chat_send_all you'll probably want to set a custom after_dig_node callback on the node type. For a SPECIFIC node (as in one at a particular location) where you aren't in control of the node type you might not have that option, and might have to use the global minetest.register_on_dignode() instead (but avoid this if possible).

For making a tool light up, you really can't. The walking light mod is a really dirty hack that replaces nodes around a moving character with invisible lit up nodes (basically invisible torches). This doesn't work very well in water or if the player is moving past a real torch or something; the mod will actually replace other nodes as you move past them. That's not a dig at the mod creator; it's just unfortunately the only way to fudge a moving light in the game right now.
 

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

by Menche » Wed Mar 13, 2013 04:45

It looks like you forgot the equals sign for "description" in the tool definition.
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
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Wed Mar 13, 2013 08:05

Menche wrote:It looks like you forgot the equals sign for "description" in the tool definition.

Good catch. This should by all rights be a syntax error, but unfortunately the designers of the Lua language decided you should be able to call a function with a single string literal parameter without using parentheses. This is a thorn in everyone's side at some point or another.

There's another problem that is causing the actual error message though. The table with the tool definitions actually must be a parameter to the minetest.register_tool() call, but there is a closing parenthesis that terminates the function call before it. Compare the following:

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
-- This is what you have:
minetest.register_tool("sits:sword_of_ultimate_power") { ... }

-- This is what you need:
minetest.register_tool("sits:sword_of_ultimate_power", { ... })


(The same goes for the call to minetest.register_node() farther down.)
Last edited by prestidigitator on Wed Mar 13, 2013 08:06, edited 1 time in total.
 

rarkenin
Member
 
Posts: 668
Joined: Tue Nov 20, 2012 20:48

by rarkenin » Wed Mar 13, 2013 10:35

prestidigitator wrote:For making a tool light up, you really can't. The walking light mod is a really dirty hack that replaces nodes around a moving character with invisible lit up nodes (basically invisible torches). This doesn't work very well in water or if the player is moving past a real torch or something; the mod will actually replace other nodes as you move past them. That's not a dig at the mod creator; it's just unfortunately the only way to fudge a moving light in the game right now.


Is there a way to make an entity light up? Or to make it so the player is bound to an entity, but the player moves the entity(not the entity moves the player)?
Last edited by rarkenin on Wed Mar 13, 2013 10:35, edited 1 time in total.
Admin pro tempore on 0gb.us:30000. Ask me if you have a problem, or just want help.
This is a signature virus. Add me to your signature so that I can multiply.
Now working on my own clone, Mosstest.
I guess I'm back for some time.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Wed Mar 13, 2013 12:32

Ok, I figured this out. The sword is effing awesome. One problem though, Mese and Trees will NOT cut for some reason. I hack away at them forever and they don't break. Also for some reason my node that drops the sword is not showing the image, instead it's showing the unknown block image. Any ideas? I would like to release this today if possible.

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
--Sword In The Stone Mod By Tedypig.  --Licence: Not sure, You can use/modify/redistribute how you want,
--but please give me credit for the original mod in the supplied readme.

-- Sword in the stone - SWORD

minetest.register_tool("sits:sword_of_ultimate_power", {
description = "Adds a sword that can cut/chop/dig/kill anything in one hit.",
inventory_image="sword_of_ultimate_power.png",
tool_capabilities={
    full_punch_interval=0,
    max_drop_level=1,
    groupcaps={
            fleshy={times={[1]=100.00}, uses=0, maxlevel=1},
            snappy={times={[1]=100.00}, uses=0, maxlevel=1},
            choppy={times={[1]=100.00}, uses=0, maxlevel=1},
            crumbly={times={[1]=100.00}, uses=0, maxlevel=1},
            cracky={times={[1]=100.00}, uses=0, maxlevel=1},
                }
    }
})


--Crafting

--No crafting. You must find the "Sword In The Stone" to obtain this sword.

--Sword in the stone - NODE

minetest.register_node ("sits:swordinthestone", {
    description = "The stone you must find to get the sword of ultimate power.",
    drawtype = 'draw',
    tiles = 'swordinthestone.png',
    inventory_image = 'swordinthestone.png',
    paramtype = 'light',
    walkable = false,
    sunlight_propagates = true,
    drop = 'sits:sword_of_ultimate_power',
        groups ={crumbly=1},
    }
)

--Crafting
--No crafting, Must be placed by the server owner in creative mode.


Edit: The inventory image work, but not when I place it.
Edit2: My new node wont break with the sword either.
Last edited by Tedypig on Wed Mar 13, 2013 12:50, edited 1 time in total.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Wed Mar 13, 2013 14:06

Fixed the image not displaying. (I forgot the {} brackets)

Made a TODO list.
1. Make it break; my new node, mese, and trees.
2. Write a callback to chat_send_all when my node is dug.
3. RELEASE!

Those are not in order. It's actually 1,3,2.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Wed Mar 13, 2013 14:14

---Screenshots---
Sword on the ground.
Image
Sword in hand.
Image
Node (drops the sword)
Image
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Wed Mar 13, 2013 17:17

rarkenin wrote:Is there a way to make an entity light up? Or to make it so the player is bound to an entity, but the player moves the entity(not the entity moves the player)?

At this time, no. Only nodes can generate light, not entities. Frustrating.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Thu Mar 14, 2013 02:52

I hate to be a bug, but can someone help me with the sword not digging those blocks.
Also, could someone write the callback for when someone digs the node.

I would like it to say "<player> just found the Sword In The Stone and received the Sword Of Ultimate Power at <position>. Congratulations!"

If I can get help with these two things I can release by midnight. YOU WILL GET CREDIT FOR YOUR HELP!!!

Thanks in advance. ----Tedypig
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Thu Mar 14, 2013 03:12

Figured out the not digging, not it wont hurt other players. Help?
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Thu Mar 14, 2013 08:48

To hurt players you need the "fleshy" group in the tool capabilities.

The callback should be relatively simple. Just call minetest.chat_send_player() or minetest.chat_send_all() in the after_dig_node() callback on the node.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Thu Mar 14, 2013 15:16

prestidigitator wrote:To hurt players you need the "fleshy" group in the tool capabilities.

The callback should be relatively simple. Just call minetest.chat_send_player() or minetest.chat_send_all() in the after_dig_node() callback on the node.


I have fleshy as the same setting as all the other groups, I just can't get it to hurt people. I have it as a one hit dig/chop/cut/kill.

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
 fleshy={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=1},
            snappy={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=1},
            choppy={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=1},
            crumbly={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=1},
            cracky={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=1},
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Thu Mar 14, 2013 16:52

Huh. And PVP is enabled? Do other weapons hurt other players?
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Thu Mar 14, 2013 20:07

prestidigitator wrote:Huh. And PVP is enabled? Do other weapons hurt other players?

If by PvP you mean damage enabled, then yes I do. Also, yes the other weapons hurt. I don't friggen get it. Lol.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Thu Mar 14, 2013 20:54

This is how the damage system works:
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("default:sword_steel", {
    description = "Steel Sword",
    inventory_image = "default_tool_steelsword.png",
    tool_capabilities = {
        full_punch_interval = 0.8,
        max_drop_level=1,
        groupcaps={
            fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2},
            snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1},
            choppy={times={[3]=0.65}, uses=40, maxlevel=0}
        }
    }
})


You can have up to 0.8 of "punch time" (silly self-invented term). You'll deal 2 damage (= 1 heart) to entities with fleshy=3, 1 damage to entities with fleshy=2 and no damage to entities with fleshy=1.
 

User avatar
Likwid H-Craft
Member
 
Posts: 1113
Joined: Sun Jan 06, 2013 14:20

by Likwid H-Craft » Thu Mar 14, 2013 21:34

Q:How Many Players can be on one server?
My Domain's/others:
http://likwidtest.hj.cx/ (Not Done)
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Thu Mar 14, 2013 22:05

Likwid H-Craft wrote:Q:How Many Players can be on one server?


Probably thousands. :P
If you want to ask a question, you should create a new topic instead.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Thu Mar 14, 2013 22:24

Calinou wrote:This is how the damage system works:
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("default:sword_steel", {
    description = "Steel Sword",
    inventory_image = "default_tool_steelsword.png",
    tool_capabilities = {
        full_punch_interval = 0.8,
        max_drop_level=1,
        groupcaps={
            fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2},
            snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1},
            choppy={times={[3]=0.65}, uses=40, maxlevel=0}
        }
    }
})


You can have up to 0.8 of "punch time" (silly self-invented term). You'll deal 2 damage (= 1 heart) to entities with fleshy=3, 1 damage to entities with fleshy=2 and no damage to entities with fleshy=1.


Right, I know. I read the ones for the wood,stone, and steel swords, but I wanted a "one hitter quitter". Is there a way to do that? Right now everything else is one click destroy, I don't see why this can't be set to fleshy also.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 04:13

(I meant PVP as in there is a server option that can be used to turn off PVP damage. This is separate from whether damage is enabled at all, I believe. Anyway, this isn't the issue if other weapons are working.)

I really don't know what the behavior will be if the times are set to zero. You could try a really small value (e.g. 0.001) instead, maybe. As Calinou said, you might try defining full_punch_interval too. This could be a small value too. Basically I think the ratio of full_punch_interval/times[...] it going to be the maximum damage the weapon does, and it will do this much damage on the first swing and if you wait pull_punch_interval between swings.

More about entity damage can be found in lua_api.txt, and I've added a synopsis to the LuaEntitySAO article on the dev wiki.

Of course, if you want a really, really sure way to kill a player with a weapon in one hit, forget the built-in damage and do something like this:
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(
   "...",
   {
      ...,

      on_use = function(stack, player, pointedThing)
         local pos = pointedThing.under
         local obj = pointedThing.ref
         if pointedThing.type == "object" and obj then
            obj:set_hp(0)
            if not obj:get_player_name() then
               -- Non-player entities have to be removed explicitly
               obj:remove()
            end
         elseif pointedThing.type == "node" and pos then
            minetest.node_dig(pos, minetest.env:get_node(pos), player)
         end
      end
   })


That should do a one-swing kill on literally anything. The code is untested, so there might need to be a small change or two.
Last edited by prestidigitator on Fri Mar 15, 2013 04:16, edited 1 time in total.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Fri Mar 15, 2013 17:08

Everything is still the same, but now it takes two hits to remove a node instead of one. No damage to other players or mobs.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 17:31

With THAT code? Erm.... Maybe throw some debug statements in then and see what branches of the code you are reaching with various uses. I don't know what else to tell you.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Fri Mar 15, 2013 17:49

prestidigitator wrote:With THAT code? Erm.... Maybe throw some debug statements in then and see what branches of the code you are reaching with various uses. I don't know what else to tell you.


I hit a vombie.

13:45:24: ACTION[ServerThread]: LuaEntitySAO at (266.17,11.7,-260.087) punched by player Teddypig, damage 0 hp, health now 8 hp

This is how I did the code. Is it right?
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("sits:sword_of_ultimate_power", {
description = "Sword Of Ultimate Power",
inventory_image="sword_of_ultimate_power.png",
tool_capabilities={
    full_punch_interval=0,
    max_drop_level=1,
on_use = function(stack, player, pointedThing)
         local pos = pointedThing.under
         local obj = pointedThing.ref
         if pointedThing.type == "object" and obj then
            obj:set_hp(0)
            if not obj:get_player_name() then
               -- Non-player entities have to be removed explicitly
               obj:remove()
            end
         elseif pointedThing.type == "node" and pos then
            minetest.node_dig(pos, minetest.env:get_node(pos), player)
         end
      end
      }
   })
       
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 17:54

Oh. No, it's not. "on_use" should come before or after "tool_capabilities", not inside it. Actually you could probably just REPLACE tool_capabilities with it, since I don't think the tool capabilities will be used if you have an explicit on_use handler.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Fri Mar 15, 2013 18:00

NOW, still no damage (doesn't even register that I swung it), and no continuous hitting. It DOES however remove a block with one hit. I apologize if I'm being a bother.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 21:39

No bother at all. Try putting this statement just before the if-statement in on_use:
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
print("DEBUG sword.on_use: pointedThing.type = "..(pointedThing.type or "nil")..", pos = "..(pos and minetest.pos_to_string(pos) or "nil")..", obj = "..(obj and (obj:get_player_name() or "(NP entity)") or "nil"))

That should tell us what the weapon thinks you are swinging at, and if the "pointed_thing" is behaving the way we're told is does.
Last edited by prestidigitator on Fri Mar 15, 2013 21:40, edited 1 time in total.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Fri Mar 15, 2013 22:33

Well I feel like it.

Debug info.
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
18:29:30: ACTION[ServerThread]: Teddypig joins game. List of players: Teddypig
Font size: 8 17
18:29:39: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [node under=36,19,-192 above=36,20,-192]
DEBUG sword.on_use: pointedThing.type = node, pos = (36,19,-192), obj = nil
node_dig
18:29:39: ACTION[ServerThread]: Teddypig digs default:dirt_with_grass at (36,19,-192)
18:29:40: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [node under=36,19,-191 above=36,20,-191]
DEBUG sword.on_use: pointedThing.type = node, pos = (36,19,-191), obj = nil
node_dig
18:29:40: ACTION[ServerThread]: Teddypig digs default:dirt_with_grass at (36,19,-191)
18:29:44: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [object 5]
DEBUG sword.on_use: pointedThing.type = object, pos = nil, obj =
18:29:45: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [object 5]
DEBUG sword.on_use: pointedThing.type = object, pos = nil, obj =
18:29:46: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [object 5]
DEBUG sword.on_use: pointedThing.type = object, pos = nil, obj =
18:29:50: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [object 5]
DEBUG sword.on_use: pointedThing.type = object, pos = nil, obj =
18:29:59: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [node under=22,23,-185 above=23,23,-185]
DEBUG sword.on_use: pointedThing.type = node, pos = (22,23,-185), obj = nil
node_dig
18:29:59: ACTION[ServerThread]: Teddypig digs default:stone at (22,23,-185)
18:30:00: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [node under=22,23,-186 above=23,23,-186]
DEBUG sword.on_use: pointedThing.type = node, pos = (22,23,-186), obj = nil
node_dig
18:30:00: ACTION[ServerThread]: Teddypig digs default:stone at (22,23,-186)
18:30:00: ACTION[ServerThread]: Teddypig uses sits:sword_of_ultimate_power, pointing at [node under=22,23,-187 above=23,23,-187]
DEBUG sword.on_use: pointedThing.type = node, pos = (22,23,-187), obj = nil
node_dig
18:30:00: ACTION[ServerThread]: Teddypig digs default:stone at (22,23,-187)
18:30:41: ACTION[ServerThread]: MOBF: Your mob table: 20871680 dropt into water moving to (2.4217445850372,3.2999999523163,-162.2046661377) state: drop
18:30:43: ERROR[main]: ServerEnvironment::deactivateFarObjects(): id=5 m_static_exists=true but static data doesn't actually exist in (4,0,-12)
WARNING: StaticObjectList::remove(): id=5 not found

I dug two dirt_with_grass, swung at a sheep a few times and the dug two/three stone.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 22:41

Oh! Sorry. I guess ObjectRef:get_player_name() returns an empty string for non-players, not nil. Change the conditional to read:

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
local pName = obj:get_player_name()
if not pName or pName == "" then ....


That should fix it for non-player entities. You tested it on a player also?
Last edited by prestidigitator on Fri Mar 15, 2013 22:42, edited 1 time in total.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Fri Mar 15, 2013 23:47

OK, this is what I have right now.
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("sits:sword_of_ultimate_power", {
description = "Sword Of Ultimate Power",
inventory_image="sword_of_ultimate_power.png",
on_use = function(stack, player, pointedThing)
         local pos = pointedThing.under
         local obj = pointedThing.ref
         if pointedThing.type == "object" and obj then
            obj:set_hp(0)
            if not obj:get_player_name() then
               -- Non-player entities have to be removed explicitly
               obj:remove()
            end
         elseif pointedThing.type == "node" and pos then
            minetest.node_dig(pos, minetest.env:get_node(pos), player)
         end
      end
     
   })


Where do I put what you said?
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

Next

Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 5 guests

cron