How do I Spawn random items from inventory

Get help using Construct 2

Post » Fri Jan 19, 2018 5:03 am

hi everyone, so i'm trying to spawn random items from what's in my inventory without any duplicates. I'm working with this capx but I will most likely have more slots... like 30. Is this something that can be done? any help would be great! Thanks

https://www.dropbox.com/s/vl30jbms1ucpf ... .capx?dl=0
B
37
S
17
G
9
Posts: 170
Reputation: 7,829

Post » Fri Jan 19, 2018 10:48 am

Hey mikewalton206,

with 'spawn item from inventory' you mean you want to drop an item from the inventory?

I made an example (had to made it with C3, so please use it to open the file):

c3p: https://1drv.ms/u/s!Ap_-qxoGKbDcd_xKj0E4FkdnXVI

Do not be surprised, I had to make some changes to make it work. If it does not fit into your game concept, please let me know.
B
9
S
2
G
1
Posts: 92
Reputation: 1,467

Post » Fri Jan 19, 2018 6:09 pm

kriand wrote:Hey mikewalton206,

with 'spawn item from inventory' you mean you want to drop an item from the inventory?

I made an example (had to made it with C3, so please use it to open the file):

c3p: https://1drv.ms/u/s!Ap_-qxoGKbDcd_xKj0E4FkdnXVI

Do not be surprised, I had to make some changes to make it work. If it does not fit into your game concept, please let me know.


Well yes and no... I want to spawn the actual inventory item onto the game level. Not just drop the item and not have it appear anyplace. I'm using this idea to actually do something else so I just need to be able to spawn the inventory items at random with no duplicates an then I can go from there and place the actual item where I want on the layout so basically like every X seconds I want to spawn at random one of the items from my inventory and place it for example on the middle of the layout.
B
37
S
17
G
9
Posts: 170
Reputation: 7,829

Post » Sat Jan 20, 2018 4:38 am

So you want to spawn a copy of one of the items from the inventory?
And what do you mean by "no duplicates"? Once one item is spawned, it can't be spawned again?
Here is one way to do this:
https://imgur.com/a/okN1n
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,393
Reputation: 84,413

Post » Sat Jan 20, 2018 9:57 pm

dop2000 wrote:So you want to spawn a copy of one of the items from the inventory?
And what do you mean by "no duplicates"? Once one item is spawned, it can't be spawned again?
Here is one way to do this:
https://imgur.com/a/okN1n


yes and no... I want to basically randomly drop one of the items from my inventory not make a copy onto the layout. lets say I pick up these... 4 blue items, two red items and 1green item. I right click and a red item drops someplace on the layout like the middle of the screen. now there's only 1 red item left. if I right click again... maybe this time a blue item drops and now there's only 3 blue items left. I right click again and this time I get another red item. now there's no more red items left in my inventory so all that I can randomly spawn now is 3 blue and 1 green item. The 2 red items are on the layout now. so basically there has to be something actually in my inventory for this to work so if my character doesn't pick up anything... no items can get randomly dropped.
B
37
S
17
G
9
Posts: 170
Reputation: 7,829

Post » Sun Jan 21, 2018 2:15 am

So basically take a random item from the inventory and drop it on the ground? You shouldn't have used the word "spawn", it usually means creating something new :)

Anyway, here is the code:
Image
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,393
Reputation: 84,413

Post » Sun Jan 21, 2018 3:13 am

dop2000 wrote:So basically take a random item from the inventory and drop it on the ground? You shouldn't have used the word "spawn", it usually means creating something new :)

Anyway, here is the code:
Image


:lol: :lol: :lol: yes this is true! sorry about that haha I know when it comes to game talk you need to say the correct words :) thanks! I'll test this out
B
37
S
17
G
9
Posts: 170
Reputation: 7,829


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests