hashes a string * All ids in the engine are represented as hashes, so a string needs to be hashed * before it can be compared with an id. * * @name hash * @param s [type:string] string to hash * @return hash [type:hash] a hashed string * @examples * * To compare a message_id in an on-message callback function: * * ```lua * function on_mes
| 83 | * ``` |
| 84 | */ |
| 85 | static int Hash_new(lua_State* L) |
| 86 | { |
| 87 | int top = lua_gettop(L); |
| 88 | |
| 89 | dmhash_t hash; |
| 90 | dmhash_t* phash = ToHash(L, 1); |
| 91 | if (phash != 0) |
| 92 | { |
| 93 | hash = *phash; |
| 94 | } |
| 95 | else |
| 96 | { |
| 97 | const char* str = luaL_checkstring(L, 1); |
| 98 | hash = dmHashString64(str); |
| 99 | } |
| 100 | PushHash(L, hash); |
| 101 | |
| 102 | assert(top + 1 == lua_gettop(L)); |
| 103 | return 1; |
| 104 | } |
| 105 | |
| 106 | /*# get hex representation of a hash value as a string |
| 107 | * Returns a hexadecimal representation of a hash value. |
nothing calls this directly
no test coverage detected