Need help: Spawn actor and save all new spawned actor position (table?) how to
Darkpax
Member Posts: 22
Hey everybody I need help my idea is actor 1 spawns all 3 seconds an actor 2. The actor 2 spawns in random positions. My question is, how I save actor 2 position to table or anything ? I mean actor 2 spawns all3 seconds in another position and all positions should save. I need all positions to move to it with actor 3 in example , thanks for help
Comments
Create a game attribute called game.spawnOrder (integer).
Actor 1 needs to have Change Attribute game.spawnOrder to game.spawnOrder+1 immediately before the Spawn Actor behavior.
Actor 2 needs to have a self attribute called self.spawnOrder (integer). At the top of the actor's rule list, have Change Attribute self.spawnOrder to game.spawnOrder.
What that does is to increase game.spawnOrder by one each time Actor 2 is spawned and then Actor 2 assigns itself with that number. You can then use each Actor 2's self.spawnOrder to keep track of its position as follows:
Change Table Value
Table: [tableName]
row: self.spawnOrder
column: 1 value: self.position.X
column: 2 value: self.position.Y
Save Table [tableName]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
short example what i mean:
actor 1 spawns actors 2.
actor 3 should move to all actors 2 and destroy it (attribute pack +1)
actor 3 move back to farm and for all packs i become money. 1= 100 2=100*2 or so...
after become money actor 3 should move to another actor 2 and so on.
and this should go automatic.
look command and conquer for example with erz mining (red alert 1)
thanks for every help have a nice day
my stuff to move actor 3 doesnt work with more actors (actor 2) .
i make:
rule: game.spawnorder greater than 0,0
do:
timer every 1 seconds
do:
move to
position:
for X:table cell value(table name,1,1)
for Y:table cell value(table name,1,2)
table is new for me.
thanks
I would use Interpolate instead of Move To, but your rule should still work with Move To.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Log(Actor: name): runrule
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
Log(Actor: name): runtimer
endless ....
actor move to only one actor 2 most the first or second one .
to test i have make more actor 1 and all move to the first of all spawned actor 2
the actor 2 know what coordinates it has
but i make example too: display text:tablecellvalue(table name,1,1)this shows all time the same coordinate that the first actor 2 has spawn to(only on refresh another position )
how can i move to the other of that .
what do u mean with add the behaviors in bold above
thanks a lot
i make: display text:tablecellvalue(table name,1,1)
this shows all time the same coordinate that the first actor 2 has spawn to
(only on refresh another position )
how can i add the right coordinates from every actor (actor 2)
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Spawned actor
Add New Row [at end]
Change Attribute self.myRow to tableRowCount(tableName)
Then use self.myRow as the table row for all of your Change Table Value behaviors.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
example spawner spawns 3 actors (row count should now be 3) moveable actor move to one of this 3 (in same time it spawns more actors and new rows...)
movable actor collides with actor with row 2 in the table. now i would delete actor 2 and row 2 in table, to delete this positions .row count -1. a counter in example would go up +1
than movable actor move to an other actor with row 1 in example , and it should do the same. delete actor 1 and remove row 1 row count -1 .
but i dont know how this is the best ... thanks i learn from u very well
actor 2
When actor collides with [actor name]
.....Remove Row [at index: self.myRow]
Destroy Actor
Is the main actor going from actor to actor randomly or in the order that they were spawned? If it's in order, then you're right... you would change game.row to game.row-1 before the Destroy Actor behavior above.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
e.g. spawn 3 actors with IDs 1,2,3 and their rows in the table are 1,2 and 3 respectively.
#2 gets destroyed and row 2 is removed. If you don't adjust #3's ID, then when it tried to delete row 3, that row will not exist in the table.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I hasn t implement the move to spawned actors jet. I don t know how to move the actor to an self.myrow from an other actor.
I think the movable actor need automatically all positions from all spawned actors.
For now, its okay when the movable actor move randomly to the spawned one.
i has test this idea for move....
move to
x: table cell value(name),random(1,self.myrow),1
y: table cell value(name),random(1,self.myrow),2
but when i test that and the movable actor spawn from my house the game stop working. i have a seconds timer and that stopp and flare
Thanks.
Greetings from Germany
Also, put random expressions outside of the tableCellValue expression like this:
Change Attribute self.randomRow to random(1,tableRowCount(tableName))
Move To [x: tableCellValue(tableName,self.randomRow,1]
Move To [y: tableCellValue(tableName,self.randomRow,2]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Actor move to random spawned actor
I upload the file for other one.
Think I'm not alone with this.
@tatiang
how can i adjust all rows after remove a row
sorry many wonder ...
So if you have these rows:
A
B
C
D
E
And you delete row 4 ("D"), you end up with this:
A
B
C
E
Is that what you mean?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
2 remove 3 and4 must adjust but how to do
Thank u. The movable works okay
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
So when you delete a table row, you'll need to change an attribute that each actor uses for its row value.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
this is what i make now(funktion only by one spawned actor):
In the move actor a self random row integer.
in rule i make change attribute. self random row to random(1,tableRowCount(game.table)-1)
in spawned actor i make
add row at end
change attribute game.tablerowcount to game.tablerowcount +1
change attribute self.myrow to game.tablerowcount
change table value row: self.myrow
column 1 self.position X
column 2 self.position Y
save table
rule actor collides with actor of type (name)
add/remove row
remove row at index self.myrow
change attribute game.tablerowcount to game.tablerowcount -1
destroy actor
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
and this is the problem . this what i make is working with one spawning acot now , i dont understand how i adjust actors attribute to know what row are active in the table