Closed nelloy-git closed 5 years ago
I want count number of needed spell book in compiletime and do not generate extra ability id.
What Wurst version are you using? A recent update introduced data retention for objects in compiletime expression (https://github.com/wurstscript/WurstScript/pull/822/files) and int/real/string from hashtables also gets transferred from compiletime to runtime iirc. So you could try a HashMap to save the counter.
Im using the latest version. So can i add something like this?
Globals: constant hashtable hash = InitHashtable() constant int param_books_count = hash.loadInt(0, 0)
To hidePassives func: hash.saveInt(0, 0, used_books)
And i thought ID_GEN can give different values in compiletime and init time
Im using the latest version. So can i add something like this?
You of course need to wrap the InitHashtable()
in a compiletime expression..
And i thought ID_GEN can give different values in compiletime and init time
The preset id generators are not inside compiletime expressions either, nothing has changed there.
Thanks for explanation.
int value = 5
@compiletime function changeValue()
value = 10
init print(value.toString())
This code will print 10, is it truth?
This code will print 10, is it truth?
Why don't you test it? And no, it won't. Remember: compiletime-function != compiletime-expression. As I said, you need an object or a hashtable.
Here is an example (untested):
class Counter
var count = 0
constant COUNTER = compiletime(new Counter())
@compiletime function doStuff()
COUNTER.count++
init
print(COUNTER.count.toString()) // Will print 1
Did you get it to work? Closing for now.
Hi! Can you add opportunity to change variable (or/and constants) inside compiletime functions? For example in my unit stats control library i use spell book for hiding pissives. Library can get new unit parameter types thought config function. So number of passives to hide can be changed. I want count number of needed spell book in compiletime and do not generate extra ability id.