manve1 Posted December 18, 2012 Posted December 18, 2012 I tried using unpack function for createObject and when i use the unpack function for marker it work, but it doesn't for createObject, so i need help to know how to make it: local lol = { { 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 } } local s = createObject(unpack(lol)) Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 for key, value in ipairs( lol ) do createObject( unpack( value ) ); end "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 ty Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 You're welcome. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 How can i get object's position? Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 You can save object elements in a table and get their position with getElementPosition. E.g. local pObjects = {}; local pTable = { { 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 }; }; for key, value in ipairs( pTable ) do pObjects[key] = createObject( unpack( value ) ); end -- local string = string.format( "Object's X: %d, Y: %d, Z: %d", getElementPosition( pObjects[1] ) ); outputChatBox( string, root, 255, 255, 255, false ); An easier way is: create the object inside the table. local pTable = { createObject( 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 ); }; "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 i got the table bit, but i haven't got how the getElementPosition should look, because when i try to get the objects position it just debugs bad argument Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 Show the code. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 alright, it worked, it might have been my mistake, but how can i attach a collision shape to an specific object? local collision = createColCuboid( 2493.25, -1675.25, 12.335947036743, 1.25, 2, 1 ) local string = string.format( "Object's X: %d, Y: %d, Z: %d", getElementPosition( present[1] ) ); attachElements( collision, present ) Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 Is present a table? You can't use a table as if it was an element, you must either call the object element by index or doing a for loop. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 yes, it is a table, so how could i make a loop? or get it by index? Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 You must either know the exact index ( number ) or create the objects with indexes as strings for easily get it, but then I don't know why would there be a table. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 Well, I want to make like from a table objects and i need them to have separate col shape, so when player hits it some stuff happens, but the problem is that when i try to attach them to each other i can't, and I'm using table because i will need to create loads of objects and i think that will speed up things ... and take a lot less space. local present = {} local gifts = { { 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 } } for key, value in ipairs( gifts ) do present[key] = createObject( unpack( value ) ); end local collision = createColCuboid( 2493.25, -1675.25, 12.335947036743, 1.25, 2, 1 ) local string = string.format( "Object's X: %d, Y: %d, Z: %d", getElementPosition( present[1] ) ); attachElements( collision, present ) ^ that's how the script is looking Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 Well, I want to make like from a table objects and i need them to have separate col shape, so when player hits it some stuff happens, but the problem is that when i try to attach them to each other i can't, and I'm using table because i will need to create loads of objects and i think that will speed up things ... and take a lot less space. local present = {} local gifts = { { 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 } } for key, value in ipairs( gifts ) do present[key] = createObject( unpack( value ) ); end local collision = createColCuboid( 2493.25, -1675.25, 12.335947036743, 1.25, 2, 1 ) local string = string.format( "Object's X: %d, Y: %d, Z: %d", getElementPosition( present[1] ) ); attachElements( collision, present ) ^ that's how the script is looking Use multi dimensional tables to store objects & its respective colshape arguments. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 sorry for asking, but what do you mean? Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 Create a table which will contain two tables: One with object function's arguments and one with its respective colshape arguments. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted December 18, 2012 Author Posted December 18, 2012 but, if i do something like this: local gifts = { objects = { { 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 }; }, colshapes = { { 2493.25, -1675.25, 12.335947036743, 1.25, 2, 1 }; } }; for key, value in ipairs( gifts.objects ) do present = createObject( unpack( value ) ); end for key, value in ipairs( gifts.colshapes ) do colshape = createColCuboid( unpack( value ) ); end I made it, but how i attach the object to col shape? Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted December 18, 2012 Posted December 18, 2012 but, if i do something like this: local gifts = { objects = { { 2289, 2494.0295410156, -1674.1334228516, 12.335947036743 }; }, colshapes = { { 2493.25, -1675.25, 12.335947036743, 1.25, 2, 1 }; } }; for key, value in ipairs( gifts.objects ) do present = createObject( unpack( value ) ); end for key, value in ipairs( gifts.colshapes ) do colshape = createColCuboid( unpack( value ) ); end I made it, but how i attach the object to col shape? No, not that. You create two tables inside ONE table, that's what is a multi dimensional table. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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