gokuta Posted July 7, 2019 Share Posted July 7, 2019 This opcode 0ADF: add_dynamic_GXT_entry "_test" text "Test string" I use gxt entry "_test" in few of my cleo scripts. Perhaps I should not invoke this opcode in each of my cleo scripts, since "_test" may already be created and I can run into memory leakage problems. Am I right? In case I am, I should probably check first whether dynamic gxt entry "_test" already exist. How do I do that? Link to comment Share on other sites More sharing options...
gokuta Posted July 11, 2019 Author Share Posted July 11, 2019 bump! important Link to comment Share on other sites More sharing options...
cardboardbox1230 Posted July 23, 2019 Share Posted July 23, 2019 As you said in the title, 0ADF overwrites the dynamic GXT entry. Don't worry about a GXT-related memory leak in CLEO, since it's a very advanced plugin. If you look in the log (CLEO.log) you can see that CLEO deletes all the dynamic GXT entries upon loading/exiting the game. As for checking whether the GXT entry exists, I'm glad you're doing that. Most modmakers don't bother with compatibility. For checking whether a GXT entry exists, there is a way: Spoiler 09FD: get_gxt_string '_TEST' width_to 0@ 0A08: get_gxt_string_1number '_TEST' number 0 width_to 1@ if and 0@ <= 0 1@ <= 0 then // gxt doesn't exist end Some scripts may also have "~1~" or the like as their content; you have to check for that using 0A08. I learned that the hard way. Here is a little script I wrote that returns a new empty GXT every frame and then destroys it by the next: Spoiler {$CLEO .cs} 0000: NOP 03F0: enable_text_draw 1 while true //for regular text, clear them immediately after using if 0ADC: test_cheat "GXTPRI" then 0AB1: call_scm_func @f_GetFreeGXTEntry 0 Ret- zsFreeGXTKey{@v} 15@ 16@ 17@ 18@ 0AD1: show_formatted_text_highpriority "GXT String = %s" time 5000 [email protected] 0ADF: add_dynamic_GXT_entry [email protected] text "GXT Priority Text Test" 03E5: show_text_box [email protected] 0AE0: remove_dynamic_GXT_entry [email protected] end //for text draw, clear them one frame (wait 0) after using if 0ADC: test_cheat "GXTTXD" then 32@ = 0 while 32@ < 5000 0AB1: call_scm_func @f_GetFreeGXTEntry 0 Ret- zsFreeGXTKey 15@ 16@ 17@ 18@ // long string (@v) 0AD1: show_formatted_text_highpriority "GXT String = %s" time 0 [email protected] 0ADF: add_dynamic_GXT_entry [email protected] text "GXT Text-Draw Test" 033E: set_draw_text_position 320.0 224.0 GXT [email protected] wait 0 0AE0: remove_dynamic_GXT_entry [email protected] end end wait 0 end :f_GetFreeGXTEntry //0AB1: call_scm_func @f_GetFreeGXTEntry 0 Ret- zsFreeGXTKey{@v} [email protected] [email protected] [email protected] [email protected] for 0@ = 0 to 0xFFFFFFF 0AD3: [email protected] = format "%X" 0@ 09FD: get_gxt_string [email protected] width_to 5@ 0A08: get_gxt_string_1number [email protected] number 0 width_to 6@ if and 5@ <= 0 6@ <= 0 then break end end 0AB2: ret 4 1@ 2@ 3@ 4@ I know that it seems CPU-intensive, but I didn't notice any FPS loss with this method (CORE 2 DUO E8400 3GHz). Besides, you have to sacrifice performance for compatibility most often than not. Don't worry about running out of GXT strings since you can have 4294967295 different GXT entires, and that's just with the hexadecimal number system. With base-36 number system (upto letter Z), you can have more than 8 Octillion!. You're destroying yours every frame anyway, it will be used again until another script starts using it. I would tell you to migrate to MoonLoader (LUA), but I know how difficult it is. I too find myself coming back to CLEO/SCM from time to time. Anyways, best of luck. For further help, ask me anytime. I will reply in under 12 hours (at most). gokuta 1 Link to comment Share on other sites More sharing options...