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
Script Help Script help
Vasco Offline
Junior Member

Posts: 12
Threads: 4
Joined: Mar 2012
Reputation: 0
#1
Script help

I'm working on my own Custom story at the moment (actually, this is my first Amnesia CS). I'm not good in scripting, so I already have some questions. For example:
- Is there a way to script an area to call a function when a certain type of entity interacts with it? For example, I put inside an area any random book (not a concrete book with a name "book_that_calls_callback", but a random one) or random barrel, random piece of human arm etc. and this calls a function?
- Is there a way to make a rope area inactive? Or how can I script a situation, when I use a "rope" item near a hole - and a rope appears, that can be used as ladder?
- Is there a way to make a player drop a thing that he is holding in his hands at the moment? For example, the player walks through the corridor having a barrel/chair/book/Stephano/etc in his hand and whenever he goes inside an area - he drops this entity, and he has to grab it once again.
09-14-2012, 12:59 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#2
RE: Script help

Question 1: Yes. Don't understand the random book part.

Question 2: Don't know about rope areas. I worked with ladder areas, but not rope areas.

Question 3: Unsure about that. Try using "ChangePlayerStateToNormal();" (without quotes).

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-14-2012, 01:01 PM
Website Find
Vasco Offline
Junior Member

Posts: 12
Threads: 4
Joined: Mar 2012
Reputation: 0
#3
RE: Script help

(09-14-2012, 01:01 PM)Nemet Robert Wrote: Question 1: Yes. Don't understand the random book part.


I mean, that there is a library full of books in the map, and any of them can call a function if put inside the scriptarea.
09-14-2012, 01:32 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#4
RE: Script help

Well, that may be a bit difficult. You'll have to use the "AddEntityCollideCallback" script on each book.

Like this:

AddEntityCollideCallback("book_1", "ScriptAreaName", "book_1_function", true, 1);

AddEntityCollideCallback("book_2", "ScriptAreaName", "book_2_function", true, 1);


etc.

If you want like "if one book triggers that, the others can no longer" kind of thing, that will need a "Local" or "Global" int. Something that I am working with right now.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 09-14-2012, 01:40 PM by Robby.)
09-14-2012, 01:35 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Script help

You just have to use a for script. I can paste it when i get home...

Trying is the first step to success.
09-14-2012, 01:39 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#6
RE: Script help

Just noticed I typed incorrectly in the previous post. Should be fine now!

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-14-2012, 01:40 PM
Website Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#7
RE: Script help

Question 1:
The solution to this is using a "for loop". That's a script that involves alot of entities, in one line of code. Like this:

Let's say you have added 50 books. You add a "for loop" that involves the numbers 1-50. The integer (shortened "i") is every number between 1 and 50.

PHP Code: (Select All)
for(int i=1;i<50;i++) 

Now we need to add a function.

PHP Code: (Select All)
AddEntityCollideCallback("Book_"+i"ScriptArea""YourFunction"true1); 


Take a look at the AddEntityCollideCallback. Instead of using the name ("Book_1") we added ("Book"+i). And since the "for loop" made the "i" mean any number between 1 and 50, every book that is named ("Book_" and a number between 1 and 50 after the underscore) will call the function "YourFunction" when they collide with the "ScriptArea".

At the end, after adding opening and closing brackets, it should look like this:

for(int i=1;i<50;i++){
AddEntityCollideCallback("Book_"+i, "ScriptArea", "YourFunction", true, 1);
}

Question 2:
The solution to this is the un-check the "Active" check-box in your ladder area, in the editor. That makes it unable to use. After that, you simple need to activate it with this script:

PHP Code: (Select All)
SetEntityActive("LadderArea"true); 


Put that in the script function when they use the rope on the hole.

Question 3:
You can use this script:

PHP Code: (Select All)
ChangePlayerStateToNormal(); 

It will make the player drop the item he is holding. Just copy the line and add it to your function.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
(This post was last modified: 09-14-2012, 02:48 PM by Wapez.)
09-14-2012, 02:33 PM
Find
Vasco Offline
Junior Member

Posts: 12
Threads: 4
Joined: Mar 2012
Reputation: 0
#8
RE: Script help

Wow, that's great! Thanks =D Thanks to everyone. I've been working on my CS for nearly a month, and these scripts were the most difficult.
(This post was last modified: 09-14-2012, 04:03 PM by Vasco.)
09-14-2012, 04:01 PM
Find




Users browsing this thread: 1 Guest(s)