Forum

> > CS2D > Scripts > [Solved] Dispenser spawnitem system requirement
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Solved] Dispenser spawnitem system requirement

12 replies
To the start Previous 1 Next To the start

old [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Quote
The title says, I'll explain:
I need the function that used for spawnitem in dispenser, I need to recognize which spawnitem is has IID, to remove it or to use it.
I'm making custom buildings and I wanna make custom dispenser which spawns snowballs, for example instead primary/secondary-ammo, and no more than 2 for 9-tiles around the specific dispenser id, but depending on dispenser.-> since two dispensers, T and CT might be spawned near each other and somehow primary/secondary-ammo is spawned in limits of 1 for each item.

Supply/teleport/turret pattern/working way/behavior functions/methods will be appreciated in comments.
edited 2×, last 23.06.23 10:42:18 am

old Re: [Solved] Dispenser spawnitem system requirement

Masea
Super User Off Offline

Quote
You should create your whole custom building system with all the requirements you need to meet. Disable the wrench building menu (or override it with your own if possible) altogether. Create buildings via code and put images over them to hide their actual textures (see file cs2d CS2D Minecraft Mod for reference). When you create a building via code, you'd also know its position, so you can save it and more data to your own table variable. You can also listen to events such as building damage, upgrade, kill, and so on with multiple hooks. Following that, with your own variables, you can easily manipulate whatnot - spawn items around buildings, spawn more and betters items around "upgraded" buildings, and more.

By the way, your English used to be better. What happened?

old Re: [Solved] Dispenser spawnitem system requirement

Gaios
Reviewer Off Offline

Quote
Obtain a list of all items on the map, filter for primary and secondary ammo, scan for dispenser buildings nearby, and remove the ammo that is in close proximity to the dispenser buildings. It's not CPU efficient anyway.

old Re: [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Quote
user Masea has written
You should create your whole custom building system with all the requirements you need to meet. Disable the wrench building menu (or override it with your own if possible) altogether. Create buildings via code and put images over them to hide their actual textures (see file cs2d CS2D Minecraft Mod for reference). When you create a building via code, you'd also know its position, so you can save it and more data to your own table variable. You can also listen to events such as building damage, upgrade, kill, and so on with multiple hooks. Following that, with your own variables, you can easily manipulate whatnot - spawn items around buildings, spawn more and betters items around "upgraded" buildings, and more.

By the way, your English used to be better. What happened?

About english - Idk I was drunk while writing this post.

About buildings yeah, that's right what I do:
https://youtu.be/-fH8aLUDdNQ

@user Gaios: will try. I remember making custom weapons for my stalker mod which sent itemID on drop(cuz drop hook has itemID).
I'm using wall object instead of Dispenser so I don't need to removeitem.

old Re: [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Quote
I need the function or method of Dispenser's itemspawn and the way it store items and how it doesn't spawn more than 1 primary and 1 secondary ammo around. Same with supply.

I need it because spawnitem does not return spawned itemID so I couldn't store it to prevent spawning next time if the stored item table is full.

@user Bowlinghead: Made gfx by myself.
edited 1×, last 23.06.23 10:42:57 am

old Re: [Solved] Dispenser spawnitem system requirement

Gaios
Reviewer Off Offline

Quote
user Mora has written
I need the function or method of Dispenser's itemspawn and the way it store items and how it doesn't spawn more than 1 primary and 1 secondary ammo around. Same with supply.

I need it because spawnitem does not return spawned itemID so I couldn't store it to prevent spawning next time if the stored item table is full.

More >

The next step that you need to take is to store all the items you have spawned inside the dispenser code in an array. You should remove items from the array when the walkover event occurs. To determine which dispenser spawned a particular item, you have the buildingId.

More >
edited 1×, last 22.06.23 04:51:25 pm

old Re: [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Quote
@user Masea: Yeah, hudtxt and always things might be shown in the any other, easier method. Currently I made it like that because mostly made accent on what I imagine, then I surely will try to make it more optimized if I can(cuz im noobish coder tho).

@user Gaios:
1
2
3
4
parse('spawnitem '..itemId..' '..tileX..' '..tileY)

    local itemIds = item(0, 'table')
    local id = itemIds[#itemIds]

Would it not lead to the consequence when You have
itemIds{1,2,3,4}, and when u take 3'rd item would it not fill 3-rd slot or it will be like that:
itemIds{1,2,4,3}?

Always want to learn OOP in lua but idk why still can not learn it lowiq
edited 1×, last 22.06.23 06:33:50 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview