Frictional Games Forum (read-only)

Full Version: How make this script? (SOLVED)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hi Guys!

So, my question is - how make script when my character says *text*, when i enter in script area (box). It will be his thought.

Thanks for all help tips Smile
Bye! Wink
I understand you want some text to appear when the character walks into an area?
That should be simple.

First, create the ScriptArea in your level.

In your script, within your OnStart function, add a collision callback between the player and the area, like so:

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("ScriptArea""Player""CallbackName"true1);


Make sure "ScriptArea" matches the name of your in-level area. "CallbackName" can be whatever as long as it matches below.

Below that, create the callback which tells the script what will happen when these two collide. Use SetMessage to display some text in the middle of the screen.

PHP Code:
void CallbackName(string &in asParentstring &in asChildint alState)
{
    
SetMessage("MessageCategory""MessageEntry"0);


"MessageCategory" refers to a category within your extra_english.lang file. "MessageEntry" refers to an entry within that category. Are you familiar with the lang file?

It should look somewhat like this in your lang file, but you might already have some of it. If that's the case, exclude it from here:

PHP Code:
<LANGUAGE>
    <
CATEGORY Name="CategoryName">
        <
Entry Name="EntryName">Put the text that you want to display inside here.</Entry>
    </
CATEGORY>
</
LANGUAGE

Most likely you already have the <LANGUAGE> tags in your lang file. If so, don't add them again.
Mmm.... where is wrong?
https://scr.hu/0unb/cqb3l

This AddUseItemCallback is other script.
The error is the location of your CollideCallback, since it's not within a void, it will be considered an error. Since you're using rather simple code, having it in OnStart() is perfectly valid.

Therefore, to put your AddEntityCollideCallback into the OnStart parentheses, we do something like the following;

PHP Code:
void OnStart()
{
    
AddUseItemCallback("""key1""door1""UseKeyOnDoor"true);
    
AddEntityCollideCallback("Player""ScriptArea""Skyrpt1"true1);
}

//rest of code below 

Make sure to change CallbackName to the name of your callback as well, which in this case, is Skyrpt1, since that is defined in your AddEntityCollideCallback().

Also, welcome to the forums! Just a friendly reminder to post any coding issues with Amnesia in the Development Support subforum. I have moved the thread over to there now.
Since you already have an OnStart function, you need to place the AddEntityCollideCallback line inside its brackets. You can't have a new script block without a heading.


Ninja'd Tongue
Ok, i have this:

void OnStart()
{
AddUseItemCallback("", "key1", "door1", "UseKeyOnDoor", true);
AddEntityCollideCallback("ScriptArea", "Player", "Skrypt1", true, 1);
}

In game my script area is Skrypt 1, but this not work.

In lang file i have:
<CATEGORY Name="CategoryName">
<Entry Name="EntryName">My Text</Entry>
</CATEGORY>

@edit sorry for me, but i am completely green in scripts Wink
Could you post your whole script?
This is all script file:

void OnStart()
{
AddUseItemCallback("", "key1", "door1", "UseKeyOnDoor", true);
AddEntityCollideCallback("ScriptArea", "Player", "Skrypt1", true, 1);
}

void CallbackName(string &in asParent, string &in asChild, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0);
}


void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);

SetLocalVarInt("Switch", 1);
CompleteQuest("door1", "mementos1");

}

void TouchDoor(string &in asEntity)
{
if(GetLocalVarInt("Switch") == 0)
{
AddQuest("door1", "mementos1");
}
}


And Lang (i no write my text, you know Tongue)

<CATEGORY Name="CustomStoryMain">
<Entry Name="Description"> Description custom story </Entry>
</CATEGORY>

----------Notatki/Myśli----------
<CATEGORY Name="Journal">

<Entry Name="Note_voice_Name">Name Note</Entry>
<Entry Name="Note_voice_Text">[voice Voice1.ogg][br] Text</Entry>


<Entry Name="Quest_mementos1_Text">I must find key in bathroom.</Entry>
</CATEGORY>

----------Nazwy I Opisy Przedmiotów----------
<CATEGORY Name="Inventory">
<Entry Name="ItemName_KeyDesc"> Bathroom Key</Entry>
<Entry Name="ItemDesc_KeyDesc"> Old, dusty key. Used of peple thereof manor house.</Entry>

</CATEGORY>
<CATEGORY Name="CategoryName">
<Entry Name="EntryName">My text</Entry>
</CATEGORY>

</LANGUAGE>
You must change the name of this callback to match what you put inside the AddEntityCollideCallback();

PHP Code:
void CallbackName(string &in asParentstring &in asChildint alState)
{
SetMessage("MessageCategory""MessageEntry"0);


So make it like so:

PHP Code:
void Scrypt1(string &in asParentstring &in asChildint alState)
{
SetMessage("MessageCategory""MessageEntry"0);

I have:
void OnStart()
{
AddUseItemCallback("", "key1", "door1", "UseKeyOnDoor", true);
AddEntityCollideCallback("Player", "ScriptArea", "Scrypt1", true, 1);
}

void Scrypt1(string &in asParent, string &in asChild, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0);
}

But this not work in game.
Pages: 1 2 3