Skip to content

Conversation

@dastgirp
Copy link
Member

@dastgirp dastgirp commented Mar 9, 2019

Pull Request Prelude

Changes Proposed

getinventorylist now creates extra variable named @inventorylist_idx, which returns items corresponding
inventory index.
It would be useful for #2394

Example:

	getinventorylist();
	for (.@i = 0; .@i < @inventorylist_count; .@i++) {
		dispbottom(sprintf("Index %d: %s (%d)", @inventorylist_idx[.@i], getitemname(@inventorylist_id[.@i]), @inventorylist_id[.@i]), C_AQUA);
		if (@inventorylist_id[.@i] == Beret && @inventorylist_expire == 0) {
			delitemidx(@inventorylist_idx[.@i]);
			dispbottom(sprintf("Deleted Index %d: %s (%d)", @inventorylist_idx[.@i], getitemname(@inventorylist_id[.@i]), @inventorylist_id[.@i]), C_RED);
			break;
		}
	}

Issues addressed:
None

* getinventorylist now creates extra variable named @inventorylist_idx, which returns items corresponding
inventory index.
@HerculesWSAPI
Copy link
Contributor

This change is Reviewable

@dastgirp dastgirp added type:enhancement Issue describes an enhancement or feature that should be implemented component:core Affecting the Hercules core (i.e. not the game mechanics directly) labels Mar 9, 2019
Copy link
Contributor

@AnnieRuru AnnieRuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, tested working, however the example on *delitemidx has to change accordingly

@Emistry
Copy link
Member

Emistry commented Mar 16, 2019

btw, if the idea of using inventory index to select/update/adjust item are approved, perhaps can consider to further expand it in future?

  • compound card based on inventory index
  • delitem based on inventory index
  • refine item based on inventory index
  • identify item based on inventory
  • etc

summary, enable to alter/adjust the item state/info based on inventory index.

to be honest, the method we all have been using this whole time, delitem then getitem are ugly. I believe most of you know why its ugly, we aren't actually deleting an item, we're actually updating an item, so no point of deleting it and create unnecessary log.
its more precise if we take consideration when using script commands like equip, delitem, etc, inventory index allow us to pinpoint exactly the item we intended to update/alter, come in handy when there are multiple identical items appeared in inventory.

just saying ...

@Emistry Emistry added component:core:scriptengine Affecting the script engine or the script commands component:documentation Affecting the documentation in the doc/ folder labels Mar 16, 2019
@MishimaHaruna MishimaHaruna merged commit ed5a86e into HerculesWS:master Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:core:scriptengine Affecting the script engine or the script commands component:core Affecting the Hercules core (i.e. not the game mechanics directly) component:documentation Affecting the documentation in the doc/ folder type:enhancement Issue describes an enhancement or feature that should be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants