voxel / voxel-inventory-creative

inventory dialog with an infinite supply of all items and blocks (voxel.js plugin)
5 stars 2 forks source link

Infinite Items #5

Open z3t0 opened 9 years ago

z3t0 commented 9 years ago

Items in the creative inventory should not be infinite, instead they should be stacks because when you change modes back to survival, you still have an infinite block

z3t0 commented 9 years ago

Trying to figure out which part of https://github.com/deathcap/voxel-use/blob/master/use.coffee#L61-L86 Changes the number of the item/block held. I cant seem to figure out what subtracts the item number?

deathcap commented 9 years ago

    taken = held.splitPile(1)
z3t0 commented 9 years ago

I am trying to add the eventemitter to voxel-gamemode but cannot figure out how to do so. I want it to be able to emit, I gave it

inherits(Gamemode, EventEmitter)

but that won't work... I managed to get this working on voxel-console but not this

z3t0 commented 9 years ago

Here's what I am trying to do. https://gist.github.com/z3t0/f2fe3f291d1ec49bbab1

z3t0 commented 9 years ago

The @on parts never seem to run, but there are no errors

z3t0 commented 9 years ago

ok.. super noob mistake... dont ask what lol.

z3t0 commented 9 years ago

This is almost done and will be commited soon

deathcap commented 9 years ago

For the class inheritance, since this is CoffeeScript you should be able to just do class Gamemode extends EventEmitter instead of using the inherits module, I believe.

As for this issue, I half-agree with the premise. I think infinite item piles could still be useful in some situations, even survival. For example, for comparison in Minecraft, there may be adventure maps or mini-games with items from infinite dispensers or chests full of items you can use infinitely many times, to some end (I think these are implemented in MC with an item count of 0 or -1, not sure exactly, but in voxel.js itempile as its JavaScript I allow the actual Infinity value).

On the other hand, I could see how it could be useful to, by default, pickup a finite-sized pile from the creative inventory. Haven't tested https://github.com/deathcap/voxel-inventory-creative/pull/6 yet but ideally both would be possible. Not sure of the best way to handle this user interaction, but the way I see it, from the inventory window it should be possible to pickup: infinite piles, maximum pile size (usually 64), one item.

Another consideration is that in creative mode, your item blocks still deplete when placed in the world. In MC, you can have a stack of 1 dirt, place it, and you still have it; not so in voxel.js / voxel-use, where it is consumed, same in creative or survival mode. The way I got around this was having infinite-sized piles, but this does introduce the behavior you've noticed where they behave infinite in both modes. Unsure of the best solution here, but I think it requires further design to take into account these considerations.

z3t0 commented 9 years ago

Hmm. Right I am thinking of having a canKeep variable which can be set to true, so inventory items are not infinite but also do not deplete.

z3t0 commented 9 years ago

For the class inheritance, since this is CoffeeScript you should be able to just do class Gamemode extends EventEmitter instead of using the inherits module, I believe.

Thanks I managed to get events working.

chests full of items you can use infinitely many times

Why not just make the item number not deplete? That is much easier to maintain because we can have a simple setting to keep items which can be controlled.

itempile as its JavaScript I allow the actual Infinity value

I don' think having an Infinity value is a good idea because it becomes hard to manage.

Not sure of the best way to handle this user interaction, but the way I see it, from the inventory window it should be possible to pickup: infinite piles, maximum pile size (usually 64), one item.

What would be the use of having an infinity item? I just see this as hard to maintain. Do we currently have a way to pickup only one item? If not I can work on that.