Forum

> > CS2D > Scripts > [Solved] Dispenser spawnitem system requirement
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch [Solved] Dispenser spawnitem system requirement

12 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Zitieren
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.
2× editiert, zuletzt 23.06.23 10:42:18

alt Re: [Solved] Dispenser spawnitem system requirement

Masea
Super User Off Offline

Zitieren
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?

alt Re: [Solved] Dispenser spawnitem system requirement

Gaios
Reviewer Off Offline

Zitieren
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.

alt Re: [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Zitieren
user Masea hat geschrieben
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.

alt Re: [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Zitieren
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.
1× editiert, zuletzt 23.06.23 10:42:57

alt Re: [Solved] Dispenser spawnitem system requirement

Gaios
Reviewer Off Offline

Zitieren
user Mora hat geschrieben
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.

Mehr >

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.

Mehr >
1× editiert, zuletzt 22.06.23 16:51:25

alt Re: [Solved] Dispenser spawnitem system requirement

Mora
User Off Offline

Zitieren
@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
1× editiert, zuletzt 22.06.23 18:33:50
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht