Jump to content

[1.8.9] Switch contents between inventories on key press


LogicTechCorp

Recommended Posts

I have a scythe that can hold one item and a pouch that can hold nine items. I would like to swap the item in the scythe for the first item in the pouch, and move the items in the pouch up a slot and add the item from the scythe to the end. Which would be the best way to do this?

 

Side Note: I already have the key handler implemented

Link to comment
Share on other sites

I have a scythe that can hold one item and a pouch that can hold nine items. I would like to swap the item in the scythe for the first item in the pouch, and move the items in the pouch up a slot and add the item from the scythe to the end. I would like this to work on a custom key press which I have already implemented. Which would be the best way to do this?

Woah.

Thats a whole lot of switching and moving...

I think this is how I would do it:

1. Set the scythe to pouch and the pouch to the scythe.

2. Loop through the entire inventory of the pouch, and set the item to the slot before it by subtracting one from the slot number.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

I would opt for not moving anything at all - why not simply have the scythe hold an integer slot index for the pouch item? Or does the item have to exist in the scythe? Perhaps you could describe the concept in a little more detail?

I think what he means is that the scythe inventory is completely unrelated from the pouch inventory. But, when you press a certain key it switches the item that's stored in the scythe, and moves it over the to the end of the pouch. But that first item in the pouch is moved over to the scythe inventory. It then moves over all the original pouch items one slot, so the scythe item is at the end.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

I would opt for not moving anything at all - why not simply have the scythe hold an integer slot index for the pouch item? Or does the item have to exist in the scythe? Perhaps you could describe the concept in a little more detail?

I think what he means is that the scythe inventory is completely unrelated from the pouch inventory. But, when you press a certain key it switches the item that's stored in the scythe, and moves it over the to the end of the pouch. But that first item in the pouch is moved over to the scythe inventory. It then moves over all the original pouch items one slot, so the scythe item is at the end.

Exactly what starwarsmace stated.
Link to comment
Share on other sites

Right, I understood that's how you intend to implement it, but what exactly are you trying to do in terms of the game? I mean, why does the scythe move an item into the pouch? How are they related?

 

For example, in my mod I have several projectile weapons that can each use different ammo which can be selected from the player's current inventory, but instead of storing that item in the projectile weapon, I just store the selected ammo type's index and retrieve it when needed.

 

So, depending on what the relationship of the scythe and pouch is, you may not need to move things, is all I'm trying to say.

Link to comment
Share on other sites

Right, I understood that's how you intend to implement it, but what exactly are you trying to do in terms of the game? I mean, why does the scythe move an item into the pouch? How are they related?

 

For example, in my mod I have several projectile weapons that can each use different ammo which can be selected from the player's current inventory, but instead of storing that item in the projectile weapon, I just store the selected ammo type's index and retrieve it when needed.

 

So, depending on what the relationship of the scythe and pouch is, you may not need to move things, is all I'm trying to say.

 

To be honest, I really dont see why you would store something in a scythe and what a pouch would have anything to do with it.  :D

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

Right, I understood that's how you intend to implement it, but what exactly are you trying to do in terms of the game? I mean, why does the scythe move an item into the pouch? How are they related?

 

For example, in my mod I have several projectile weapons that can each use different ammo which can be selected from the player's current inventory, but instead of storing that item in the projectile weapon, I just store the selected ammo type's index and retrieve it when needed.

 

So, depending on what the relationship of the scythe and pouch is, you may not need to move things, is all I'm trying to say.

 

To be honest, I really dont see why you would store something in a scythe and what a pouch would have anything to do with it.  :D

 

The scythe will have a different ability based on the item/upgrade inside, reaping, tilling, healing etc. The pouch is so the player does not have to have their inventory cluttered with multiple upgrades.

Link to comment
Share on other sites

Ah, so they are like different blades or something to that effect that the player carries around in a pouch and swaps at will? Or should the upgrades be more like player abilities that they gain when finding / using special items? E.g. after consuming some kind of power-up the player can then channel that power through their scythe?

 

The reason I ask is because the implementation can be very different depending on exactly how you want it to play out. If they really are items that can be swapped in and out of the scythe on the fly, then sure, your idea of the implementation is fine, but if you only decided to use a pouch because you weren't sure how to implement your first idea (whatever that may have been), then I think we can do better.

 

Not knocking on the pouch idea, it just doesn't strike me as very intuitive from an in-game lore point of view (possibly due to not having the full back-story).

 

Anyway, regardless of how you decide to implement it, changing state (server-side) based on a key press (client-side) will require packets - do you have any experience with those?

Link to comment
Share on other sites

Ah, so they are like different blades or something to that effect that the player carries around in a pouch and swaps at will? Or should the upgrades be more like player abilities that they gain when finding / using special items? E.g. after consuming some kind of power-up the player can then channel that power through their scythe?

 

The reason I ask is because the implementation can be very different depending on exactly how you want it to play out. If they really are items that can be swapped in and out of the scythe on the fly, then sure, your idea of the implementation is fine, but if you only decided to use a pouch because you weren't sure how to implement your first idea (whatever that may have been), then I think we can do better.

 

The idea is similar to Thaumcraft's wands and foci.

 

Wand:

http://thaumcraft-4.wikia.com/wiki/Wands

 

Foci:

http://thaumcraft-4.wikia.com/wiki/Wand_Foci

 

Focus Pouch:

http://thaumcraft-4.wikia.com/wiki/Focus_Pouch

 

Anyway, regardless of how you decide to implement it, changing state (server-side) based on a key press (client-side) will require packets - do you have any experience with those?

 

I do not have any experience with packets.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.