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
How make this script? (SOLVED)
Abihishi Offline
Junior Member

Posts: 44
Threads: 8
Joined: Feb 2016
Reputation: 0
#1
How make this script? (SOLVED)

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
(This post was last modified: 02-19-2016, 03:37 PM by Abihishi.)
02-14-2016, 06:11 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: How make this script?

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: (Select All)
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: (Select All)
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: (Select All)
<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.

(This post was last modified: 02-14-2016, 07:44 PM by Mudbill.)
02-14-2016, 07:41 PM
Find
Abihishi Offline
Junior Member

Posts: 44
Threads: 8
Joined: Feb 2016
Reputation: 0
#3
RE: How make this script?

Mmm.... where is wrong?
https://scr.hu/0unb/cqb3l

This AddUseItemCallback is other script.
(This post was last modified: 02-14-2016, 08:10 PM by Abihishi.)
02-14-2016, 07:57 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: How make this 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: (Select All)
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.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
02-14-2016, 08:32 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: How make this script?

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

(This post was last modified: 02-14-2016, 08:35 PM by Mudbill.)
02-14-2016, 08:34 PM
Find
Abihishi Offline
Junior Member

Posts: 44
Threads: 8
Joined: Feb 2016
Reputation: 0
#6
RE: How make this script?

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
(This post was last modified: 02-14-2016, 08:48 PM by Abihishi.)
02-14-2016, 08:47 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: How make this script?

Could you post your whole script?

02-14-2016, 08:51 PM
Find
Abihishi Offline
Junior Member

Posts: 44
Threads: 8
Joined: Feb 2016
Reputation: 0
#8
RE: How make this 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>
02-14-2016, 08:54 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#9
RE: How make this script?

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

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


So make it like so:

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


02-14-2016, 11:53 PM
Find
Abihishi Offline
Junior Member

Posts: 44
Threads: 8
Joined: Feb 2016
Reputation: 0
#10
RE: How make this script?

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.
02-15-2016, 03:12 PM
Find




Users browsing this thread: 1 Guest(s)