Re: Some Plugins

I can't test this, and honestly I have no idea as Im more an artist too ( learning as I go with coding), but what if you put a space between , and 3 ?

Were you getting any errors with it uncommented ? I thought I'd weight in on this, having no idea how long com3d might be offline, etc.

cu
nl

Re: Some Plugins

marval wrote:

but the 3 balls only rotates when I turn off the speed property

Turning off the speed property has not effect, as you don't use this variable in your script

marval wrote:

       rotate(ball.objs[j], {0, 0, -1}, 1)

The balls rotate because that's what you ask them to do!
You used the "rotate" function. If you want to translate them then you can use the "translate" function for example.

You will find the function that suits your needs herewink

Last edited by com3D (2013-07-30 06:04:32)

Re: Some Plugins

heartseed wrote:

what if you put a space between , and 3 ?

Spaces, tabulations, returns... are not relevant in lua, you can use them as much as you want to organise your code. wink

Re: Some Plugins

let me explain better
the balls were spinning before including the speed property table
but stopped running after adding it
and for testing I disabled it and it worked again

Re: Some Plugins

OK, add a comma (,) at the end of the objs line. Speed is the second value of the player table (player={objs, speed}).

      objs = {getObject("ball1"),getObject("ball2"),getObject("ball3")},
      speed = {-0.4, -2 ,3}

And if you comment speed then remove the comma as there's only one value (objs)  in the player table.

      objs = {getObject("ball1"),getObject("ball2"),getObject("ball3")}
      --speed = {-0.4, -2, 3}

Last edited by com3D (2013-07-30 12:26:44)

Re: Some Plugins

sorry
I forgot the commas
it worked
Now I'll test with some of the functions
thanks

Re: Some Plugins

hi,
in this case,using getClone example,where to set the speed variable table for each clone?

object = getObject("object")
cloneList = {}
 
for j=1, 3 do
    table.insert(cloneList, #cloneList + 1, getClone(object))
end

   for j=1, #cloneList do
       rotate(cloneList[j], {0, 0, 1}, 1, "local")
   end

Last edited by marval (2013-08-08 03:03:12)

Re: Some Plugins

You just have to create the speed table :

object = getObject("object")
cloneList = {}
speedList = {0.4, 0.3, 1}
  
for j=1, 3 do
    table.insert(cloneList, #cloneList + 1, getClone(object)) 
end

   for j=1, #cloneList do 
       rotate(cloneList[j], {0, 0, 1}, speedList[j], "local")
   end

Last edited by com3D (2013-08-08 05:24:05)

Re: Some Plugins

hi,
outside the cloneList?
if there are other lists just put the variables outside and below the corresponding list?

Re: Some Plugins

Yes, outside.
You can add any lists of parameters as you want. Just create a new table. For example :

object = getObject("object")
cloneList = {}
rotationSpeedList = {0.4, 0.3, 1}
translationSpeedList = { {1, 0.1, 0.1}, {2, 0.3, 3}, {3, 2, 1} }

for j=1, 3 do
    table.insert(cloneList, #cloneList + 1, getClone(object)) 
end

   for j=1, #cloneList do 
       rotate(cloneList[j], {0, 0, 1}, rotationSpeedList [j], "local")
       translate(cloneList[j], {translationSpeedList[j][1], translationSpeedList[j][2], translationSpeedList[j][3]}, "local")
   end

Re: Some Plugins

if i have a enemy cloneList and a turret cloneList and both with a parameter with
the same name : life

enemy = getObject("enemy")
enemyCloneList = {}
life = {100,100,100}
for j=1, 3 do
    table.insert(enemyCloneList, #enemyCloneList + 1, getClone(enemy))
end

turret = getObject("turret")
turretCloneList = {}
life = {100,100,100}
for k=1, 3 do
    table.insert(turretCloneList, #turretCloneList + 1, getClone(turret))
end

is this parameter with the same name associated with the "correct" corresponding cloneList just for being right below it?

Last edited by marval (2013-08-08 13:34:52)

Re: Some Plugins

A table is identified by its name. If you declare it more than once, you simply update its content.

So if life is sharable between enemie & turrets, you just have to declare it once before using it. You can declare it anywhere as long as it is before using its content.

If life is a different parameter for enemies & turrets or if the number of parameters is different (for example number of turrets and number of enemies are not necessarily the same), then you should create a new table for each set of parameters. Again, you can declare this set anywhere before using its content.

What links tables is not the way they are coded but the way they are used :

rotate(cloneList[j], {0, 0, 1}, rotationSpeedList [j], "local") -- use rotationSpeedList parameters with clones
rotate(turretList[j], {0, 0, 1}, rotationSpeedList [j], "local") -- use rotationSpeedList parameters with turrets

Re: Some Plugins

ok,thanks

in your first example the objects and speed parameter list were created inside the player list,using commas at the end and you must use the point access to each parameter

player = {
objs = {getObject("player1"), getObject("player2")},
speed = {-0.4, -2},
}

for j=1, #player.objs do
        translate(player.objs[j], {0,player.speed[j],0}, "local")
        if player.speed[j] > 3 then player.speed[j] = 3 end
    end

which is quite different from the getClone example
is there any difference between choosing to use one of these methods?

Re: Some Plugins

Basically these examples are quiet similar. There's an infinity of ways to achieve the same goal.
In the first example, we could have also done:

players = { {getObject("player1"), -0.4}, {getObject("player2"), -2} } -- table structure is {object, speed}

which is exactly the same.

With the getClone example, after having created the cloneList, we could have done exactly as in the first example:

object = getObject("object")
cloneList = {}

for j=1, 3 do
    table.insert(cloneList, #cloneList + 1, getClone(object)) 
end

player = {
objs = {cloneList[1], cloneList[2]}, 
speed = {-0.4, -2},
}

In fact it is the complexity and versatility that dictates the best solution.
With experience you will easily find it.
Don't try to rigidly replicate some piece of code. Understand the logic and translate it into some code that makes sense for you (clear and customizable).

Last edited by com3D (2013-08-08 17:49:02)

Re: Some Plugins

hi,ok
I prefer the method using the point to access the attribute
Thanks com3D!