[Mod] Minecraft-Like Node drop

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

[Mod] Minecraft-Like Node drop

by LorenzoVulcan » Tue Mar 20, 2012 17:13

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.
Last edited by LorenzoVulcan on Thu Mar 22, 2012 16:18, edited 1 time in total.
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Tue Mar 20, 2012 17:40

Nice!
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Tue Mar 20, 2012 17:46

sfan5 wrote:Nice!

Thanks.
This is just a line of code :D Do you think i might do some accelleration on the object?
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

Utilisatrice
Member
 
Posts: 103
Joined: Thu Feb 16, 2012 18:04

by Utilisatrice » Tue Mar 20, 2012 18:31

Hi,

You're amazing,

But you can build a mod ?

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

Good Jobs.
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Tue Mar 20, 2012 18:47

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.
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33

by sdzen » Fri Mar 23, 2012 19:07

now all we need is for it to be picked up when you step on it!
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Mar 23, 2012 19:24

+1
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Fri Mar 23, 2012 19:34

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.
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33

by sdzen » Fri Mar 23, 2012 21:11

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
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Sun Mar 25, 2012 20:42

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.
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Sun Mar 25, 2012 21:11

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! ;)
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Sun Mar 25, 2012 21:32

I think Jeija's mesecon code could help us here...
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 07:07

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
Last edited by cornernote on Mon Jul 30, 2012 07:20, edited 1 time in total.
 

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

by PilzAdam » Mon Jul 30, 2012 09:17

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.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 09:41

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?
 

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

by PilzAdam » Mon Jul 30, 2012 09:56

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.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 10:11

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.
 

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

by PilzAdam » Mon Jul 30, 2012 10:14

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,
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 10:19

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?
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 10:21

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
 

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

by PilzAdam » Mon Jul 30, 2012 10:23

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)?
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 10:24

you should come in IRC, easier to chat =)
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 10:27

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)!
 

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

by PilzAdam » Mon Jul 30, 2012 10:38

cornernote wrote:you should come in IRC, easier to chat =)

Im on.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 10:38

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)
 

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

by PilzAdam » Mon Jul 30, 2012 10:42

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.
 

Lelix
Member
 
Posts: 94
Joined: Sat Apr 14, 2012 12:51

by Lelix » Mon Jul 30, 2012 15:22

finalmente sei ritornato!
 

User avatar
LolManKuba
Member
 
Posts: 939
Joined: Fri Feb 10, 2012 22:36

by LolManKuba » Mon Jul 30, 2012 17:17

Lelix wrote:finalmente sei ritornato!

Only use other languages on the other languages sub forum
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 131 guests