Talk:GetWeapon

From ZDoom Wiki
Jump to navigation Jump to search

About the example

In my tests, the script actually worked fine (directly comparing strings without using StrIcmp or its sister function as a medium). Is there something I'm missing? Are you not meant to use this approach? -- Blue Shadow (talk) 05:42, 25 October 2013 (CDT)

I'm a little surprised that the direct comparison worked at all. When you do a direct comparison you essentially compare the address of the string and not the contents, so it relied on an identical string existing in the string table. (I haven't looked at the dynamic strings implementation in awhile to say if its supposed to look at the string table first before creating a new string or not. In any case that behavior is not defined in my VM docs which EE implements their version upon.) Blzut3 (talk) 08:20, 25 October 2013 (CDT)
I guess it was a coincidence or luck that it worked. Thanks for the explanation. -- Blue Shadow (talk) 10:13, 25 October 2013 (CDT)
It will work as-is if you use it in a library. As a map-based ACS script, you would need to wrap the script's strings (not the ones returned by GetWeapon) inside strparam. Libraries and strparam all share the same string table, but maps have their own. -- Randy Heit (talk) 17:14, 25 October 2013 (CDT)