Page 1 of 1

How to make things walkthrough-able?

PostPosted: Mon Feb 13, 2012 20:01
by Lunarhiro
Say if I want to make like, a portal or what not, how would I make the lil portal bits so that you can walk through it?

I just started with lua scripting...and have been looking at some mods, and they all use node, but you can't walk through nodes...can you?

PostPosted: Mon Feb 13, 2012 20:10
by Jeija
Yes, you can walk through nodes.
Just add this to your node definition:

walkable = false,

PostPosted: Mon Feb 13, 2012 20:19
by Lunarhiro
Oh thank you! Now one more question...I been messin wit it only for like an hour now, but think I'm understanding a bit now.

I'm currently looking through more_ores mod and have stumbled across this...

Edited this part: Alright good thanks guys for this, but theres still more under this now! :/

and how could I make it so I could obtain the node upon hitting it once with anything? O.e

Sorry, working on a flower mod so thats why I asked for the walkthrough as well. xD

This is what I got so far... still need help though xD

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
--[[
****
Flowers
by Lunarhiro
Version 1.0
****
--]]

-- Flowers

minetest.register_node( "flowers:flowers_flower_red", {
    description = "Red Flower",
    tile_images = { "flowers_flower_red.png" },
    walkable = false,
    inventory_inventory_image = minetest.inventorycube( "flowers_flower_red.png" ),
    is_ground_content = true,
    material = minetest.digprop_constanttime(0.5),
    drop = 'craft "flowers:flowers_flower_red" 1',
})




-- Items

minetest.register_craftitem( "flowers:flowers_flower_red", {
    description = "Red Flower",
    inventory_image = "flowers_flower_red.png",
    on_place_on_ground = minetest.craftitem_place_item,
})


Now I also...need to know, how can I make it spawn on top of grass? And how can I place the flower like if it was an actual ...well node? When I right click to drop it, it just falls down onto the floor like if I dropped iron or something xD. Thanks ;D

PostPosted: Mon Feb 13, 2012 21:08
by sdzen
its simple drop is what will go into your inventory
sorry if ive double posted i left this one mid response

PostPosted: Mon Feb 13, 2012 21:14
by kahrl
BTW, the way the drop line is written is outdated, it should be written like this in the newest version of minetest:
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
drop = 'flowers:flowers_flower_red 1'


EDIT: And it's inventory_image, not inventory_inventory_image. Are you sure you want to have an inventorycube there?

PostPosted: Mon Feb 13, 2012 21:17
by Lunarhiro
kahrl wrote:BTW, the way the drop line is written is outdated, it should be written like this in the newest version of minetest:
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
drop = 'flowers:flowers_flower_red 1'



Yea, I figured that part on my own after it failed to load the game, and told me to check the debug.txt.

It said "no name: or ":"" provided...or something like that, so I looked around in other mods and found that, but still have trouble with spawning it on grass terrains and being able to place it. Sorry, I'm a newb to lua xD...and c...and all that other stuff. Just okay at Sadscripting O.e

PostPosted: Mon Feb 13, 2012 21:19
by sdzen
kahrl wrote:BTW, the way the drop line is written is outdated, it should be written like this in the newest version of minetest:
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
drop = 'flowers:flowers_flower_red 1'


EDIT: And it's inventory_image, not inventory_inventory_image. Are you sure you want to have an inventorycube there?

yeah i spotted that but didnt know if for some reason it was intentional
Edit I never post in time! :(

PostPosted: Mon Feb 13, 2012 21:21
by kahrl
OK, the spawning part is a bit tricky. Do you want them to be generated during world generation or should they grow randomly later on? You'd do the first with an on_generated callback and the second using ABMs. Perhaps you could look how the existing flowers mod does it, I think it also has some algorithm that prevents too many flowers from spawning next to each other.

PostPosted: Mon Feb 13, 2012 21:23
by Lunarhiro
Randomly appearing, that way they can always appear wherever, but on grass. Hm, So Ima get the mod and see what I figure out, if anything xD. Should I repost what I fixed and did to the whole script?

Edit:
o.e oh god, looking at all 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 grow_blocks_on_surfaces = function(growdelay, grownames, surfaces)
    for _, surface in ipairs(surfaces) do
        minetest.register_abm({
            nodenames = { surface.name },
            interval = growdelay,
            chance = 30,
            action = function(pos, node, active_object_count, active_object_count_wider)
                local p_top = {
                    x = pos.x,
                    y = pos.y + 1,
                    z = pos.z
                }
                local n_top = minetest.env:get_node(p_top)
                local rnd = math.random(1, MAX_RATIO)

                if (MAX_RATIO - surface.chance < rnd) then
                    local flower_in_range = is_node_in_cube(grownames, p_top, surface.spacing)
                    if (n_top.name == "air") and (flower_in_range == false) then
                        local nnode = grownames[math.random(1, #grownames)]
                        dbg('Adding node ' .. nnode .. ' ('
                            .. pos.x .. ', '
                            .. pos.y .. ', '
                            .. pos.z .. ')')
                        minetest.env:add_node(p_top, { name = nnode })


Kinda hurts not knowing what the hell is going on LOL xD. Im'a eventually figure this out with you guys helping like you are thankfully...unlike where I learned sadscripting where people would turn a cold shoulder...learned it mostly alone...and ended up teaching some. xD