GE Lua Documentation

Press F to search!

stringHash

Definition


-- @/lua/common/utils.lua:236

function stringHash(text)
  -- From: http://wowwiki.wikia.com/wiki/StringHash/Analysis
  -- available under CC-BY-SA
  local counter = 1
  local len = string.len(text)
  for i = 1, len, 3 do
    counter = fmod(counter * 8161, 4294967279) +
    (string.byte(text, i) * 16776193) +
    ((string.byte(text, i + 1) or (len - i + 256)) * 8372226) +
    ((string.byte(text, i + 2) or (len - i + 256)) * 3932164)
  end
  return fmod(counter, 4294967291)
end

Callers

@/lua/ge/extensions/core/vehicle/mirror.lua
  if configName:startswith("{") then --custom
    configName = "custom" -- +"_"+stringHash(configName)
  end
  if configName:startswith("{") then --custom
    configName = "custom" -- +"_"+stringHash(configName)
  end
@/lua/vehicle/controller/couplings/kingpin.lua
local function debugDrawMethod(focusPos)
  obj.debugDrawProxy:drawNodeSphere(kingpinNodeCid, 0.15, getContrastColor(stringHash(kingpinKey), 150))
end
@/lua/vehicle/beamstate.lua
    if not coupler.couplerLock and not coupler.couplerWeld and ((coupler.couplerTag and externalCouplerVisibilityTags[coupler.couplerTag]) or (coupler.tag and externalCouplerVisibilityTags[coupler.tag])) then
      obj.debugDrawProxy:drawNodeSphere(coupler.cid, 0.15, getContrastColor(stringHash(coupler.couplerTag or coupler.tag), 150))
    end
@/lua/vehicle/controller/couplings/fifthwheel.lua
local function debugDrawMethod(focusPos)
  obj.debugDrawProxy:drawNodeSphere(fifthwheelNodeCid, 0.15, getContrastColor(stringHash(fifthwheelKey), 150))
end