Topic: Scenarios: File I/O
GunChleoc![]() |
Posted at:
2018-04-28, 16:59 UTC+2.0
Can you provide me with the scenario that you are using for testing your branch? Busy indexing nil values ![]() ![]() |
ypopezios![]() |
Posted at:
2018-04-28, 21:13 UTC+2.0
I'm not sure if the following is relevant, but I thought of sharing it. I understand the above desire as to bound a value between an acceptable range, so as it's not too big a dis/advantage. For any quantity which can have any value (val) between 0 and infinity, instead of comparing it against the desired bounds (minval and maxval) and equal all excessive values to them, we could bound it in a more challenging way through the following formula:
Suppose that we want to bound a quantity between 40 and 60. The common way through comparisons would behave like this:
While the formula would behave like this:
If the central idea is relevant, the formula could be adjusted to bring its behavior closer to more special desires. ![]() ![]() |
Nordfriese![]() Topic Opener |
Posted at:
2018-04-29, 09:13 UTC+2.0
Here´s my test script:
The desired output would be
But I always get:
The .wcd file is written to correctly, though in wrong order. @ypopezios: That´s a very good idea! I was going to use 1/x or exp(-x) functions to balance difficulties, but your approach will work much better (the only difficulty in scripting will be finding good min/max values). I´ll definitely use it in scenario #4 (though it will be some time until even #3 is complete…) ![]() ![]() |
GunChleoc![]() |
Posted at:
2018-04-29, 17:34 UTC+2.0
Thanks for the formula The C++ code was actually correct, except for some test output that caused it to push strings instead of numbers. Lua is a bit tricky when your tables don't have integer keys:
I have fixed up your test script and added it to the test suite, in the
You're doing a good job here venturing into C++
Edited:
2018-04-29, 17:36 UTC+2.0
Busy indexing nil values ![]() ![]() |
Nordfriese![]() Topic Opener |
Posted at:
2018-05-02, 12:29 UTC+2.0
I hate spending so much time debugging my code when only the test script is wrong… now it works. Thanks I pulled out the code that parses/creates the table into a recursive read/write function, so tables can now be used as values. Scenarios can save subtables, e.g.
One other thing it would be nice to have is to permit arrays as well as tables. Using an array currently causes a coroutine error ("invalid key to 'next'"). I don´t know how to fix that though… ![]() ![]() |
GunChleoc![]() |
Posted at:
2018-05-03, 08:46 UTC+2.0
Yep. It led me a merry chase too
Very nice!
What do you mean by that - tables that use ints instead of strings as keys? I guess you'd have to iterate over the current table to check if all keys can be reverted to consecutive ints, starting from 1. This check could be done when saving if you write a hint to the file, or during loading. Busy indexing nil values ![]() ![]() |
Nordfriese![]() Topic Opener |
Posted at:
2018-05-03, 18:48 UTC+2.0
Experimented some more and it turned out that actually the error message is incorrect. It´s
As far as I know, tables can either be arrays with indices 1..n, or have only strings as keys. Finally, one small bug remaining: In arrays,
I have no idea where this could come from… ![]() ![]() |
GunChleoc![]() |
Posted at:
2018-05-03, 21:42 UTC+2.0
You could check for nil values when saving and trigger report_error if there are any. If somebody is saving nil values, chances are good that there is something wrong with the data being saved anyway. Busy indexing nil values ![]() ![]() |
Nordfriese![]() Topic Opener |
Posted at:
2018-05-04, 09:37 UTC+2.0
But if a ![]() ![]() |
GunChleoc![]() |
Posted at:
2018-05-04, 16:57 UTC+2.0
I'll have to take a look at the code. Please ping me if you don't hear from me by Monday. Busy indexing nil values ![]() ![]() |