sfall-team / sfall

sfall - Engine modifications for Fallout 2
https://sfall-team.github.io/sfall/
GNU General Public License v3.0
348 stars 41 forks source link

write memory doesn't seem to work #415

Closed tnevolin closed 3 years ago

tnevolin commented 3 years ago

I have set AllowUnsafeScripting=1 and running code below to test direct memory write. There is no error but value does not change either. Do I use it right?

        variable s = "abc";
        variable p = get_string_pointer(s);
        debug_msg(s);
        debug_msg("" + read_byte(p));
        write_byte(p, 48);
        debug_msg(s);

Output

abc
97
abc
FakelsHub commented 3 years ago

In order to write outside the Fallout 2 address space, you need to set AllowUnsafeScripting=2 but in general it is not recommended to use very-low-level programming in the c++ style.

tnevolin commented 3 years ago

Thank you for pointing this out. Yes. I don't like to access memory directly either but this seems to be the last resort. I am trying to modify messages loaded into memory from *.msg files by program at start time. Let me know if there is there is a programmatic and safe way to modify them. Other option would be to add more information in description window at the time the item description is requested.

NovaRain commented 3 years ago

Other option would be to add more information in description window at the time the item description is requested.

Have you checked HOOK_DESCRIPTIONOBJ?

tnevolin commented 3 years ago

That may do. Thank you.