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


Thread Rating:
  • 5 Vote(s) - 2.8 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The meaning of Parameters
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
The meaning of Parameters

Have you ever wondered what it is when people talk about a parameter?
Don't you know how it works? Well, I'll tell you.

A parameter is the little amount of text inside these ( Parameter)
They always come after: void function() <-- parameter goes in here
parameters are used to specify what kind of callback you want.

Here are some common examples:

AddEntityCollideCallback
Colliding = (string &in asParent, string &in asChild, int alState)

Spoiler below!

Because:
asParent = 1st object
asChild = 2nd object
alState = How do they collide? When 1 goes inside? When 1 goes outside? Both?

SetEntityPlayerInteractCallback
Interacting = (string &in asEntity)

Spoiler below!

Because:
asEntity = The entity you interact with. There can only be 1 thing that is cabable of interacting and that is the player.

AddUseItemCallback
Use Item = (string &in asItem, string &in asEntity)

Spoiler below!

Because:
asItem = The item you use.
AsEntity = The entity you use it on

SetEntityPlayerLookAtCallback
Look-at function = (string &in asEntity, int alState)

Spoiler below!

Because:
asEntity = The entity you look at
alState = Defining if you are: Looking at it? Looking away from it? Both?


CheckPoint
Checkpoint function = (string &in asName, int alCount)

Spoiler below!

Because:
asName = The name of the Checkpoint.
alCount = How many times you have respawned at that checkpoint.

AddTimer
Timer function = (string &in asTimer)

Spoiler below!

Because:
asTimer = The name of the timer.

SetEntityCallbackFunc
SetEntityCallbackFunc = (string &in asEntity, string &in asType)

Spoiler below!

Because:
asEntity = The entity you are specifying.
asType = Which kind of callback are you wanting? OnPickup? Break? OnIgnite?

Now these parameters are commonly used in scripts and if-statements.
If you don't know what an if-statement is then you should check that out first, because that will make your scripting even better!
I will give you some function examples for each of the codes i have listed above:

AddEntityCollideCallback("Player", "ScriptArea_1", "CollideFunction", true, 0);
Spoiler below!

void CollideFunction(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
//Do something if the player is walking into the script area.
//How about a screen effect?
FadeImageTrailTo(1, 1);
}
if(alState == -1)
{
//Do something when the player leaves the script area
FadeImageTrailTo(0, 1);
}
}

SetEntityPlayerInteractCallback("ScriptArea", "InteractFunction", true);
Spoiler below!

void InteractFunction(string &in asEntity)
{
//First we do stuff
FadeImageTrailTo(1, 1);
//And then we set the entity, that we just interacted with, inactive
SetEntityActive(asEntity, false);
}

**Notice that in the next function there is 2 items, but only 1 script area**
AddUseItemCallback("", "Item_1", "ScriptArea_1", "UseItemFunction", true);
AddUseItemCallback("", "Item_2", "ScriptArea_1", "UseItemFunction", true);
Spoiler below!

void UseItemFunction(string &in asItem, string &in asEntity)
{
if(asItem == "Item_1")
{
//Do stuff if you used Item_1
}
if(asItem == "Item_2")
{
//Do stuff if you used Item_2
}
}

CheckPoint("", "PlayerStartArea_1", "CheckpointFunction", "DeathHints", "Entry_1");
Spoiler below!

void CheckpointFunction(string &in asName, int alCount)
{
if(alCount == 5)
{
//Do stuff if you respawned 5 times
}
}

**Notice that "asTimer" is the same as "asName"**
**Also notice that I am calling 2 timers. The first is called in 5 seconds. The second is called in 10 seconds. Both of them is calling the same function, but they have different asName**

AddTimer("Timer_1", 5, "TimerFunction");
AddTimer("Timer_2", 10, "TimerFunction");
Spoiler below!

void TimerFunction(string &in asTimer)
{
if(asTimer == "Timer_1")
{
//Do stuff after 5 sconds
}
if(asTimer == "Timer_2")
{
//Do stuff after 10 seconds
}
}

**Notice that in this script i am interacting with a candle, but it could have been a lot of other stuff... Though the Onignite only works on candles (I guess)**
SetEntityCallbackFunc("candle_1", "CallbackFunction");
Spoiler below!

void CallbackFunction(string &in asEntity, string &in asType)
{
if(asType == "OnIgnite")
{
//Do stuff when you light the candle, but only if you light the candle!
}
}


Trying is the first step to success.
(This post was last modified: 12-01-2012, 07:47 PM by FlawlessHappiness.)
09-16-2012, 03:44 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: The meaning of Syntaxes

Note: Syntax is the rules of the language. While parameters and arguments concern syntax, syntax is not limited to just that.

Tutorials: From Noob to Pro
09-16-2012, 04:32 PM
Website Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#3
RE: The meaning of Syntaxes

Do you even know the meaning of the word Syntax?
Quote:A syntax(...)
----

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
09-16-2012, 05:01 PM
Find
Melvin Offline
Member

Posts: 245
Threads: 38
Joined: Jun 2012
Reputation: 5
#4
RE: The meaning of Syntaxes

Thanks for this information!

[Image: 25F7U37.png]
09-16-2012, 05:30 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: The meaning of Syntaxes

(09-16-2012, 05:01 PM)nemesis567 Wrote: Do you even know the meaning of the word Syntax?
Quote:A syntax(...)
----
No i do not know the precise definition of the word "Syntax", but since i couldn't find any thread about these, and more and more people have been asking about this, i felt i should do something. Thats why i made this. And so what if they use the wrong word in a wrong context, as long as people understand each other, and they are only making custom stories for fun!
I just wanted to make a tutorial that was easy to understand. Smile

Trying is the first step to success.
09-16-2012, 05:46 PM
Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#6
RE: The meaning of Syntaxes

Avoiding any further conflict I must say that from the two ways of learning something, it's quite better to use the plain rock one, instead of walking over sand.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
09-16-2012, 07:33 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: The meaning of Syntaxes

Yea, you might be right Smile That was also how i learned it... But there is just people out there who takes a bridge at one place, copy it, and then crosses the hole without knowing what they did, why they get an error, or why it doesnt work Smile I understand what you mean Smile And if i did a bad thing, i am sorry Smile

Trying is the first step to success.
09-16-2012, 07:47 PM
Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#8
RE: The meaning of Syntaxes

You didn't do a bad thing if you felt you did the right thing.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
09-17-2012, 12:41 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: The meaning of Syntaxes

No that sounds about right Smile

Trying is the first step to success.
09-17-2012, 07:41 AM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#10
RE: The meaning of Syntaxes

(09-16-2012, 07:47 PM)beecake Wrote: Yea, you might be right Smile That was also how i learned it... But there is just people out there who takes a bridge at one place, copy it, and then crosses the hole without knowing what they did, why they get an error, or why it doesnt work Smile I understand what you mean Smile And if i did a bad thing, i am sorry Smile
Sorry for bumping this, but I felt that I had to do it: This post has the smiley : ) amount record.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
(This post was last modified: 11-26-2012, 06:00 PM by The chaser.)
11-26-2012, 06:00 PM
Find




Users browsing this thread: 3 Guest(s)