Frictional Games Forum (read-only)
[SCRIPT] (Request) Moving Shelf using Secrets Books - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] (Request) Moving Shelf using Secrets Books (/thread-53736.html)

Pages: 1 2


RE: (Request) Moving Shelf using Secrets Books - FlawlessHappiness - 05-08-2017

Without knowing anything about it, I believe "&in" is used when the game istelf feeds you an object as a string. In a collide callback there is no place in the script where you tell call the callback with an object. It just takes any object that collides and passes the naming criteria. So the "&in" part probably means that you're expecting any object.

Technically you do say what you expect in void OnStart, but the function doesn't know that. It just knows that there is a parent and a child, and both could be many different objects.


RE: (Request) Moving Shelf using Secrets Books - Mudbill - 05-08-2017

Here are the docs for it: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_func_ref.html

What &in means is that it only acts as input (as you'd expect) and it cannot be modified back out. It basically makes a copy of the original value and lets you play with it locally. It says that it has little benefit other than slight performance improvements in certain cases, especially while also using const.

&out on the other hand is a little more interesting. It lets you modify the direct value that was given. From what I understand, you can do this:

PHP Code:
void OnStart() {
    
int value 5;

    
process(value);

    print(
value);
}

void process(int &out value) {
    
value 10;


Running this would print out 10, whereas if it were &in, it would give you 5. Do you see why?

Also, apologies for going off-topic. OP, you can respond whenever if you got your issue resolved.


RE: (Request) Moving Shelf using Secrets Books - User01 - 05-14-2017

Sorry, have been busy lately. Now I'm back.

(05-07-2017, 02:03 PM)Mudbill Wrote: Well, I opened the map and saw that you didn't name your books correctly. They are named book_moveable_1 instead of book_1 as the script asks for.

I tested it and now it works just fine.
Oops, my bad.

Now I have trouble pulling the books back to the start position, when pulled the wrong book.

I added the AddPropForce (It's the only methode I can think of, correct me I'f I'm wrong) in a timer at the wrong book event.
PHP Code:
void PullBook(string &in asParentstring &in asChildint alState) {
    if(
asParent == StringSub(asParent0asParent.length() - 1) + bookCounter) {
        
AddDebugMessage("Pulled the correct book. Number: " bookCounterfalse);
        
bookCounter++;
    } else {
        
AddDebugMessage("Pulled the wrong book. Number: " bookCounterfalse);
        
bookCounter 1;
        
AddTimer(""0.1f"resetbook");
    }

    if(
bookCounter 3) {
        
AddDebugMessage("Completed the puzzle!"false);
        
SetMoveObjectState("shelf_secret_door_1"1);
    }


void resetbook(string &in asTimer)
{
        
PlayGuiSound("wrong_book.ogg"1.0f);
        
AddPropForce("book_1"00, -180"world");
        
AddPropForce("book_2"00, -180"world");
        
AddPropForce("book_3"00180"world");




RE: (Request) Moving Shelf using Secrets Books - Mudbill - 05-14-2017

Does ResetProp not work? Because I'm a bit unsure if the prop force will work due to how the physics works on the book.


RE: (Request) Moving Shelf using Secrets Books - User01 - 05-14-2017

Oh, I completely forgot about ResetProp. Thanks.