[solved]bad eyes, cant find the problem, need help pls

User avatar
tkerwel
Member
 
Posts: 213
Joined: Fri Jan 13, 2012 07:35

[solved]bad eyes, cant find the problem, need help pls

by tkerwel » Fri Jan 27, 2012 12:12

i always get a error

init.lua:488: ')' expected (to close '(' at line 444) near 'if'

i really blind and already starring since hours on this code, i cant figure out where is the mistake...

can somebody give me a hint....

code is:

minetest.register_on_placenode(function(pos, newnode, placer)

if newnode.name == "deko:deko_wallbase" then

--param.2 detects the state that this object is placed in and stores it
local state = newnode.param2

--this makes the game generate a random number
local i = math.random(1,4)

--removes the dekobase
if minetest.env:remove_node(pos) then

--this statement tells the game if it stops on this number this painting will be selected
if i==1 then

minetest.env:add_node(pos, {name="deko:deko_wallpaper1",param2=state})

end

if i==2 then

minetest.env:add_node(pos, {name="deko:deko_wallpaper2",param2=state})

end

if i==3 then

minetest.env:add_node(pos, {name="deko:deko_wallpaper3",param2=state})

end

if i==4 then

minetest.env:add_node(pos, {name="deko:deko_wallpaper4",param2=state})

end

end

end
end


if newnode.name == "deko:deko_shieldbase" then

--param.2 detects the state that this object is placed in and stores it
local state = newnode.param2

--this makes the game generate a random number
local i = math.random(1,4)

--removes the dekobase
if minetest.env:remove_node(pos) then


if i==1 then

minetest.env:add_node(pos, {name="deko:deko_shield1",param2=state})

end

if i==2 then

minetest.env:add_node(pos, {name="deko:deko_shield2",param2=state})

end

if i==3 then

minetest.env:add_node(pos, {name="deko:deko_shield3",param2=state})

end

if i==4 then

minetest.env:add_node(pos, {name="deko:deko_shield4",param2=state})

end

end
end

)
Last edited by tkerwel on Sun Jan 29, 2012 08:53, edited 1 time in total.
++++ Kung walang tiyaga, walang nilaga. ++++
 

User avatar
dannydark
Member
 
Posts: 428
Joined: Fri Aug 12, 2011 21:28

by dannydark » Fri Jan 27, 2012 14:07

can't see any error there could you paste the full init.lua into pastebin.com and I'll take another look for you.
 

User avatar
tkerwel
Member
 
Posts: 213
Joined: Fri Jan 13, 2012 07:35

by tkerwel » Fri Jan 27, 2012 14:17

okay... hope this works

here schould be the init.lua http://pastebin.com/uMjdDPLz

i guess somewhere i miss a ( or a ) ... or put one to much... starting somewhere behind line 444 ..
Last edited by tkerwel on Fri Jan 27, 2012 14:18, edited 1 time in total.
++++ Kung walang tiyaga, walang nilaga. ++++
 

User avatar
dannydark
Member
 
Posts: 428
Joined: Fri Aug 12, 2011 21:28

by dannydark » Fri Jan 27, 2012 14:21

Ahh wait sorry I just re-read your original post and noticed you have 1 too many end's in the top if statement.

Sorry for getting you to pastebin the full code ^_^ lol

EDIT: Sorry I meant top if statement the "if newnode.name == "deko:deko_wallbase" then" one ^_^

EDIT2: So basically replace the code you pasted in your first post with 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
minetest.register_on_placenode(function(pos, newnode, placer)
    if newnode.name == "deko:deko_wallbase" then
        --param.2 detects the state that this object is placed in and stores it
        local state = newnode.param2

        --this makes the game generate a random number
        local i = math.random(1,4)

        --removes the dekobase
        if minetest.env:remove_node(pos) then
            --this statement tells the game if it stops on this number this painting will be selected
            if i==1 then
                minetest.env:add_node(pos, {name="deko:deko_wallpaper1",param2=state})
            end

            if i==2 then
                minetest.env:add_node(pos, {name="deko:deko_wallpaper2",param2=state})
            end

            if i==3 then
                minetest.env:add_node(pos, {name="deko:deko_wallpaper3",param2=state})
            end

            if i==4 then
                minetest.env:add_node(pos, {name="deko:deko_wallpaper4",param2=state})
            end
        end
    end

    if newnode.name == "deko:deko_shieldbase" then
        --param.2 detects the state that this object is placed in and stores it
        local state = newnode.param2

        --this makes the game generate a random number
        local i = math.random(1,4)

        --removes the dekobase
        if minetest.env:remove_node(pos) then
            if i==1 then
                minetest.env:add_node(pos, {name="deko:deko_shield1",param2=state})
            end

            if i==2 then
                minetest.env:add_node(pos, {name="deko:deko_shield2",param2=state})
            end

            if i==3 then
                minetest.env:add_node(pos, {name="deko:deko_shield3",param2=state})
            end

            if i==4 then
                minetest.env:add_node(pos, {name="deko:deko_shield4",param2=state})
            end
        end
    end
end)


EDIT3: Oh also you where missing an end from the end of your function, I've updated my pasted version above. I also cleaned up your indentation ^_^ sorry lol.

Sorry about all the edits I'm back and forth between work ^_^
Last edited by dannydark on Fri Jan 27, 2012 14:40, edited 1 time in total.
 

User avatar
tkerwel
Member
 
Posts: 213
Joined: Fri Jan 13, 2012 07:35

by tkerwel » Fri Jan 27, 2012 15:09

@dannydark

10000000000000000000000000000 times thank to you...

i really hat hurting eyes and could not see the "end" in the forrest of "end's" anymore...

now its working, just a mistake with the textures of the added shields... only one has full transparency ...
++++ Kung walang tiyaga, walang nilaga. ++++
 

User avatar
dannydark
Member
 
Posts: 428
Joined: Fri Aug 12, 2011 21:28

by dannydark » Fri Jan 27, 2012 16:27

Haha no problem mate glad I could help, btw one thing that helps with situations like this is correct indentation on your code ^_^ plus using correct code indentation should also improve your writing speed :D
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 28 guests

cron