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 Lever opening bookshelf?
Biscuitbarrel Offline
Junior Member

Posts: 4
Threads: 1
Joined: Apr 2012
Reputation: 0
#1
Lever opening bookshelf?

Hey, I'm working on my first custom story mod. It's more of a practice thing for myself, because I'm just learning scripting for HPL2 and want to understand all the mechanics I can before going into my big project idea.

I've got a hunk of code to fix. I'm trying to make a lever move a bookshelf.

void OnStart()
{
    SetEntityConnectionStateChangeCallback("lever_1, "PullLever");
}

void PullLever(string &in asEntity, int alState)
{
    if (alState == 1)
    {
    AddBodyForce("secret_shelf_1", 0, 0, -3, "world");
    }
}

Can someone tell me exactly what's up? Should I be using AddBodyForce, AddBodyImpulse, AddPropForce, or AddPropImpulse? And what's the difference? Remember, I'm brand-spanking-new to this. Mostly. I have also made a readable note and an unlock-able door.
(This post was last modified: 04-27-2012, 11:41 PM by Biscuitbarrel.)
04-27-2012, 11:40 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#2
RE: Lever opening bookshelf?

I would suggest looking at 01_old_archives in the original Amnesia maps. They have a secret bookshelf there and that code is short and simple Smile

04-27-2012, 11:45 PM
Find
Biscuitbarrel Offline
Junior Member

Posts: 4
Threads: 1
Joined: Apr 2012
Reputation: 0
#3
RE: Lever opening bookshelf?

(04-27-2012, 11:45 PM)SilentStriker Wrote: I would suggest looking at 01_old_archives in the original Amnesia maps. They have a secret bookshelf there and that code is short and simple Smile
:O
It never occurred to me all the original code is right there in the Amnesia folders! I thought it was magically compiled and stuffed into a secret suitcase or something.
This job is now about 600x easier, thank you
04-27-2012, 11:52 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#4
RE: Lever opening bookshelf?

Frictional Games used two general ways of moving the shelves in the game(s).
The first secret door was moved through a direct ConnectEntities() connection made between the state of the bookshelf, and the state of the lever.
The other two were moved through SetMoveObjectState().


Noob scripting tutorial: From Noob to Pro

04-27-2012, 11:53 PM
Find
Biscuitbarrel Offline
Junior Member

Posts: 4
Threads: 1
Joined: Apr 2012
Reputation: 0
#5
RE: Lever opening bookshelf?

I think I understand, but I don't want the shelf to rotate open; I want it to slide open along the z-axis.

This is more in the Level Editor category, but how do I set something like that up?
04-28-2012, 01:43 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#6
RE: Lever opening bookshelf?

(04-28-2012, 01:43 PM)Biscuitbarrel Wrote: I think I understand, but I don't want the shelf to rotate open; I want it to slide open along the z-axis.

This is more in the Level Editor category, but how do I set something like that up?
If by "z-axis" you mean "sideways", then simply use the "shelf_secret_door" entity. It normally slides to the left, but it's easy to rig it to slide to the right by reversing its states.


Noob scripting tutorial: From Noob to Pro

04-28-2012, 01:57 PM
Find
Biscuitbarrel Offline
Junior Member

Posts: 4
Threads: 1
Joined: Apr 2012
Reputation: 0
#7
RE: Lever opening bookshelf?

In Level Editor or otherwise, how do I tell the game where I want the shelf to go? Just saying its state is "1" isn't going to mean anything by itself.

(on a related note, I'd like to complain about how unhelpful the "tutorials" at the wiki are...are there any other resources I can use for info on making Amnesia stories? May I ask where you picked your knowledge up?)
05-10-2012, 11:05 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#8
RE: Lever opening bookshelf?

If a move object's state's amount to 1 for open and 0 for closed, then setting its state to 1 will absolutely open it. As Cranky suggested, check out how Frictional did it in Amnesia. You have their objects, look at how they use them. The direction and amount to move will be set in the model editor, try opening up the object in the model editor and play with the settings to find a something that works for you. Alternatively, just follow Cranky's advice and set it's state to the opposite of whatever state moves it left (if 1 opens it left, set it to -1 and see what happens)

As great as the tutorials are, they are not sufficient for learning 'scripting' in general. People who can work this stuff out for themselves usually have scripting or programming experience outside of HPL2. Keep in mind those tutorials are made by people who are writing or recording a tutorial purely for the benefit of the community. They often assume knowledge on the part of the audiance, because to write every tutorial for someone who has no concept of scripting would be an enormous waste of time. Better you learn from tutorials that cover the basics, then move on to HPL2 tutorials demonstrating more advanced ways of doing things specific to HPL2 scripting.
05-11-2012, 02:06 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#9
RE: Lever opening bookshelf?

(05-10-2012, 11:05 PM)Biscuitbarrel Wrote: are there any other resources I can use for info on making Amnesia stories? May I ask where you picked your knowledge up?)
The YouTube series "From Noob to Pro" helped at first, and from there I picked apart a lot of Amnesia maps. You will need an intelligent and scientific mind too, or else you'll never make sense of any kind of programming.

Noob scripting tutorial: From Noob to Pro

05-11-2012, 02:13 PM
Find
SilentHideButFine Offline
Member

Posts: 156
Threads: 38
Joined: May 2012
Reputation: 6
#10
RE: Lever opening bookshelf?

There is an Tut on dev wiki how to follow that one Smile
05-11-2012, 02:39 PM
Find




Users browsing this thread: 1 Guest(s)