Page 1 of 1

I have a Problem to put two variables in one

PostPosted: Mon Jan 21, 2013 12:22
by yves_de_beck
Hallo all,

Perhaps someone have an idea to fix my problem:

I make some experiments with the nodebox value.


I want make from two variables one:

My Example:
variable1 = {abcabc}
variable2 = {xyzxyz}

varibalenew = variable1 variable2

--> output of 'variablenew' should be -> {abcabc}{xyzxyz}

I have tryed all. It won't work =(



this is my 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
math.randomseed(os.time())
local detail = 16
local testnoc = {}
local testbox1 = {}
local testbox2 = {}

for i = 0, detail-1 do
    hoehe = math.random (0,5)
    testbox1[i+1]={-0.5, -0.5, (i/detail)-0.5, -0.5+(1/detail), hoehe*0.1, (i/detail)-0.5+(1/detail)}
    hoehe = math.random (0,5)
    testbox2[i+1]={-0.5+(1/detail), -0.5, (i/detail)-0.5, -0.5+(2*(1/detail)), hoehe*0.1, (i/detail)-0.5+(1/detail)}
end


local testbox = testbox1, testbox2   


minetest.register_node("test:test_object2", {
    description = "TEST OBJECT2",
    drawtype = "nodebox",
    tiles = {"default_desert_sand.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    walkable = true,
    selection_box = {
        type = "fixed",
        fixed = {-0.5,-0.5,-0.5,0.5,0.5,0.5},
    },
    node_box = {
        type = "fixed",
        fixed = testbox,
    },
    groups = {snappy=1,choppy=2,oddly_breakable_by_hand=3,flammable=2},
})



Now it works without an error, but in the var 'testbox' is only the value of 'testbox1'.

Wat i'm doing wrong???

PostPosted: Mon Jan 21, 2013 12:27
by kaeza
Try 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
math.randomseed(os.time())
local detail = 16
local testnoc = {}
local testbox = {}

for i = 0, detail-1, 2 do
    hoehe = math.random (0,5)
    testbox[i+1]={-0.5, -0.5, (i/detail)-0.5, -0.5+(1/detail), hoehe*0.1, (i/detail)-0.5+(1/detail)}
    hoehe = math.random (0,5)
    testbox[i+2]={-0.5+(1/detail), -0.5, (i/detail)-0.5, -0.5+(2*(1/detail)), hoehe*0.1, (i/detail)-0.5+(1/detail)}
end

minetest.register_node("test:test_object2", {
    description = "TEST OBJECT2",
    drawtype = "nodebox",
    tiles = {"default_desert_sand.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    walkable = true,
    selection_box = {
        type = "fixed",
        fixed = {-0.5,-0.5,-0.5,0.5,0.5,0.5},
    },
    node_box = {
        type = "fixed",
        fixed = testbox,
    },
    groups = {snappy=1,choppy=2,oddly_breakable_by_hand=3,flammable=2},
})

PostPosted: Mon Jan 21, 2013 12:40
by yves_de_beck
kaeza wrote:Try 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
math.randomseed(os.time())
local detail = 16
local testnoc = {}
local testbox = {}

for i = 0, detail-1, 2 do
    hoehe = math.random (0,5)
    testbox[i+1]={-0.5, -0.5, (i/detail)-0.5, -0.5+(1/detail), hoehe*0.1, (i/detail)-0.5+(1/detail)}
    hoehe = math.random (0,5)
    testbox[i+2]={-0.5+(1/detail), -0.5, (i/detail)-0.5, -0.5+(2*(1/detail)), hoehe*0.1, (i/detail)-0.5+(1/detail)}
end

minetest.register_node("test:test_object2", {
    description = "TEST OBJECT2",
    drawtype = "nodebox",
    tiles = {"default_desert_sand.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    walkable = true,
    selection_box = {
        type = "fixed",
        fixed = {-0.5,-0.5,-0.5,0.5,0.5,0.5},
    },
    node_box = {
        type = "fixed",
        fixed = testbox,
    },
    groups = {snappy=1,choppy=2,oddly_breakable_by_hand=3,flammable=2},
})




Wooooow thank you for the very fast answer kaeza!!!! =) =)

I've tested it.... and it works.

Super!!

PostPosted: Mon Jan 21, 2013 13:05
by kaeza
yves_de_beck wrote:Wooooow thank you for the very fast answer kaeza!!!! =) =)

I've tested it.... and it works.

Super!!

You're welcome :)