for statement problem

luciferleftwing
Member
 
Posts: 10
Joined: Tue Oct 23, 2012 14:21

for statement problem

by luciferleftwing » Mon Nov 12, 2012 06:37

ok so i was tring to add pillows in the form o stairsplus slabs made of wool i tried using a for cycle to irerate a list colors but all the colors i put in make the same slab and even in creative inventory it does not give me the other one
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
for index,color in pairs({'red','white'}) do
    local material="wool:"..color
    print(index)
    print(color)
    stairsplus.register_slab("wool", material,
            {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
            {"wool_"..color..".png"},
            "wool " ..color.." pillow",
            material)
    print(color)
    print(material)
end
 

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

by PilzAdam » Mon Nov 12, 2012 15:27

You have to use ipairs() to get the index and the value. With pairs() you get fieldname and value.
 

luciferleftwing
Member
 
Posts: 10
Joined: Tue Oct 23, 2012 14:21

by luciferleftwing » Mon Nov 12, 2012 19:20

thanks Adam but the real problem was that i forgot to link the subname parameter of the function to the loop so i was overwriting the same definition at each iteration
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 15 guests

cron