Item to String or Int Item Number (ASH)

Nightmist

Member
To use, import the script (It currently only supports items 1-1497)

Edit2: Removed since format changed. See below for new instructions


Note: You will need to edit 2 data files in mafia for it to work. Check the KoLmafia thread in the KoL forums for the changes you need to make. (They were typo errors in the data files so thats why they are posted in the mafia thread)
http://forums.kingdomofloathing.com/viewtopic.php?p=1662895#1662895


Edit: Edit2: Removed since changed script.


Edit2: To use this scriptlet, import it into your ASH script.
To find a items number in a Int then use
Code:
ItemToIntNumber( $item[*Item Name*])

To find a items number in a String then use
Code:
ItemToStringNumber( $item[*Item Name*])
OR you can just use int_to_string and then use the ItemToIntNumber (I have uploaded 2 files, one with only the int return and another with both int and string returns)

Remember you still need to update your dat files manually, see the link above.



Edit3: Ok realised that people might want the pure string version (Instead of having to use the one mixed with the Int for the people messing with URL's) Uploaded.

Edit4: Fixed the script to work with the "new" ice-cold beer names.
 

Attachments

  • ItemToInt.ash
    80.5 KB · Views: 82
  • ItemToString.ash
    84.7 KB · Views: 68
  • ItemToIntOrString.ash
    165.2 KB · Views: 68
Excellent! My scriplet for putting stuff into a display case has been revamped, and now requires ItemToIntOrString.ash

It also now accepts a quantity to be put into the display case instead of all, and takes stuff out of the display case.

Your script made it so much easier to handle the writing and calling of mine, and allowed for a less confusing system!

2901 lines of code! That is one huge script!

I just can't say enough! An excellent compilation of data!
 

Nightmist

Member
It would seem the data override files have been updated, to ease your updating of the data files use the inbuilt "Update" command in the CLI to automatically download the fixed datafiles. (Remember you need to restart mafia for the changes to come into effect)
 
[quote author=Nightmist link=topic=55.msg184#msg184 date=1144315015]
It would seem the data override files have been updated, to ease your updating of the data files use the inbuilt "Update" command in the CLI to automatically download the fixed datafiles. (Remember you need to restart mafia for the changes to come into effect)
[/quote]

after using the update command:

Item ice-cold beer not found in database at line 42 in file scripts\itemtostring.ash
Item ice-cold beer not found in database at line 82 in file scripts\itemtostring.ash

These items have been renamed on KOL, and KOLMafia probably just got updated to reflect the new name. Once fixed, things will be perfect. I've already fixed my copy.
 

holatuwol

Developer
Holy o_o I recently added an int_to_item function after seeing the crazy-sized split-up script and thought to myself, "Maintaining that must be really really painful," so I've also added an item_to_int method after seeing this one because it must definitely be really really painful. I also added automatic type-casting to strings because of the amount of _to_string calls I kept seeing. All these will be present in v7.0.
 

Nightmist

Member
[quote author=holatuwol link=topic=55.msg189#msg189 date=1144402267]
"Maintaining that must be really really painful,"[/quote]

Its not that bad since you really only ever use the items listed in the datafiles which allows pretty quick and easy updating... (De-bugging isnt that hard either, just try running the scriptlet directly and it should point out any typo errors by going red and stopping with helpful information on what the typo is)

The above scripts took me about 10 minutes... (I <3 being able to use item numbers instead of having to use item name)


But with the new functions I do suppose that means less waiting when mafia checks thes script before running ;D.
 
Top