vladvo Posted September 14, 2022 Share Posted September 14, 2022 (edited) Hi All ! I'am making a mod to export and import all possible game stats. Almost everything seem to work as intended. So, I read a float value with CLEO I read it using 0653: [email protected] = 81 //Gambling then save it to file with 0AF3: [email protected] "CLEO\stat.dat" "stats" key "Gambling" In-game stat screen shows normal value but in the stat.dat file it look like this: Gambling=3.67312e+06 How do I get a normal value ? Not this "e+06 " overflow. And it should be compatible with 0AF2: [email protected] = "CLEO\stat.dat" "stats" key "Gambling" so that I would be able to import it back in the game. Edited September 14, 2022 by vladvo Link to comment Share on other sites More sharing options...
ZAZ Posted September 14, 2022 Share Posted September 14, 2022 (edited) i saw those expressions more times can you compile it ? does it work ? If not, then post complete script if yes then display output of ini on screen while true wait 0 03F0: enable_text_draw 1 045A: draw_text_1number 50.0 200.0 GXT 'NUMBER' number 12@// display Gambling skill 0653: 1@ = float_stat 81//Gambling 0092: 12@ = float_to_integer 1@ end Edited September 14, 2022 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
vladvo Posted September 14, 2022 Author Share Posted September 14, 2022 (edited) Yes, it works now. Thanks. I decided to check another stat (distance on motorbike) to avoid any confusion - there are like 3 or 4 stats related to gambling. The distance one is pretty clear. At first your code failed to do the job. Just because I forgot that I have to use 0AF1 instead of 0AF3. (0AF1 - write int, 0AF3 - write float to file) The only drawback of float to int conversion is that the real in-game value is 1801278.75M and during conversion .75 is lost. No biggie. At least with this stat. The value in file is 1801278. Great. Tested the mod a bit more and it seems that float values over 1000000 (starting with 1000001) are written with e+##. Guess it's a problem with this cleo function. Well, turns out that at the moment it would require more work to check if the var is >1000000 and if it is - convert it. Not sure I am ready for it. The code is already 1000+ lines long. )) Actually, everything was done quite fast with excel and a stat table I found on one of the websites. Have a look, if you want to. https://pastebin.com/7jP4ZvZp Read-writes are made in blocks due to limitations (33 local vars, I think). Edited September 14, 2022 by vladvo Link to comment Share on other sites More sharing options...
OrionSR Posted September 15, 2022 Share Posted September 15, 2022 What happens if you ignore the scientific notation in the ini file and follow through with reading it as a float and updating the stat with that value? Do you loose any precision? Floating point values are not terribly accurate anyway, and this becomes more apparent as the numbers become larger. Link to comment Share on other sites More sharing options...
ZAZ Posted September 17, 2022 Share Posted September 17, 2022 have tested the script and found inside ini file Longest 2 wheels distance=5.1522e+007 when i convert it to integer 0653: 12@ = float_stat 12 0092: 31@ = float_to_integer 12@ it returns 78 Spoiler :EXPORT wait 0 03F0: enable_text_draw 1 045A: draw_text_1number 50.0 200.0 GXT 'NUMBER' number 31@// display Longest 2 wheels distance if 0AB0: key_pressed 119 //F8 - save stats else_jump @IMPORT // If not ignore this part and jump to the second part 0653: 12@ = float_stat 12 0092: 31@ = float_to_integer 12@ 0AF3: write_float 12@ to_ini_file "CLEO\stat.dat" section "stats" key "Longest 2 wheels distance " :IMPORT if 0AB0: key_pressed 118 // F7 else_jump @EXPORT 0AF2: 12@ = read_float_from_ini_file "CLEO\stat.dat" section "stats" key "Longest 2 wheels distance " jump @EXPORT CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now