Closed fbicirno closed 2 years ago
I don't understand what you are trying to do here. Hash to save game speed?
Putting @compiletime
means the func will be executed once at compiletime.
I want to convert some strings to hashes at compile time, not in game.
I want the compiler to automatically turn "text".gethash() into a hash value like 97675546
You should use compiletime("text".getHash())
You should use
compiletime("text".getHash())
The code is too long,not good to read
why not work
@cloudfox2 is correct. compiletime() expression are evaluated once at compiletime and then are replaced with the result. Because this is not defined when running the expression in the function body your function evaluates to:
function string.autohash2() returns int
return null
If you want to hash your strings for protection of some sort I would suggest using specialized software for that like W3Protect and not do it in source code.
@compiletime public function string.autoHash() returns int return this.getHash()
i really need a string autohash method to save game speedbut its look like not work.. such as in wurst "test".autohash() in game " stringhash("test") "