Allow Letters In Coordinates (Lua Function Included)

Discussion in 'Mechanics' started by Surn_Thing, May 8, 2017.

?

Good Idea or Bad Idea

  1. Good Idea

    1 vote(s)
    50.0%
  2. Bad Idea

    1 vote(s)
    50.0%
  1. Surn_Thing

    Surn_Thing Pangalactic Porcupine

    Because "Chuckle,Fish" is easier to remember than "7479781,554". It would be a lot of fun to see what you can get with different word combinations.

    "I found some good Floran colonies around ur,mom's."

    "There are some great firy stars at bleach,chugger."

    "I set up my base near triggly,puff."

    The following lua function allows non-numeric characters to be read as numbers while allowing normal numbers to remain the same. In other words, it allows letters to be accepted as coordinates while retaining the old "just numbers" functionality. It treats numbers as regular digits while using the last digit of the byte code of other characters.


    Code:
    function wordToNumber (grindme)
    
        if (type(grindme) ~= "string") then return -1 end
        toSend = "";
        numbers = {'0','1','2','3','4','5','6','7','8','9'}
    
            function indexOf(arrayHere, thingHere) --Gets the index of an item if it's in the array. Returns -1 otherwise.
    
                for a = 1,#arrayHere,1
                do
                if (thingHere == arrayHere[a]) then return a end
                end
                return -1
    
    
            end
    
        for a=1,string.len(grindme),1
        do
            grindDown = indexOf(numbers,string.sub(grindme,a,a))-1;
    
            if (grindDown <= -1) then grindDown = string.byte(string.sub(grindme,a,a)); end --Uses the bytecode if not a number
    
            while (grindDown >= 10) do grindDown = grindDown - 10; end --Whittles it down to the last digit to keep the number short
               
                if (a == 1 and string.sub(grindme,a,a) == "-") -- This allows for negatives
                then
                toSend = "-";
                else
                toSend = toSend .. grindDown;
                end
    
               
    
           
        end
       
    
        return toSend;
    
    
    end
     
  2. Vyrvin

    Vyrvin Scruffy Nerf-Herder

    Fun and little bit abuseable, but can be greatly used for trolling and remembering the coordinates.
    For example, the numbered coordinates cannot be remembered at all, so its hard to write. But word coordinates are very easy.
     

Share This Page