Page 1 of 1

[Help]Can someone Help me make a block move on its own

PostPosted: Tue Jul 24, 2012 23:31
by madchicken13
Im trying to make a mod where you can craft a block that moves on its own when set down on the ground
Its loading Now But what do i need to change to make it move on its own?
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_abm("movingblock:block", {
    movement = {default_gen=movement_gen,
    min_accel=0.4,
    max_accel=0.6,
    max_speed=2,
    pattern="run",   
    }                                                                               
})

minetest.register_node("movingblock:movingblock", {
    description = "moving block",
    tiles = {"block.png"},
    is_ground_content = true,
    groups = {cracky=1},
})       

minetest.register_craft({
    output = 'movingblock:block 3',
    recipe = {
        {'default:stick', 'default:stick', 'default:stick'},
    }
})       



print ("MoViNg_BlOcK mod loaded")   

Here is what i started:
http://modificationhelp.weebly.com/uploads/1/3/0/0/13008815/movingblock.zip

PostPosted: Wed Jul 25, 2012 01:47
by IPushButton2653
I think someone has done a mod that adds moving blocks. Just to prove a point. Why don't you check that out sometime? And you can submit your code to codepad.org and select LUA and it can check for errors

PostPosted: Wed Jul 25, 2012 09:24
by LocaL_ALchemisT
why do you want to make a block that can move? I tried it once for my monster mod, in the end it becomes a node eater. and yes it moves.

just use minetest.register_abm

PostPosted: Wed Jul 25, 2012 20:17
by madchicken13
Is this how the code should look like:
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_abm("movingblock:block", {
    movement = {default_gen=movement_gen,
    min_accel=0.4,
    max_accel=0.6,
    max_speed=2,
    pattern="run",   
    }                                                                               
})

minetest.register_node("movingblock:movingblock", {
    description = "moving block",
    tiles = {"block.png"},
    is_ground_content = true,
    groups = {cracky=1},
    }
})       

minetest.register_craft({
    output = 'movingblock:block 3',
    recipe = {
        {'default:stick', 'default:stick', 'default:stick'},
    }
})       



print ("MoViNg_BlOcK mod loaded")   

But its wont load it says something is wrong with line 10 and when it does load it sayd unknown Item

PostPosted: Wed Jul 25, 2012 20:47
by Menche
You have an extra curly brace:
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
    groups = {cracky=1},
    }
})       

Remove the second to last line in that selection. Consider using a text editor with syntax-highlighting, it makes catching those errors easier.

And I was making a mod for blocks that can be pushed, maybe look at my code? http://minetest.net/forum/viewtopic.php?id=2464

PostPosted: Thu Jul 26, 2012 00:29
by madchicken13
thnx for telling me the error but in\m trying to make my block move on its own

PostPosted: Thu Jul 26, 2012 07:59
by PilzAdam
Do you realy want a block or do you want a object (much better animation). Objects can move free but blocks can only move 1 block steps.

PostPosted: Thu Jul 26, 2012 08:59
by madchicken13
yea i want blocks to move whats the code?

PostPosted: Thu Jul 26, 2012 09:09
by PilzAdam
Something like this (not testet):
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_abm({
    nodenames = {"move:movingblock"},
    interval = 1,
    chance = 1,
    action = function(pos, node)
        minetest.env:remove_node(pos)
        pos.x = pos.x + 1
        minetest.env:set_node(pos, node)
    end
})

This will move the block in x+ direction. (Every block in the way will be destroyed so maybe you should check if theres air or a block.)

PostPosted: Thu Jul 26, 2012 09:21
by madchicken13
Thnx So Much

PostPosted: Thu Jul 26, 2012 09:58
by madchicken13
MonsterBlock Created it eats anything in its path