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


Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add all simple scripts here!
HumiliatioN Offline
Posting Freak

Posts: 1,176
Threads: 62
Joined: Dec 2010
Reputation: 18
#1
Add all simple scripts here!

Okay im making my first map and level editor is easy to use, but i have problems with scripting i just wanna add here some simple scripts example.

- Using item like crowbar with door and combine items?

- Two levels combine doors (I mean hub)

- Enemy trigger some areas and hallucinating enemy, scary door, player insanity some areas

- Lever making with combines door?

- Playing sound some areas.

Okay thats it if i get answered these scripts i thank you so much!

Please Wink

“Life is a game, play it”
(This post was last modified: 12-12-2010, 09:22 PM by HumiliatioN.)
12-12-2010, 09:21 PM
Find Reply
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#2
RE: Add all simple scripts here!

Pretty much everything you asked, is either on the Wiki or on the forum.
search through those first, and ask if you still can't figure it out Smile
12-12-2010, 11:34 PM
Find Reply
HumiliatioN Offline
Posting Freak

Posts: 1,176
Threads: 62
Joined: Dec 2010
Reputation: 18
#3
RE: Add all simple scripts here!

(12-12-2010, 11:34 PM)Akumasama Wrote: Pretty much everything you asked, is either on the Wiki or on the forum.
search through those first, and ask if you still can't figure it out Smile

I searched it but doesnt get it Sad And not working all of these scripts example. Scary door and enemy trigger i need better explanations on these scripts. Plz Angel

“Life is a game, play it”
12-13-2010, 01:43 AM
Find Reply
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#4
RE: Add all simple scripts here!

Well, to start out, try writing it yourself.
We will be glad to help you fix it.

If you just started with scripting, take a look at other scripts to see the structure.
For example, this is how I started: http://frictionalgames.com/forum/thread-5425.html
12-13-2010, 03:43 PM
Find Reply
HumiliatioN Offline
Posting Freak

Posts: 1,176
Threads: 62
Joined: Dec 2010
Reputation: 18
#5
RE: Add all simple scripts here!

(12-13-2010, 03:43 PM)Akumasama Wrote: Well, to start out, try writing it yourself.
We will be glad to help you fix it.

If you just started with scripting, take a look at other scripts to see the structure.
For example, this is how I started: http://frictionalgames.com/forum/thread-5425.html

Okay heres one question: Where i put all scripts because there are 3 areas?

OnStart() What scripts belongs here?

OnEnter() here?

OnLeave() here?

Im confused because i tried OnStart my 3 scripts put but there are couple errors. end of file.. example:

And how i seperate all void codes..

Okay this one is working script: Two doors with open keys.. I get it but.. where i put now Enemy trigger script area?

void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
RemoveItem("key_1");
AddDebugMessage("KeyOnDoor", false);
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}




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

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

“Life is a game, play it”
12-13-2010, 04:02 PM
Find Reply
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#6
RE: Add all simple scripts here!

(12-13-2010, 04:02 PM)HumiliatioN Wrote: OnStart() What scripts belongs here?

OnEnter() here?

OnLeave() here?
OnStart(): The first time you enter an map
OnEnter(): Every time you enter an map
OnLeave(): Whenever you leave the map


(12-13-2010, 04:02 PM)HumiliatioN Wrote: Im confused because i tried OnStart my 3 scripts put but there are couple errors. end of file.. example:
You'll have to give us the errors and/or the script for this one...


(12-13-2010, 04:02 PM)HumiliatioN Wrote: And how i seperate all void codes..
Void basically means that you start a new function.
Like this:
void funcname(syntax){
     stuff you want to happen
}
void funcname2(syntax){
     stuff you want to happen
}


(12-13-2010, 04:02 PM)HumiliatioN Wrote: Okay this one is working script: Two doors with open keys.. I get it but.. where i put now Enemy trigger script area?

void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
RemoveItem("key_1");
AddDebugMessage("KeyOnDoor", false);
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}




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

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Well, the thing I do, is put every function that is NOT in any of the "on---" functions, at the bottom of the script.
This way, you won't have to search in between all of your trigger-functions.
void OnStart()
{
}

////////////////////////////
// Run when entering map

void OnEnter()
{
    AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
    AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true)
}

////////////////////////////
// Run when leaving map

void OnLeave()
{
}

////////////////////////////
// Actual functions

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
    RemoveItem("key_1");
    AddDebugMessage("KeyOnDoor", false);
}    

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_2", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}

I put your key code in OnEnter, because you'd want to be able to open it every time you enter the level, and not just the first time.
Triggers that scare you the first time you enter a map for example, should be placed in OnStart, so it will not trigger again when entering the map for the second time.
12-13-2010, 04:16 PM
Find Reply
HumiliatioN Offline
Posting Freak

Posts: 1,176
Threads: 62
Joined: Dec 2010
Reputation: 18
#7
RE: Add all simple scripts here!

(12-13-2010, 04:16 PM)Akumasama Wrote:
(12-13-2010, 04:02 PM)HumiliatioN Wrote: OnStart() What scripts belongs here?

OnEnter() here?

OnLeave() here?
OnStart(): The first time you enter an map
OnEnter(): Every time you enter an map
OnLeave(): Whenever you leave the map


(12-13-2010, 04:02 PM)HumiliatioN Wrote: Im confused because i tried OnStart my 3 scripts put but there are couple errors. end of file.. example:
You'll have to give us the errors and/or the script for this one...


(12-13-2010, 04:02 PM)HumiliatioN Wrote: And how i seperate all void codes..
Void basically means that you start a new function.
Like this:
void funcname(syntax){
     stuff you want to happen
}
void funcname2(syntax){
     stuff you want to happen
}


(12-13-2010, 04:02 PM)HumiliatioN Wrote: Okay this one is working script: Two doors with open keys.. I get it but.. where i put now Enemy trigger script area?

void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
RemoveItem("key_1");
AddDebugMessage("KeyOnDoor", false);
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}




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

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Well, the thing I do, is put every function that is NOT in any of the "on---" functions, at the bottom of the script.
This way, you won't have to search in between all of your trigger-functions.
void OnStart()
{
}

////////////////////////////
// Run when entering map

void OnEnter()
{
    AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
    AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true)
}

////////////////////////////
// Run when leaving map

void OnLeave()
{
}

////////////////////////////
// Actual functions

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
    RemoveItem("key_1");
    AddDebugMessage("KeyOnDoor", false);
}    

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_2", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}

I put your key code in OnEnter, because you'd want to be able to open it every time you enter the level, and not just the first time.
Triggers that scare you the first time you enter a map for example, should be placed in OnStart, so it will not trigger again when entering the map for the second time.

Okay good now i understand something but i copied that last code what you write and not working Sad Why?

“Life is a game, play it”
12-13-2010, 04:28 PM
Find Reply
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#8
RE: Add all simple scripts here!

void OnStart()
{
}

////////////////////////////
// Run when entering map

void OnEnter()
{
    AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
    AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true);
}

////////////////////////////
// Run when leaving map

void OnLeave()
{
}

////////////////////////////
// Actual functions

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
    RemoveItem("key_1");
    AddDebugMessage("KeyOnDoor", false);
}    

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_2", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}

My bad, forgot the ";" after AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true).
This is also part of what you must learn to do.
Seek out the errors in your script.
Most of the the time, the error message you get, tells you where your error is, and what it's missing/wrong.

In your case, it should say something like: "Expected ";""
12-13-2010, 04:54 PM
Find Reply
HumiliatioN Offline
Posting Freak

Posts: 1,176
Threads: 62
Joined: Dec 2010
Reputation: 18
#9
RE: Add all simple scripts here!

(12-13-2010, 04:54 PM)Akumasama Wrote:
void OnStart()
{
}

////////////////////////////
// Run when entering map

void OnEnter()
{
    AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
    AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true);
}

////////////////////////////
// Run when leaving map

void OnLeave()
{
}

////////////////////////////
// Actual functions

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
    RemoveItem("key_1");
    AddDebugMessage("KeyOnDoor", false);
}    

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door_2", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}

My bad, forgot the ";" after AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true).
This is also part of what you must learn to do.
Seek out the errors in your script.
Most of the the time, the error message you get, tells you where your error is, and what it's missing/wrong.

In your case, it should say something like: "Expected ";""

Oh i see.. Now it works.. hmm this takes time i know these errors but lines are confusing me sometimes. When main errors appears...

Thank you for this tutorial very helpful! I ask more error scripts if something is wrong Smile

“Life is a game, play it”
12-13-2010, 05:00 PM
Find Reply
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#10
RE: Add all simple scripts here!

No problem.
This is how you learn scripting, not asking for stuff out of nowhere Wink
12-13-2010, 05:13 PM
Find Reply




Users browsing this thread: 1 Guest(s)