Snivy's Lua Land

Snivy

Quark
Joined
Apr 7, 2017
Messages
56
Nebulae
26
I thought since Zombine had a thread for sharing code and such Maybe I could make one too,

So I've taken an interest in code around last year and have been working on nonserious projects since last year.

Few things i've been working on were
Mods in garry's mod
A dumb text based game
a 2D RPG game engine

and a few other things.

It's kinda obvious I like pokemon based on my name, and in respect of that that name i've been working on a mod for such

Although it's not much yet, i've gotten each type and their respective weaknesses, and i'm working on the battle mechanics and UI
YBFrYzn.png


I got bored and thats why it's colorful lmao

Also working on a zelda style ui for GMOD

A80902DF992EEB1E6DD099A622AA1021E3F6E4DF

I can't quite figure out how to get a weapons max Ammo1 magazine so a lil help would be nice. as I'm going to attach the ammo to the magic meter

Another thing I'm kinda proud of is a function I made that iterates through a string and can encode a string using a given key in the format of a table, turning any occurrence of a key within a table into a value, and vice versa

Code:
function string.encode( str )
    str = string.lower(str)
    local str_encoded = ""
    local pos = 0
    len = string.len(str)
    while true do
        pos = pos + 1
        if pos > len then
            break
        end
        local A = string.sub( str, pos, pos )
        if encode[A] then str_encoded = str_encoded..encode[A] end
    end
    return str_encoded
end

function string.decode( str )
    if str and str ~= string.upper(str) then
        error("string.decode: The given string was either not encoded or not properly encoded")
    end
    local str_decoded = ""
    local pos = 0
    len = string.len(str)
    while true do
        pos = pos + 1
        if pos > len then
            break
        end
        local A = string.sub(str, pos, pos)
        pos = pos + 1
        if pos > len then break end
        local B = string.sub(str, pos, pos)
        if decode[A..B] then str_decoded = str_decoded..decode[A..B] end
    end
    return str_decoded
end

of course their is a limitation as string.encode reads it one letter at a time, meaning it can only turn one letter into two.



I've got a GitHub if anyone's interested

I really encourage you guys to look at this and critique it so I can better myself
 
Last edited:
Reactions: List