Page 1 of 1

[Mod] Minecraft-Like Node drop

PostPosted: Tue Mar 20, 2012 17:13
by LorenzoVulcan
I made a drop of broken node in LUA changing the builtin.lua code.

Image

Video: http://www.youtube.com/watch?v=qwSybmvqINo&feature=youtu.be

Q:How can i import this mod?

1.On builtin.lua,Search "minetest.node_dig" (without "",LOL)
2.Where:
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
        -- Add dropped items

        local _, dropped_item

        for _, dropped_item in ipairs(drops) do

            digger:get_inventory():add_item("main", dropped_item)

        end

3.Take:
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
            digger:get_inventory():add_item("main", dropped_item)

4.Then Sostitute that with:
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.env:add_item(pos,dropped_item);

5.This could be the result
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
        -- Add dropped items

        local _, dropped_item

        for _, dropped_item in ipairs(drops) do

            --digger:get_inventory():add_item("main", dropped_item)
            --Original Code's Backup

            minetest.env:add_item(pos,dropped_item);

        end


Q:Is there a stay-alone version?

Yes,get it there: http://www.mediafire.com/?hlsoc988x7f5qf4
Not so performable And it's bugged with nodes like stone and dirt with glass because they didn't give the same block,so he doesn't remove.I have no time for fix that,but if somebody wants to fix it's welcome.

PostPosted: Tue Mar 20, 2012 17:40
by sfan5
Nice!

PostPosted: Tue Mar 20, 2012 17:46
by LorenzoVulcan
sfan5 wrote:Nice!

Thanks.
This is just a line of code :D Do you think i might do some accelleration on the object?

PostPosted: Tue Mar 20, 2012 18:31
by Utilisatrice
Hi,

You're amazing,

But you can build a mod ?

For activate and desactivate this option without modify the builtin.lua

Good Jobs.

PostPosted: Tue Mar 20, 2012 18:47
by LorenzoVulcan
Utilisatrice wrote:Hi,

You're amazing,

But you can build a mod ?

For activate and desactivate this option without modify the builtin.lua

Good Jobs.

Eeeeeyup.

Added in the main message.

PostPosted: Fri Mar 23, 2012 19:07
by sdzen
now all we need is for it to be picked up when you step on it!

PostPosted: Fri Mar 23, 2012 19:24
by sfan5
+1

PostPosted: Fri Mar 23, 2012 19:34
by LorenzoVulcan
sdzen wrote:now all we need is for it to be picked up when you step on it!

Not so easy to make,but why?
Without auto-pickup you can moderate your inventory from useless nodes.

PostPosted: Fri Mar 23, 2012 21:11
by sdzen
yes but my mouse doesnt enjoy the massive clicking sprees i put it through now any more and my mouse springs will bust im sure

PostPosted: Sun Mar 25, 2012 20:42
by lkjoel
Wow, I should have looked at this before I tried to do that lol! I'm going to try to implement the auto-pickup thing.

PostPosted: Sun Mar 25, 2012 21:11
by LorenzoVulcan
lkjoel wrote:Wow, I should have looked at this before I tried to do that lol! I'm going to try to implement the auto-pickup thing.

Let's do it! ;)

PostPosted: Sun Mar 25, 2012 21:32
by lkjoel
I think Jeija's mesecon code could help us here...

PostPosted: Mon Jul 30, 2012 07:07
by cornernote
any updates on auto-picking up the dropped items? I would really like to see that working!

edit: there is code here to do it:
http://minetest.net/forum/viewtopic.php?id=1597

PostPosted: Mon Jul 30, 2012 09:17
by PilzAdam
My MiniTest game has Minecraft like drop and pickup. Theres just one mod (item_drop) that do the whole work (you dont have to change any builtin.lua). The problem is that you have to add some code to all registered nodes.

PostPosted: Mon Jul 30, 2012 09:41
by cornernote
I got it working by editing the builtin file, similar to the instructions in the other post, but some things were a little different.

I see you also did this:
>> Imporve picking up of items. Add sound when picking up items.

nice =)


In my game I am having a problem where if you are moving, sometimes the items go past you and fly off into space. How did you deal with that?

PostPosted: Mon Jul 30, 2012 09:56
by PilzAdam
cornernote wrote:In my game I am having a problem where if you are moving, sometimes the items go past you and fly off into space. How did you deal with that?

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 items = minetest.env:get_objects_inside_radius(pos,1)
for j,item in ipairs(items) do
    [pick up items]
end

items = minetest.env:get_objects_inside_radius(pos,2)
for j,item in ipairs(items) do
    [accelerate items in players direction]
end

The items in a radius of 2 are accelerated in players direction and the items in a radius of 1 are picked up.
I hope this helps out.

PostPosted: Mon Jul 30, 2012 10:11
by cornernote
I tried your item_drop mod. Works a treat, no core hack required. I think the greater acceleration, as well as the range you implemented prevents them from flying past you.

What was the thing you had to change in all registered nodes? I didnt have to change anything and it works in mine.

PostPosted: Mon Jul 30, 2012 10:14
by PilzAdam
cornernote wrote:I tried your item_drop mod. Works a treat, no core hack required. I think the greater acceleration, as well as the range you implemented prevents them from flying past you.

What was the thing you had to change in all registered nodes? I didnt have to change anything and it works in mine.

The pickup of items works without changes but if you want that blocks drops items when digged you have have to add this to all register_node methods:
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
after_dig_node = function(pos, oldnode, oldmetadata, digger)
    item_drop(pos, oldnode, digger)
end,

PostPosted: Mon Jul 30, 2012 10:19
by cornernote
I think there should be 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
local items = minetest.env:get_objects_inside_radius(pos,1)
for j,item in ipairs(items) do
    [pick up items]
end

items = minetest.env:get_objects_inside_radius(pos,2)
for j,item in ipairs(items) do
    [accelerate items in players direction]
    [wait 1 second, if i still exist then find new player pos and accelerate towards them]
end


Can this be done?

PostPosted: Mon Jul 30, 2012 10:21
by cornernote
PilzAdam wrote:The pickup of items works without changes but if you want that blocks drops items when digged you have have to add this to all register_node methods:
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
after_dig_node = function(pos, oldnode, oldmetadata, digger)
    item_drop(pos, oldnode, digger)
end,


ahh, yes I did that as a global in builtin/item.lua

PostPosted: Mon Jul 30, 2012 10:23
by PilzAdam
cornernote wrote:ahh, yes I did that as a global in builtin/item.lua

Does this support a drop of other items (e.g. dirt_with_grass drops dirt)?

PostPosted: Mon Jul 30, 2012 10:24
by cornernote
you should come in IRC, easier to chat =)

PostPosted: Mon Jul 30, 2012 10:27
by cornernote
PilzAdam wrote:Does this support a drop of other items (e.g. dirt_with_grass drops dirt)?


Yep. It even drops the randoms (eg, 1/20 at dropping a sapling when you chop leaves)!

PostPosted: Mon Jul 30, 2012 10:38
by PilzAdam
cornernote wrote:you should come in IRC, easier to chat =)

Im on.

PostPosted: Mon Jul 30, 2012 10:38
by cornernote
I did a few small tweaks...

set the radius to 3, (2 didn't seem like enough reach, 4 was too much)
set the player pos to only p.y+0.5 (instead of 1, this causes the items to shoot towards your waist instead of right at your face)

PostPosted: Mon Jul 30, 2012 10:42
by PilzAdam
cornernote wrote:I did a few small tweaks...

set the radius to 3, (2 didn't seem like enough reach, 4 was too much)
set the player pos to only p.y+0.5 (instead of 1, this causes the items to shoot towards your waist instead of right at your face)

With the p.y+0.5 you are right but i think a radius of 3 is too much.

PostPosted: Mon Jul 30, 2012 15:22
by Lelix
finalmente sei ritornato!

PostPosted: Mon Jul 30, 2012 17:17
by LolManKuba
Lelix wrote:finalmente sei ritornato!

Only use other languages on the other languages sub forum