Frictional Games Forum (read-only)

Full Version: error in "for" ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys

Its first time im using "for" scripts, but so fare i can see nothing is wrong, but the games keep saying that my "for" needs 2 ; but i cant see it.

////////////////////
//When entering map
void OnEnter()
{
//Slime
If(HasItem("glass_container_mix_done"))
for(int i=1;i<=22;i++)
{
SetEntityActive("Slime_"+i, true);
PlaySoundAtEntity("", "guardian_activated1.ogg", "Player", 0, false);
StartScreenShake(0.1, 8, 2, 2);
SetEntityActive("SlimeDamageArea_1", true);
SetEntityActive("SlimeDamageArea_2", true);
SetEntityActive("SlimeDamageArea_3", true);
SetEntityActive("SlimeDamageArea_4", true);
}

//Keys
AddUseItemCallback("", "CellerKey", "level_celler_1", "UsedKeyOnDoor", true);

//Quests
AddEntityCollideCallback("Player", "QuestArea", "SlimeQuest", true, 1);
AddUseItemCallback("" "glass_container_mix_done", "web_1", "SlimeQuestEnd", true);
}

Hope you guys will help
Try putting brackets around what goes in the if, like so

If(HasItem("glass_container_mix_done"))

{
for(int i=1;i<=22;i++)

{

SetEntityActive("Slime_"+i, true);

PlaySoundAtEntity("", "guardian_activated1.ogg", "Player", 0, false);

StartScreenShake(0.1, 8, 2, 2);

SetEntityActive("SlimeDamageArea_1", true);

SetEntityActive("SlimeDamageArea_2", true);

SetEntityActive("SlimeDamageArea_3", true);

SetEntityActive("SlimeDamageArea_4", true);

}

}

Also, from what I see so far, SetEntityActive("Slime_"+i, true); is the only script that really has any business being in the for.
the If(HasItem("glass_container_mix_done")) has to be if(HasItem("glass_container_mix_done")) with a lowercase i.
Remember, C++ is case-sensitive.
////////////////////

//When entering map

void OnEnter()

{
Spoiler below!


//Slime

If(HasItem("glass_container_mix_done"))

for(int i=1;i<22;i++)

{

SetEntityActive("Slime_"+i, true);

PlaySoundAtEntity("", "guardian_activated1.ogg", "Player", 0, false);

StartScreenShake(0.1, 8, 2, 2);

SetEntityActive("SlimeDamageArea_1", true);

SetEntityActive("SlimeDamageArea_2", true);

SetEntityActive("SlimeDamageArea_3", true);

SetEntityActive("SlimeDamageArea_4", true);

}



//Keys

AddUseItemCallback("", "CellerKey", "level_celler_1", "UsedKeyOnDoor", true);



//Quests

AddEntityCollideCallback("Player", "QuestArea", "SlimeQuest", true, 1);

AddUseItemCallback("" "glass_container_mix_done", "web_1", "SlimeQuestEnd", true);

}

There was an unecessary "=".
(10-06-2012, 03:44 PM)The chaser Wrote: [ -> ]There was an unecessary "=".
Nah not really, <= x is the same as ≤x which means smaller than or equal as x.
i<=22 is not the same as i<22
The first one repeats 22 times and the second one only 21 times.
THanks guys

Now my only problem is that there is no mathcing signatures to AddUseItemCallback("glass_container_mix_done", "web_1", "SlimeQuestEnd", true);


void OnEnter()
{
AddUseItemCallback("glass_container_mix_done", "web_1", "SlimeQuestEnd", true);

}


void SlimeQuestEnd(string &in asItem, string &in asEntity)
{
CompleteQuest("slimeblockquest", "SlimeBlockQuest");
GiveSanityBoostSmall();
PlaySoundAtEntity("", "puzzle_acid.ogg", "web_1", 0, false);
SetPropActiveAndFade("web_1", false, 4);
}
(10-06-2012, 03:49 PM)ZereboO Wrote: [ -> ]THanks guys

Now my only problem is that there is no mathcing signatures to AddUseItemCallback("glass_container_mix_done", "web_1", "SlimeQuestEnd", true);


void OnEnter()
{
AddUseItemCallback("glass_container_mix_done", "web_1", "SlimeQuestEnd", true);

}


void SlimeQuestEnd(string &in asItem, string &in asEntity)
{
CompleteQuest("slimeblockquest", "SlimeBlockQuest");
GiveSanityBoostSmall();
PlaySoundAtEntity("", "puzzle_acid.ogg", "web_1", 0, false);
SetPropActiveAndFade("web_1", false, 4);
}
It should be:

Spoiler below!

AddUseItemCallback("glass_container_mix_done", "web_1", "SlimeQuestEnd", true);


void OnEnter()
{
AddUseItemCallback("", "glass_container_mix_done", "web_1", "SlimeQuestEnd", true);

}


void SlimeQuestEnd(string &in asItem, string &in asEntity)
{
CompleteQuest("slimeblockquest", "SlimeBlockQuest");
GiveSanityBoostSmall();
PlaySoundAtEntity("", "puzzle_acid.ogg", "web_1", 0, false);
SetPropActiveAndFade("web_1", false, 4);
}



Its working now

Thanks guys