ApeCake
Member
Posts: 116
Threads: 20
Joined: Jun 2012
Reputation:
4
|
Multiple use of a void OnStart, need help D:
Hi guys, I am new to scripting and I am currently trying out almost all the script on the wiki. However, most of the ones I want to use require void OnStart(). This didn't seem like a problem to me, but I somehow can't get multiple scripts to work with void OnStart().
Example;
void OnStart()
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
ShowEnemyPlayerPosition("monster_grunt");
}
//new thing here
{
AddEntityCollideCallback("Player", "Message_1", "Message1", true, 1);
}
void Message1(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "popuptext1", 5);
}
void OnEnter()
{
}
void OnLeave()
{
}
When starting up my map, an error shows up saying ''main (18, 1) : ERR : Unexpected Token '{'.
But when I remove the { and } on 18, another error comes by showing ''main (19, 25) : ERR : Expected indentifier. However, I have no idea how to fix this. If this is the way to do it, how do I add this 'indentifier? This seems to be so simple! Am I just missing something easy?
I am sorry if this has been asked before, I couldn't find anything like this. Also forgive me for any grammar/spelling errors. Not my native language, you see.
(This post was last modified: 06-22-2012, 08:31 PM by ApeCake.)
|
|
06-09-2012, 10:08 PM |
|
palistov
Posting Freak
Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation:
57
|
RE: Multiple use of a void OnStart, need help D:
Under your line //new thing here is a code block that is out of place. You can't stick blocks of code arbitrarily around, they need an identifier, which essentially says what it is and/or under what circumstances it is run.
|
|
06-09-2012, 10:11 PM |
|
ApeCake
Member
Posts: 116
Threads: 20
Joined: Jun 2012
Reputation:
4
|
RE: Multiple use of a void OnStart, need help D:
(06-09-2012, 10:11 PM)palistov Wrote: Under your line //new thing here is a code block that is out of place. You can't stick blocks of code arbitrarily around, they need an identifier, which essentially says what it is and/or under what circumstances it is run. Yeah, but that part needs to be with void OnStart(). I guess void OnStart() is an indentifier? But if I put void OnStart() there it says I can't put void OnStart() twice...
(This post was last modified: 06-09-2012, 10:44 PM by ApeCake.)
|
|
06-09-2012, 10:43 PM |
|
Ermu
Member
Posts: 86
Threads: 13
Joined: Jan 2012
Reputation:
2
|
RE: Multiple use of a void OnStart, need help D:
(06-09-2012, 10:43 PM)ApeCake Wrote: (06-09-2012, 10:11 PM)palistov Wrote: Under your line //new thing here is a code block that is out of place. You can't stick blocks of code arbitrarily around, they need an identifier, which essentially says what it is and/or under what circumstances it is run. Yeah, but that part needs to be with void OnStart(). I guess void OnStart() is an indentifier? But if I put void OnStart() there it says I can't put void OnStart() twice... You can do this:
put this inside your void OnStart
NewThing();
and then place this anywhere, outside OnStart, OnLeave, and OnEnter
NewThing()
{
}
|
|
06-09-2012, 10:53 PM |
|
JenniferOrange
Senior Member
Posts: 424
Threads: 43
Joined: Jun 2011
Reputation:
33
|
RE: Multiple use of a void OnStart, need help D:
void OnStart()
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
AddEntityCollideCallback("Player", "Message_1", "Message1", true, 1);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
ShowEnemyPlayerPosition("monster_grunt");
}
void Message1(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "popuptext1", 5);
}
void OnEnter()
{
}
void OnLeave()
{
}
That should do it.
Ba-da bing, ba-da boom.
|
|
06-09-2012, 11:04 PM |
|
ApeCake
Member
Posts: 116
Threads: 20
Joined: Jun 2012
Reputation:
4
|
RE: Multiple use of a void OnStart, need help D:
(06-09-2012, 11:04 PM)JenniferOrange Wrote: void OnStart()
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
AddEntityCollideCallback("Player", "Message_1", "Message1", true, 1);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
ShowEnemyPlayerPosition("monster_grunt");
}
void Message1(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "popuptext1", 5);
}
void OnEnter()
{
}
void OnLeave()
{
}
That should do it. Thanks Jennifer! It worked. Love your tutorials!
|
|
06-10-2012, 11:22 AM |
|
KeysOfMyMind
Junior Member
Posts: 15
Threads: 1
Joined: Jan 2012
Reputation:
0
|
RE: Multiple use of a void OnStart, need help D:
So hi guys.
i'm new to scripting and I want this script to work and it should, but it doesn't for some reason.
void OnStart()
{
AddUseItemCallback("", "crowbar_1", "mansiondoor1", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_Joint", "CollideAreaBreakDoor", true, 1);
}
void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}
void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar_joint_1", true);
}
void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("mansiondoor1", false, true);
AddPropImpulse("mansiondoor1", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("mansiondoor1", true);
SetSwingDoorClosed("mansiondoor1", false, false);
SetMoveObjectState("mansiondoor1", 1);
PlaySoundAtEntity("","break_wood_metal", "ScriptArea_Dust", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "ScriptArea_Dust", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}
//Scare Here
{
AddEntityCollideCallback("Player", "push", "Push", true, 1);
AddEntityCollideCallback("Player", "door_slam", "Slam", true, 1);
}
void Push(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "react_pant.snt", "push", 0, false);
AddPlayerBodyForce(30000, 0, 0, false);
}
void Slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansiondoor1", true, true);
SetSwingDoorLocked("mansiondoor1", true, true);
PlaySoundAtEntity("", "00_laugh.snt", "door_scare", 0, false);
}
My scare part crashes the game.
Some help please.
Also I'd like to make it so that I have another area the player hits up against the wall where he collapses and gasps from hitting the wall.
Also the value for the AddPlayerBodyForce propels the player forward, I'd like him to be push backwards into the wall area.
(This post was last modified: 03-16-2013, 03:29 PM by KeysOfMyMind.)
|
|
03-16-2013, 03:27 PM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: Multiple use of a void OnStart, need help D:
(03-16-2013, 03:27 PM)KeysOfMyMind Wrote: So hi guys.
i'm new to scripting and I want this script to work and it should, but it doesn't for some reason.
void OnStart()
{
AddUseItemCallback("", "crowbar_1", "mansiondoor1", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_Joint", "CollideAreaBreakDoor", true, 1);
}
void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}
void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar_joint_1", true);
}
void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("mansiondoor1", false, true);
AddPropImpulse("mansiondoor1", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("mansiondoor1", true);
SetSwingDoorClosed("mansiondoor1", false, false);
SetMoveObjectState("mansiondoor1", 1);
PlaySoundAtEntity("","break_wood_metal", "ScriptArea_Dust", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "ScriptArea_Dust", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}
//Scare Here
{
AddEntityCollideCallback("Player", "push", "Push", true, 1);
AddEntityCollideCallback("Player", "door_slam", "Slam", true, 1);
}
void Push(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "react_pant.snt", "push", 0, false);
AddPlayerBodyForce(30000, 0, 0, false);
}
void Slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansiondoor1", true, true);
SetSwingDoorLocked("mansiondoor1", true, true);
PlaySoundAtEntity("", "00_laugh.snt", "door_scare", 0, false);
}
My scare part crashes the game.
Some help please.
Also I'd like to make it so that I have another area the player hits up against the wall where he collapses and gasps from hitting the wall.
Also the value for the AddPlayerBodyForce propels the player forward, I'd like him to be push backwards into the wall area.
Put the AddEntityCollideCallback parts to your void OnStart(), so that it will look like this.
void OnStart() { AddUseItemCallback("", "crowbar_1", "mansiondoor1", "UsedCrowbarOnDoor", true); AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_Joint", "CollideAreaBreakDoor", true, 1); AddEntityCollideCallback("Player", "push", "Push", true, 1); AddEntityCollideCallback("Player", "door_slam", "Slam", true, 1); }
To make the player to be pushed backwards, change to force from 30000 to -30000.
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
03-16-2013, 03:41 PM |
|
No Author
Posting Freak
Posts: 962
Threads: 10
Joined: Jun 2012
Reputation:
13
|
RE: Multiple use of a void OnStart, need help D:
You could have just create a new thread instead bumping a year old thread.
|
|
03-16-2013, 03:49 PM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: Multiple use of a void OnStart, need help D:
(03-16-2013, 03:49 PM)No Author Wrote: You could have just create a new thread instead bumping a year old thread.
He's a new guy, just get off his back.
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
03-16-2013, 03:51 PM |
|
|