Chaos Posted June 27, 2013 Posted June 27, 2013 (edited) hi, i have a question how to make a multi colcuboid Zone2 = createColCuboid(-435.35120, 1127.09399, 64.77347, 89.786315917969, 138.08850097656, 31.516172409058) Zone3 = createColCuboid(-539.83765, 1099.35901, -0.24455, 63.918670654297, 108.96557617188, 26.398180007935) Zone4 = createColCuboid(-478.33630, 1126.67896, 1.00000, 89.334411621094, 38.739135742188, 79.651779174805) Zone5 = createColCuboid(-354.53192, 1107.53027, 69.47218, 48.932952880859, 113.24426269531, 23.160528182983) Zone6 = createColCuboid(-305.90366, 929.78162, 66.37509, 44.974731445313, 177.42919921875, 29.443685531616) Zone7 = createColCuboid(-305.33679, 1107.58313, 65.53906, 16.306518554688, 114.54858398438, 27.093648910522) Zone8 = createColCuboid(-316.93121, 1054.64819, 65.19218, 55.719940185547, 52.712158203125, 8.1574993133545) should i make a table ? Edited June 27, 2013 by Guest
xXMADEXx Posted June 27, 2013 Posted June 27, 2013 What do you mean? You could make a table, or just do it how it currently is..
Chaos Posted June 27, 2013 Author Posted June 27, 2013 how to make it table can you give me an example
xXMADEXx Posted June 27, 2013 Posted June 27, 2013 how to make it table can you give me an example It would be something like this local Colshape = { } local ColShapes = { { THE COLSHAPE ARGUMENTS HERE }, { 0, 20, 200, 200, 200, 50 } -- The example } for i,v in ipairs ( ColShapes ) do Colshape [ i ] = createColCuboid ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ] ) end
xXMADEXx Posted June 27, 2013 Posted June 27, 2013 and what about events how it will be? in the loop just do: addEventHandler ( "onColShapeHit, Colshape [ i ], function ( ) -- Use "source" for the colshape. end )
Chaos Posted June 27, 2013 Author Posted June 27, 2013 debug 17:unfinished string near ""onColShapeHit, Colshape [ i ],' local Colshape = { } local ColShapes = { { -435.35120, 1127.09399, 64.77347, 89.786315917969, 138.08850097656, 31.516172409058 }, { -539.83765, 1099.35901, -0.24455, 63.918670654297, 108.96557617188, 26.398180007935 }, { -478.33630, 1126.67896, 1.00000, 89.334411621094, 38.739135742188, 79.651779174805}, {-354.53192, 1107.53027, 69.47218, 48.932952880859, 113.24426269531, 23.160528182983}, {-305.90366, 929.78162, 66.37509, 44.974731445313, 177.42919921875, 29.443685531616}, {-305.33679, 1107.58313, 65.53906, 16.306518554688, 114.54858398438, 27.093648910522}, {-316.93121, 1054.64819, 65.19218, 55.719940185547, 52.712158203125, 8.1574993133545} -- The example } for i,v in ipairs ( ColShapes ) do Colshape [ i ] = createColCuboid ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ], v [7] ) end addEventHandler ( "onColShapeHit, Colshape [ i ], function ( ) outputChatBox("Welcome",source,0,255,0) end )
Vector Posted June 27, 2013 Posted June 27, 2013 You need to learn lua first local Colshape = { } local ColShapes = { { -435.35120, 1127.09399, 64.77347, 89.786315917969, 138.08850097656, 31.516172409058 }, { -539.83765, 1099.35901, -0.24455, 63.918670654297, 108.96557617188, 26.398180007935 }, { -478.33630, 1126.67896, 1.00000, 89.334411621094, 38.739135742188, 79.651779174805}, {-354.53192, 1107.53027, 69.47218, 48.932952880859, 113.24426269531, 23.160528182983}, {-305.90366, 929.78162, 66.37509, 44.974731445313, 177.42919921875, 29.443685531616}, {-305.33679, 1107.58313, 65.53906, 16.306518554688, 114.54858398438, 27.093648910522}, {-316.93121, 1054.64819, 65.19218, 55.719940185547, 52.712158203125, 8.1574993133545} -- The example } -- this could work. local dummy_element = createElement ("areas"); for i,v in ipairs ( ColShapes ) do Colshape [ i ] = createColCuboid ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ], v [7] ) setElementParent (Colshape [i], dummy_element); end addEventHandler ("onColShapeHit", dummy_element, function (hitElement) if getElementType (hitElement) == "player" then outputChatBox ("Welcome " .. getPlayerName (hitElement), 0, 255, 0); end; end);
Chaos Posted June 27, 2013 Author Posted June 27, 2013 (edited) i got this debug Edited June 27, 2013 by Guest
Vector Posted June 27, 2013 Posted June 27, 2013 it works fine for me. there is a little error when calling outputChatBox. outputChatBox ("Welcome " .. getPlayerName (hitElement), getRootElement (), 0, 255, 0); -> this works. local Colshape = { } local ColShapes = { { -435.35120, 1127.09399, 64.77347, 89.786315917969, 138.08850097656, 31.516172409058 }, { -539.83765, 1099.35901, -0.24455, 63.918670654297, 108.96557617188, 26.398180007935 }, { -478.33630, 1126.67896, 1.00000, 89.334411621094, 38.739135742188, 79.651779174805}, {-354.53192, 1107.53027, 69.47218, 48.932952880859, 113.24426269531, 23.160528182983}, {-305.90366, 929.78162, 66.37509, 44.974731445313, 177.42919921875, 29.443685531616}, {-305.33679, 1107.58313, 65.53906, 16.306518554688, 114.54858398438, 27.093648910522}, {-316.93121, 1054.64819, 65.19218, 55.719940185547, 52.712158203125, 8.1574993133545} -- The example } -- this could work. local dummy_element = createElement ("areas"); for i,v in ipairs ( ColShapes ) do Colshape [ i ] = createColCuboid ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ], v [7] ) setElementParent (Colshape [i], dummy_element); end addEventHandler ("onColShapeHit", dummy_element, function (hitElement) if getElementType (hitElement) == "player" then outputChatBox ("Welcome " .. getPlayerName (hitElement), getRootElement (), 0, 255, 0); end; end);
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now