Skip to content

Current questions and answers regarding the map editor.

User Avatar
#5225
Auto-translated
}{0TT@6bI4

[/U]I encountered the following problem: this code snippet
print(GetGameVar("morale_bonus")); */Outputs 0 to the console/*
-------------------------
if GetGameVar("morale_bonus")==0 then
my_talkbox_params=
{
icon="/PATH_TO_MAP/BonusGeneratorIcon.xdb#xpointer(/Texture)",
name="BonusGeneratorName.txt",
text="BonusGenerator_ChooseAmount.txt",
ans1="Add_1.txt",
ans2="Add_2.txt",
ans3="Add_3.txt",
func="BonusGenerator_Callback_2"
};
TalkBoxWith3A2(my_talkbox_params);
BonusType= HERO_BATTLE_BONUS_MORALE;
elseif GetGameVar("morale_bonus")~=0 then
print(GetGameVar("morale_bonus")); */Also outputs 0 to the console/*
MessageBox(path.."YouAlreadyHaveThisBonus.txt", "BonusGenerator");
end;
-------------------------
displays the message "YouAlreadyHaveThisBonus.txt", which is located in the block that is executed if the variable is not equal to zero, but in the same block, the print statement outputs that the variable's value is 0 (!)

I would be very grateful if someone could explain what is wrong here:smile35: :smile15:

GetGameVar returns a string value, i.e., '0'. To correctly compare this value with a number, you should write it like this:
if (GetGameVar("morale_bonus") + 0) == 0 then...
Нет войне.

Statistics

Welcome our newest member: artem

Users Online 2 users 1511 guests