5,391
edits
mNo edit summary |
(aha) |
||
Line 41: | Line 41: | ||
It should be noted, however, that "ordinary" string literals (the ones that are included in BSL scripts and allocated at level start) seem to be always compared by content even if they're changed to completely new literals at runtime (as long as it's from the console and not from OBJC events). If you have two global string vars '''testVar''' and '''testVar2''', you can set them both to "bla" from the console, and '''testVar eq testVar2''' will evaluate as '''true''' - so apparently the comparison becomes lazy (by pointer) if at least one of the strings (pointers) is in the dynamic range used by runtime events, but for new strings from the console (also dynamically allocated) it still uses the non-lazy comparison. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST) | It should be noted, however, that "ordinary" string literals (the ones that are included in BSL scripts and allocated at level start) seem to be always compared by content even if they're changed to completely new literals at runtime (as long as it's from the console and not from OBJC events). If you have two global string vars '''testVar''' and '''testVar2''', you can set them both to "bla" from the console, and '''testVar eq testVar2''' will evaluate as '''true''' - so apparently the comparison becomes lazy (by pointer) if at least one of the strings (pointers) is in the dynamic range used by runtime events, but for new strings from the console (also dynamically allocated) it still uses the non-lazy comparison. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST) | ||
I sort of found a workaround, where I copy the value of '''ai_name''' to '''testVar''' not directly, but via Daodan's '''sprintf''' (basically you do '''testVar = sprintf("%s",ai_name)''' instead of '''testVar = ai_name'''). This fills '''testVar''' with some garbage (in my test it was "hӌ"), but it's some consistent garbage that is somehow related to '''ai_name''' - so you can use this at spawn time to initialize the "reference name" of a character, and later check against it with names that you receive from death functions, trigger volumes, etc. I didn't check this thoroughly, but I will make an illustration (probably in TCTF HQ, where many Vanilla CHARs have spawn functions). Also, I have no idea why '''sprintf''' garbles the literal like that when it comes from runtime, so that's another thing that will need to be checked. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:56, 18 May 2020 (CEST) |