Snippet GetIntName

Azlier

Old World Ghost
Reaction score
461
This snippet gives you the proper name of an integer below 100. Ex: 7 = "seven", 23 = "twenty three".

It just looks more polished for an NPC to say "Please, bring me seven chickens." rather than "Please, bring me 7 chickens." Best used with constant integers set at the top of your vJass quests and such. Works for GUI, too, though.

One function is available to you.
JASS:
function GetIntName takes integer i returns string


Yep, that's it. I'd have gone higher, but textmacros cannot be run from textmacros.

JASS:
library GetIntName initializer Init

//*****************
//*  0 - 100 pack *
//*****************

globals
    private string array Names
    private integer Count = 0
endglobals

constant function GetIntName takes integer i returns string
    return Names<i>
endfunction

//! textmacro IntName__Set takes NAME
    set Names[Count] = &quot;$NAME$&quot;
    set Count = Count + 1
//! endtextmacro

//! textmacro IntName__SetTens takes NAME
    set Names[Count] = &quot;$NAME$&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-one&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-two&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-three&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-four&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-five&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-six&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-seven&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-eight&quot;
    set Count = Count + 1
    set Names[Count] = &quot;$NAME$-nine&quot;
    set Count = Count + 1
//! endtextmacro

private function Init takes nothing returns nothing
    //! runtextmacro IntName__Set(&quot;zero&quot;)
    //! runtextmacro IntName__Set(&quot;one&quot;)
    //! runtextmacro IntName__Set(&quot;two&quot;)
    //! runtextmacro IntName__Set(&quot;three&quot;)
    //! runtextmacro IntName__Set(&quot;four&quot;)
    //! runtextmacro IntName__Set(&quot;five&quot;)
    //! runtextmacro IntName__Set(&quot;six&quot;)
    //! runtextmacro IntName__Set(&quot;seven&quot;)
    //! runtextmacro IntName__Set(&quot;eight&quot;)
    //! runtextmacro IntName__Set(&quot;nine&quot;)
    //! runtextmacro IntName__Set(&quot;ten&quot;)
    //! runtextmacro IntName__Set(&quot;eleven&quot;)
    //! runtextmacro IntName__Set(&quot;twelve&quot;)
    //! runtextmacro IntName__Set(&quot;thirteen&quot;)
    //! runtextmacro IntName__Set(&quot;fourteen&quot;)
    //! runtextmacro IntName__Set(&quot;fifteen&quot;)
    //! runtextmacro IntName__Set(&quot;sixteen&quot;)
    //! runtextmacro IntName__Set(&quot;seventeen&quot;)
    //! runtextmacro IntName__Set(&quot;eightteen&quot;)
    //! runtextmacro IntName__Set(&quot;nineteen&quot;)
    
    //! runtextmacro IntName__SetTens(&quot;twenty&quot;)
    //! runtextmacro IntName__SetTens(&quot;thirty&quot;)
    //! runtextmacro IntName__SetTens(&quot;forty&quot;)
    //! runtextmacro IntName__SetTens(&quot;fifty&quot;)
    //! runtextmacro IntName__SetTens(&quot;sixty&quot;)
    //! runtextmacro IntName__SetTens(&quot;seventy&quot;)
    //! runtextmacro IntName__SetTens(&quot;eighty&quot;)
    //! runtextmacro IntName__SetTens(&quot;ninety&quot;)
    
    //! runtextmacro IntName__Set(&quot;one hundred&quot;)
endfunction

endlibrary</i>
 

Azlier

Old World Ghost
Reaction score
461
>It just makes sense.

Perhaps, but since when has Azlier been known to care about sense?
 

SerraAvenger

Cuz I can
Reaction score
234
I would've done some modulo stuff I guess. Interesting implementation you got there, just awkward memory usage...
 

Jesus4Lyf

Good Idea™
Reaction score
397
Not useful in many occasions, but useful, nonetheless.
Dude! This means now you can attach to structs!
JASS:
globals
    integer array Data
endglobals
...
set Data[StringHash(GetIntName(struct))]=data
set data=Data[StringHash(GetIntName(struct))]

:D :D :D

(I WILL shoot anyone who actually uses this, of course...)
 

Romek

Super Moderator
Reaction score
964
Very silly, J4L.
Why not just use Data[integer(struct)]? :p

Anyway, I think this is very useful indeed.
Only 101 numbers though? :(

> //! runtextmacro IntName__Set("eightteen")
eightteen? You mean eighteen.

> Works for GUI, too, though.
Why the commas? o_O
 

Azlier

Old World Ghost
Reaction score
461
Technically, you only type out numbers less than 12 in English anyway. I'd actually have gone to 500, but you can't run textmacros from textmacros :(.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Why not just use Data[integer(struct)]?
Because two separate structs with the same index would overwrite the value (same as in my method). The real question is why not just use fields? :D

>Why the commas? o_O
This soooo isn't the grammar zone. :p

On a serious note, make this return I2S for values that have no stored string version?
 

SerraAvenger

Cuz I can
Reaction score
234
On a related note, I'm so totally for
JASS:
constant function GetIntName takes integer i returns string
    if i &lt; 0 then
        return &quot;minus &quot; + GetIntName(-i)
    elseif Names<i> == null then
        return I2S( i )
    else
        return Names[ i ]
    endif    
endfunction
</i>
 

Romek

Super Moderator
Reaction score
964
I think 'negative' would sound better than 'minus'.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
This would be more useful if you'd make some kind of algorithm which "constructs" the correct string dependant on the input number.

:eek:
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
And took advantage of the fact that each 10^3 group reuses the same names (ie 13, 13,000, 13,000,000, etc...) to make the system increasable by 10^3 in domain however many times you like without much trouble.

:)
 

SerraAvenger

Cuz I can
Reaction score
234
rawcode hashing would be the absolutely wrong algorithm for this. Just hashtables are much better.

Should probably know:
Code:
[0] - zero   
[1] - one
[2] - two 
[3] - three 
[4] - four
[5] - five
[6] - six
[7] - seven
[8] - eight
[9] - nine
// * 10 * ( index - 8 ) 
[10] - twenty
[11] - thirty
[13] - fifty
// * 10 ^ ( index - 13 )
[14] - ten
[15] - hundred
[16] - thousand
[19] - million
[22] - billion

And then construct:
Code:
Construct
 - triple block 1
  - letter 1
  - letter 2
  - letter 3
 - triple block 2
  - letter 1
  - letter 2
  - letter 3
 - triple block 3
  - letter 1
  - letter 2
  - letter 3

// EG:
Construct ( 123456789 )
 - triple block 1: 789
  - letter 1: 7 -> seven [ hundred]
  - letter 2: 8 -> eight [y]
  - letter 3: 9 -> nine
 - triple block 2: 456 [ thousand] [and]
  - letter 1: 4 -> four [ hundred]
  - letter 2: 5 -> [fifty]
  - letter 3: 6 -> six
 - triple block 3: 123 [ million]
  - letter 1: 1 -> one [ hundred]
  - letter 2: 2 -> [twenty]
  - letter 3: 3 -> three
-> one hundred twenty three million four hundred fifty six thousand and seven hundred eighty nine
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top