Giter Club home page Giter Club logo

universal-ammo's Introduction

universal-ammo's People

Contributors

zakarybk avatar

Watchers

 avatar  avatar

universal-ammo's Issues

Use proper string sort algorithm

UniversalAmmo.StringLikeness = function(str1, str2)
local score = 0
local str1Letters = {}
local str2Letters = {}
if str1 == str2 then
score = score + 1
end
if isnumber(tonumber(str1)) and isnumber(tonumber(str2)) then
score = -math.abs(tonumber(str1)-tonumber(str2))
end
str1 = string.ToTable(str1)
str2 = string.ToTable(str2)
-- Score+ for same chars at index
for index, char in pairs(str1) do
-- Identical spots
if char == str2[index] then
score = score + 1
end
-- Number of each char in string
if str1Letters[char] == nil then
str1Letters[char] = 1
else
str1Letters[char] = str1Letters[char] + 1
end
end
-- Number of each char in string
for index, char in pairs(str2) do
if str2Letters[char] == nil then
str2Letters[char] = 1
else
str2Letters[char] = str2Letters[char] + 1
end
end
-- Compare char counts
for char, count in pairs(str1Letters) do
if str2Letters[char] != nil then
local diff = count - str2Letters[char]
diff = 1 - math.abs(diff / str2Letters[char])
score = score + 1
end
end
return score
end

I came up with this one ages ago. There's probably a better method I can use. This one is not super accurate, but it's really close.

Add render distance to ammo text

Drawing text in GMod can start to cause lag in bigger servers. But I doubt there will be many ammo boxes stashed in-game so it's only really a concern for high population servers - in which case I would probably want to compress the initial table download as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.