Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with item names and name modifiers #88

Closed
HimeWorks opened this issue Jan 13, 2014 · 4 comments
Closed

Working with item names and name modifiers #88

HimeWorks opened this issue Jan 13, 2014 · 4 comments
Labels
bug

Comments

@HimeWorks
Copy link
Member

@HimeWorks HimeWorks commented Jan 13, 2014

Say you had several scripts that modify an equip's name.

My item affixes adds prefixes and suffixes.
http://himeworks.wordpress.com/2014/01/13/item-affixes/

Selchar's got a couple level and durability scripts that also modifies the item name to add a level indicator or a durability indicator.

This can easily result in messed up names.
For example, you might have something like Shining Sword of Shining +3 (5/5) initially, but hen you change the suffix and maybe end up with

Shining Sword +3 (5/5) of Chaos

I don't know if that's possible, but right now I don't think there's a standard way to write names, so the order in which name modifiers are added could be problematic...

There should probably be a way to define this order, so that your names look like

PREFIX BASENAME SUFFIX LEVEL DURABILITY

and so on. String formatitng might be useful here, so you could literally say you want

sprintf("%s %s %s %s %s", prefix, basename, suffix, level, durability)

But how can that be made more extensible.

@Selchar
Copy link

@Selchar Selchar commented Jan 13, 2014

It can get complicated working with multiple scripts that modify item names. Especially when they are continuously being updated(durability/item charges), or has the potential to be updated at any time(levels, and apparently your item affixes script). It wasn't easy to think of a way to combine my Level/Durability script names but I eventually managed. I even made an allowance for affixes, tho I was thinking they would be applied at item creation and not through a scriptcall.

It will certainly get more complicated, but taking a look, I think the easiest solution would be to apply the level name suffix and durability name suffix at the end of your update_affix method if the appropriate script is detected.

More or less the more scripts made that modify names, the trickier it can get, I agree with that.

I'll see if there is anything that can be done with my own scripts as well, simply applying your method to mine when your script is detected should do the trick, but there's only 1 way to find out.

@Selchar
Copy link

@Selchar Selchar commented Jan 13, 2014

I had a few problems with renaming with my leveling script(obviously), but managed to fix it. In my script I have the following method.

def level_name_base
    if $imported[:TH_ItemAffixes]
      return @affix_name ? @affix_name : InstanceManager.get_template(self).name.dup
    else
      return InstanceManager.get_template(self).name.dup
    end
  end

I was able to resolve my issues by making the modifications with the $imported hash, however it only works with this method in your script commented out.

def name
  @affix_name ||= @name
  return @affix_name
end

I make my changes to @name, after grabbing it either from the template, or from in this instance @affix_name. Defining a method for name as you did has it's consequences where windows who reference item.name use the method, and not the @name instance variable. That's what I was able to figure out.

@HimeWorks
Copy link
Member Author

@HimeWorks HimeWorks commented Jan 14, 2014

Solution described here
#42 (comment)

@HimeWorks
Copy link
Member Author

@HimeWorks HimeWorks commented Jan 14, 2014

Instance Items has been updated to provide a make_name method which you should use for any sort of name modifications.

If you ever need to re-build the name, call the refresh_name method which will go and re-build the name.

@HimeWorks HimeWorks closed this Jan 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.