Script file unknown float variable

  • Thread starter RecursiveHarmony
  • Start date

Users who are viewing this thread

RecursiveHarmony

if (type(func[1]) == list_type):
file.write("%s -1\n"%(convert_to_identifier(func[0])))
save_statement_block(file,convert_to_identifier(func[0]), 0,func[1], variable_list,variable_uses,tag_uses,quick_strings)
else:
file.write("%s %f\n"%(convert_to_identifier(func[0]), func[1]))
save_statement_block(file,convert_to_identifier(func[0]), 0,func[2], variable_list,variable_uses,tag_uses,quick_strings)
In scripts.txt file there is an unknown float variable after script ids. There is no comment about it. Anybody knows what it does?
 
Solution
After looking through the source code of WSE and testing, I came to the conclusion that scripts are named & callable simple triggers (or simple triggers are non-named & non-callable scripts) :grin::grin::grin:
I'm serious.
Setting the value 0 makes script execute every frame and positive integrals make them work periodically like a simple trigger. Timing seems a little bit off. In the tests, it flactuates a little bit. They work only on map so interval is like the map simple triggers, in hours. I didn't test the minus values much, but they don't seem to work.
After looking through the source code of WSE and testing, I came to the conclusion that scripts are named & callable simple triggers (or simple triggers are non-named & non-callable scripts) :grin::grin::grin:
I'm serious.
Setting the value 0 makes script execute every frame and positive integrals make them work periodically like a simple trigger. Timing seems a little bit off. In the tests, it flactuates a little bit. They work only on map so interval is like the map simple triggers, in hours. I didn't test the minus values much, but they don't seem to work.
 
Upvote 2
Solution
That is honestly incredibly interesting. It's too bad they didn't end up being named and callable normal triggers so we could sneak a delay in.
If i come across one, i'll let you know. This isn't the first sneaky thing i came across. In the forge, while arguing about threading, variables and registers, i figured out local variables aren't local either. Quoting the related part in the post:
...i tested global variables and registers, and they passed thread-safety test. I also wrote two simple triggers. First one sets first local variable to 5 and does nothing else. Second one sets reg0 to first local variable and prints it. As a result, second one prints 5, so local variables keep their values like registers do. They're just some unnamed global array of variables created for convenience and reusability...
This game's engine is like a pyramid scheme. Nothing is what it looks like. :grin:
 
Upvote 0
Regarding local variables I made recently an entry at the Modding Guide
If you have a script that is called repeatedly (from a loop) the local variables within this script are NOT reset
with every call due to the quick succession of the script calls. One must initialize them at the beginning of the script
so they are re-set with every call.
It's an discovery of Caba`drin which I found at the old Modding Q&A Thread.

I have not understood yet fully your discovery above. It is possible to edit the values you marked in red and thus introduce a delay?
 
Upvote 0
Caba`drin says later:
I had anticipated that, as local variables, they wouldn't linger beyond the end of the script run, but it appears they do. No shortcuts around initializing them at 0, it seems.
It looks like he understood the problem but not entirely. Here is my post's link. Everything that uses operation block seem to run in a sequential order (in a single thread). That makes everything thread safe to use. About local variables, again everything that uses operation block shares the same local variables. They're are not local like in c# or python. It's just a static array variables. 5th script's 3rd local variable and 34th simple trigger's 3rd local variable is the same variable (they share the same memory space like registers).
I have not understood yet fully your discovery above. It is possible to edit the values you marked in red and thus introduce a delay?
It's like the check interval value of a simple trigger. If you set it to 5, it runs every 5 hours.
 
Upvote 0
It looks like he understood the problem but not entirely. Here is my post's link. Everything that uses operation block seem to run in a sequential order (in a single thread). That makes everything thread safe to use. About local variables, again everything that uses operation block shares the same local variables. They're are not local like in c# or python. It's just a static array variables. 5th script's 3rd local variable and 34th simple trigger's 3rd local variable is the same variable (they share the same memory space like registers).
Now I will need to think about how to integrate that information properly at the Modding Guide. Have the topic marked for now, will be a problem for future me :lol:
It's like the check interval value of a simple trigger. If you set it to 5, it runs every 5 hours.
One has to do this edit at the scripts.txt file though or not? And it only works at the world map?
 
Upvote 0
One has to do this edit at the scripts.txt file though or not? And it only works at the world map?
You can see it in the code at the first post. If you use string and operation block tuple, it defaults to -1 (disables it). If you use string, float and operation block tuple, it writes in the place of -1.
They work only on map so interval is like the map simple triggers...
 
Upvote 0
Back
Top Bottom