Random Spawning

Hi all, new here - I just started digging into the salad and I wonder if anyone here could help.
In addition to my player, which I've already set up. I want to start my scene by spawning say 8 items randomly around the play area. These items will get destroyed so I'd like to replace/respawn some when their number drops below say 5.
I'm totally new and don't know where to start.
In addition to my player, which I've already set up. I want to start my scene by spawning say 8 items randomly around the play area. These items will get destroyed so I'd like to replace/respawn some when their number drops below say 5.
I'm totally new and don't know where to start.
Comments
Spawn actor random() in the x and y
Then make an attribute destroy number int 0
When the player overlpapaps or collide with any actor, add one to the attribute
When attribute is greater or equals to 3 you recycle the actors but you son't wnant to spawn thwem again
And don't respawn, check out some videos in the cookbook, I think there is a recycle actor video there
Calvin
Create 2 game attribute (integer) and call it something like SpawnedItem and NumberofItems
Then have an actor to take care of the spawning, have a rule inside;
If attribute game.NumberofItems < 5
Every x seconds
Change attribute SpawnedItem to Random(1,8) - access the random function by clicking on the little 'e' for the expression editor.
Then a rule that says;
If attribute game.SpawnedItem = 1
Spawn - Item1
Position X random (0,480) and Y (0,320) - Numbers depend on your screen area.
If attribute game.SpawnedItem = 2
Spawn - Item 2
Position X random (0,480) and Y (0,320) - Numbers depend on your screen area.
etc etc
Then on each of the items to be spawned
Change attribute game.NumberofItems to NumberofItems + 1
When item is destroyed, before the destroying behaviour have a change attribute game.NumberofItems to NumberofItems - 1