Jump to content

XML:BINA/OBJC/TRGV: Difference between revisions

→‎String comparison bug: solution (Windows-only)
(→‎String comparison bug: solution (Windows-only))
Line 221: Line 221:
[[Image:Trigger_volume_string_comparison_bug.jpg|300px]]
[[Image:Trigger_volume_string_comparison_bug.jpg|300px]]


(EDIT: Interestingly, '''ai_name eq ai_name''' evaluates to '''true'''. So it seems that the string passed from BSL includes a non-printable character (end-of-line, perhaps). --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 18:54, 14 May 2020 (CEST) )
(EDIT: Interestingly, '''ai_name eq ai_name''' evaluates to '''true'''. Apparently, as detailed by [[User:Loser|Loser]] [[BSL:String_comparison|HERE]], strings are compared by pointer and not by content. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 18:47, 6 August 2020 (CEST) )


=====Possible workarounds=====
=====Possible workarounds=====


If you need to detect few characters and if all of these are from different teams you can clone the trigger volume one time for each character and call different functions one for each team. This way you make sure you know which character triggered the trigger volume since each character has a unique team and a unique trigger volume function.
If you need to detect a few characters and if all of these are from different teams you can clone the trigger volume one time for each character and call different functions one for each team. This way you make sure you know which character triggered the trigger volume since each character has a unique team and a unique trigger volume function.
 
On Windows, you can take advantage of the [[Daodan DLL]]'s custom function <tt>d_getindex(string ai_name)</tt> and compare by ID.
{{divhide|&nbsp;Example: fire detection in Airport level (remove existing IGMD\Airport\*.bsl files and use a custom main.bsl with the following content)|align=left}}
func void fire_damage(string ai_name)
{
var int index = d_getindex(ai_name);
var int index0 = d_getindex(char_0);
var int index1 = d_getindex(LoadingBay_Thug_1);
var int index2 = d_getindex(LoadingBay_Thug_2);
if(index eq index0)
dmsg "Konoko is burning!"
if(index eq index1)
dmsg "Thug 1 is burning!"
if(index eq index2)
dmsg "Thug 2 is burning!"
}
func void main(void)
{
ai2_spawn LoadingBay_Thug_1
ai2_spawn LoadingBay_Thug_2
chr_location 0 134 -105 1029
}
{{divhide|end}}


====chr_poison bug====
====chr_poison bug====