Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help
TheDanny942 Offline
Junior Member

Posts: 20
Threads: 7
Joined: Dec 2011
Reputation: 0
#1
Help

I need some help with my .hps file. I need to know how to separate multiple scripts (I'm an amateur I know). It keeps giving me an error message that says there was an unexpected token {. Here is my script file, and I thank you so much in advance for helping a amateur out. Big Grin
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "BasementDoorKey", "BasementDoor", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("BasementDoor", false, true);
PlaySoundAtEntity("", "unlock_door", "BasementDoor", 0, false);
RemoveItem("BasementDoorKey");
}
{
AddEntityCollideCallback("Player", "Scary", "CollideScary", true, 1);
}

void CollideScary(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("ScareDoor", true, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
01-23-2012, 02:41 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#2
RE: Help

Ok, here you go.


void OnStart()
{
AddUseItemCallback("", "BasementDoorKey", "BasementDoor", "UsedKeyOnDoor", true);//THIS IS A CALLBACK COMMAND
AddEntityCollideCallback("Player", "Scary", "CollideScary", true, 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("BasementDoor", false, true);
PlaySoundAtEntity("", "unlock_door", "BasementDoor", 0, false);
RemoveItem("BasementDoorKey");
}

void CollideScary(string &in asParent, string &in asChild, int alState)//THIS IS THE SYNTAX
{
SetSwingDoorClosed("ScareDoor", true, true);//THIS IS THE FUNCTION
}


When you create a CALLBACK, it means that your going to call it back later on. Seeing as you have no timers or any other slightly more complex Functions, all your callbacks(for now) will go in the void OnStart

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-23-2012, 02:58 AM by Tripication.)
01-23-2012, 02:46 AM
Find
TheDanny942 Offline
Junior Member

Posts: 20
Threads: 7
Joined: Dec 2011
Reputation: 0
#3
RE: Help

(01-23-2012, 02:46 AM)Tripication Wrote: Ok, here you go.


void OnStart()
{
AddUseItemCallback("", "BasementDoorKey", "BasementDoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "Scary", "CollideScary", true, 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("BasementDoor", false, true);
PlaySoundAtEntity("", "unlock_door", "BasementDoor", 0, false);
RemoveItem("BasementDoorKey");
}

void CollideScary(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("ScareDoor", true, true);
}


When you create a CALLBACK, it means that your going to call it back later on. Seeing as you have no timers or any other slightly more complex Functions, all your callbacks(for now) will go in the void OnStart
Thanks a ton man! So whenever I create a new callback, I should put it with the others, below onstart?


01-23-2012, 02:54 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#4
RE: Help

Yes,Anything thats not in a Syntax goes in the original voids(OnStart, OnLeave, OnEnter ect.)everything else goes in the syntax for the callback. I'm not very good at explaining things like this, mainly because i haven't hd very much experience with it myself, but thats what the forum and wiki are for, help.

I'll edit my original post.
If you still dont understand, dont worry. Im really phasy with this stuff too, so you'd probably be better off asking someone like Statyk, flamez or Elven, they helped me alot with understanding.

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-23-2012, 03:03 AM by Tripication.)
01-23-2012, 02:57 AM
Find
TheDanny942 Offline
Junior Member

Posts: 20
Threads: 7
Joined: Dec 2011
Reputation: 0
#5
RE: Help

(01-23-2012, 02:57 AM)Tripication Wrote: Yes,Anything thats not in a Syntax goes in the original voids(OnStart, OnLeave, OnEnter ect.)everything else goes in the syntax for the callback. I'm not very good at explaining things like this, mainly because i haven't hd very much experience with it myself, but thats what the forum and wiki are for, help.

I'll edit my original post.
If you still dont understand, dont worry. Im really phasy with this stuff too, so you'd probably be better off asking someone like Statyk, flamez or Elven, they helped me alot with understanding.
Thanks for being so patient with a novice like myself Tongue So the syntax is all the script that go between {}? EDIT Just realized you posted it, thanks!

(This post was last modified: 01-23-2012, 03:08 AM by TheDanny942.)
01-23-2012, 03:07 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#6
RE: Help

thats ok and No, not really. Heres an example.

void OnStart//YOUR MAIN VOID
{
SetEntityPlayerInteractCallback("ENTITY", "FUNCTION01", (remove after 1 use[true/false]);//THE CALLBACK(EXPECTED TO BE "CALLED BACK" LATER ON)
}


void FUNCTION01(string &in asEntity)//THIS IS THE SYNTAX, THE FUNTION THE SYNTAX PLANS TO USE IS COLOURED WITH AQUA BLUE.

{
SetEntityActive("grunt", true);//THIS IS THE COMMAND THAT WILL BE CALLED, BECAUSE IT IS INSIDE { }, IT MUST HAVE A SEMICOLAN AFTER THE LINE OF CODE(Wink
}








And i'll try to explain a bit more down here.


Starting from the top, The void onstart, is whatever will be loaded AS SOON as the map is loaded.


Then, when the Player(SetEntityPlayerInteractCallback) interacts with a certain entity(SetEntityPlayerInteractCallback) on the map, it will call(SetEntityPlayerInteractCallback)a function. But ONLY when the player interacts with that entity, wich could be in half an hour or 2 minutes. Whenever.

For example.
When a player interacts with a door called CellarDoor, it will call a function(named whatever you want)called SpawnGrunt, and then once it has happened, it will remove that function from the void OnStart once(true)

void OnStart()
{
SetEntityPlayerInteractCallback("CellarDoor", "SpawnGrunt", true);
}

And as for the rest of it(syntax and the Actual function that will spawn the grunt)

void SpawnGrunt(string &in asEntity)
{
SetEntityActive("Grunt", true);
}

Another example for comparison.
In this case, we have a lever named Lever somewhere on the map. If the player interacts with this Lever it will call a function called GiveSanity and that function will NOT be removed ever from the void OnStart because we have the AutoRemoval set to false.

void OnStart
{
SetEntityPlayerInteractCallback("Lever", "GiveSanity", false);
}

The rest of the function(Were using the same callback so its the same syntax, if we were using a different callback, the syntax would be different aswell.)


void GiveSanity(string &in asEntity)
{
GiveSanityBoostSmall();//THIS GIVES THE PLAYER A VERY SMALL SANITY INCREASE
}


I'm sorry if its still very difficult to understand, its not one of the simplest scripts to get around, but give it a day or two of practise and you'll start to really understand it.

Im sorry if there is a bunch of typos and errors in the HTML, thats what happens when you copy and paste from the script functions page, an write long replies
A few more useful tips, make sure you have Debug mode setup so you can reload the map ingame, without having to quit the map and play through until you got to the bit your working on.

And you may very well want to check out Apjjm's Notepad++ plugin, he's a hero.
http://www.frictionalgames.com/forum/thread-9783.html

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-23-2012, 03:39 AM by Tripication.)
01-23-2012, 03:31 AM
Find




Users browsing this thread: 1 Guest(s)