Decimal To Base 70 Trigger

ShadowInTheD

Active Member
Reaction score
12
The function below is supposed to convert an integer value into base 70 and show it to the player that types in the value (atleast for now). I have two questions regarding this.

1. Does the trigger actually DO what I want, or did I do it completely wrong?
2. If I call it in a completely different trigger, will it display?

JASS:
function Decimal2Base70 takes integer i returns string
local string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*"
local string Base70String
local integer tracker = i
local integer tracker2
local integer loopinteger
local integer check = 0
local integer StringInteger = 1
loop
exitwhen check < 0
if i/Pow(70,check) < 1 then
set check = -5
set loopinteger = check - 1
endif
set check = check + 1
endloop
loop
exitwhen loopinteger < 0
set tracker = ModuloInteger(tracker,R2I(Pow(70.0,I2R(loopinteger))))
set tracker2 = i - (70*tracker)
set Base70String = SubString(Base70String,StringInteger,StringInteger)+SubString(Alphabet,tracker2,tracker2)
set tracker = tracker2
set StringInteger=StringInteger+1
set loopinteger = loopinteger-1
endloop
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Base 70:" + Base70String)
endfunction


As a completely off question that I still need, is there a native function or something that will break a loop immediately?
 

No_exit

Regular User (What is Custom User Title?)
Reaction score
40
1. Does it do what you want?
No.

I had to rewrite most of the code but I managed to get it work.

JASS:
function Decimal2Base70 takes player pl, integer i returns string //Takes a player now too so to call it do something like "call Decimal2Base70(GetTriggerPlayer(),70)"
    local string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$^&*?" //Removed % and added ?, apparantly the % char doesn't work in strings.
    local string Base70String = "" //Now initialized.
    local integer tracker
    local integer loopinteger
    local integer check = 1 //now initialized at 1 to allow the number 0 to be properly displayed as 1 digit. If you don't want this then put it at 0.
    loop
        if i/Pow(70,check) < 1 then
            set loopinteger = check-1
            exitwhen true //Exits loop. Always.
        endif
        set check = check + 1
    endloop
    
    loop
        exitwhen loopinteger < 0
        set tracker = ModuloInteger(i,70)
        set i = i / 70
        set Base70String = SubString(Alphabet,tracker,tracker+1) + Base70String
        set loopinteger = loopinteger-1
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,60,"Base 70:" + Base70String) //Now displays for 60 seconds.
    return Base70String //Now actually returns a string.
endfunction


2. If I call it in a completely different trigger, will it display?
The function above will. The original function had a GetTriggerPlayer() in the end which is not very nice since it means that when calling this function you will need to keep in mind that a playerevent happened.

3. As a completely off question that I still need, is there a native function or something that will break a loop immediately?
exitwhen true
as displayed in the code.
 
Reaction score
341
JASS:
function Decimal2Base70 takes integer int returns string
    local string alpha  = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$^&*%%"
    local integer base  = StringLength(alpha)
    local integer one   = 0
    local integer two   = int
    local string output = ""
    
    if int < base then
        return SubString(alpha, int, int + 1)
    endif
    
    loop
        exitwhen two <= 0
        set one = two - (two / base) * base
        set two = two / base
        set output = SubString(alpha, one, one + 1) + output
    endloop
    return output
endfunction


% works, i'm pretty sure you just need to add two of them.
 

ShadowInTheD

Active Member
Reaction score
12
No_Exit, I don't think it's working quite right? Like, 393 is putting 1N, and 71 is putting 1. Do you know what the problem is? It's not putting them together right..
 

ShadowInTheD

Active Member
Reaction score
12
Actually Happy, yours doesn't work well either ^^. If I enter like: 290, 390, and 490, it always returns "1K", and like 289, 389, and 489 returns "1J" ><
 

ShadowInTheD

Active Member
Reaction score
12
WHY WON'T THIS DISPLAY?!?!?!!?!?!!
JASS:
function Decimal2Base70 takes player pl, integer i returns string
  local integer tracker = i
  local integer tracker2
  local integer loopinteger
  local string Alphabet = &quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$^&amp;*?&quot;
  local string output = &quot;&quot;
    loop
        if i/R2I(Pow(70,loopinteger)) &lt; 1 then
        set loopinteger = loopinteger-1
        exitwhen true
        endif
      set loopinteger = loopinteger + 1
    endloop
    loop
      exitwhen loopinteger &lt; 0
        set tracker2 = tracker/R2I(Pow(70,loopinteger))
        set output = SubString(output,tracker2,tracker2+1) + output
        set tracker = tracker - (tracker2 * R2I(Pow(70,loopinteger)))
        set loopinteger = loopinteger-1
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,60,&quot;Base 70:&quot; + output)
    return output
endfunction
 

No_exit

Regular User (What is Custom User Title?)
Reaction score
40
Tested mine too,
393 gives 5h
71 gives 11

I think you are are calling the wrong function or you haven't copied the function right because TriggerHappy's function seems right too.

@ the previous post, you need to initialize loopinteger
local integer loopinteger = 0
 

ShadowInTheD

Active Member
Reaction score
12
First of all, obviously none of these will "work," at least, in the sense that I'm thinking of (maybe you tried to do it just for the sense I was thinking of). But the lines:
JASS:
 set output = SubString(output,tracker2,tracker2+1) + output

creates the string in the wrong order :D.

+ rep =)

Why can't it go past 70^6-1?

What's the highest storing value of an int?
 
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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      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