Lizard
Member
Posts: 174
Threads: 23
Joined: Jul 2012
Reputation:
5
error in "for" ?
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
CURRENT PROJECT:
A Fathers Secret == Just started
(This post was last modified: 10-06-2012, 04:04 PM by Lizard .)
10-06-2012, 03:24 PM
Kreekakon
Pick a god and pray!
Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation:
124
RE: error in "for" ?
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.
(This post was last modified: 10-06-2012, 03:41 PM by Kreekakon .)
10-06-2012, 03:39 PM
Ongka
Member
Posts: 225
Threads: 3
Joined: Nov 2010
Reputation:
20
RE: error in "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.
10-06-2012, 03:44 PM
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
RE: error in "for" ?
////////////////////
//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 "=".
THE OTHERWORLD (WIP)
Aculy iz dolan.
10-06-2012, 03:44 PM
Ongka
Member
Posts: 225
Threads: 3
Joined: Nov 2010
Reputation:
20
RE: error in "for" ?
(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.
(This post was last modified: 10-06-2012, 03:49 PM by Ongka .)
10-06-2012, 03:49 PM
Lizard
Member
Posts: 174
Threads: 23
Joined: Jul 2012
Reputation:
5
RE: error in "for" ?
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);
}
CURRENT PROJECT:
A Fathers Secret == Just started
(This post was last modified: 10-06-2012, 03:59 PM by Lizard .)
10-06-2012, 03:49 PM
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
RE: error in "for" ?
(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);
}
THE OTHERWORLD (WIP)
Aculy iz dolan.
10-06-2012, 04:02 PM
Lizard
Member
Posts: 174
Threads: 23
Joined: Jul 2012
Reputation:
5
RE: error in "for" ?
Its working now
Thanks guys
CURRENT PROJECT:
A Fathers Secret == Just started
10-06-2012, 04:04 PM