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
Problem adding a diary page (i'm nooby)
Fetishman Offline
Junior Member

Posts: 42
Threads: 3
Joined: Aug 2011
Reputation: 7
#1
Problem adding a diary page (i'm nooby)

Hello, I'm making my first real map, and I haven't been able to find ANY tutorials on adding diary entries. So basically, I'm playing it by ear. When I run my map, the error that shows is a fatal error on line 15,28.


Here is the segment of code that I have.

[Image: scriptproblem.png]

Note: The name of the diary page is "diarypage1" and the CustomSubItemTypeName is "servantdiary".

Some help in this matter would be appreciated.
(This post was last modified: 08-22-2011, 03:53 AM by Fetishman.)
08-22-2011, 03:12 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Problem adding a diary page (i'm nooby)

Your main issue deals with syntax errors. In order to help you solve your own problems, you would have to learn how to properly define a function, how to properly declare variables, how to properly call a function, et cetera; pretty much, you'd have to learn a few things about programming. I'm not going to try to teach you everything (since there are better places to learn from than from me), but i'll mention a couple of things.

Variables

Think of a variable as a container for data. Each variable contains a specific type of data (search "data types"). A valid variable name consists of letters, which could also include either underscores (_) and numbers. When storing information in a variable, you must specify the type of data you're storying (again, see "data types").

Example:
int number = 0;
string text = "some text";
float number_2 = 2.0;

Functions

A function can be considered a group of statements that can be executed by calling the function. A function can be declared with or without parameters. Parameters are a comma-delimited list of expressions. An expression is basically a line of code to be executed (usually ending with a semicolon). Functions can also return a certain data type.

Example functions:
// Without parameters
void function_name()
{
     // some code here...
}

// With parameters
int function_name(string &in name, int state)
{
     // some code here...
     return state;
}

Calling one of the example functions:
int state = function_name("object_1", 1);
function_name();

In any given script, there cannot be two functions with the same name with the same return type and with the same kind of parameters. This confuses the parser (or compiler) and will toss out an error.

The HPL2 engine (the engine of Amnesia) already has functions reserved for use. Overriding these functions will confuse the engine.

Try to figure out what you did wrong.

Tutorials: From Noob to Pro
08-22-2011, 04:00 AM
Website Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
#3
RE: Problem adding a diary page (i'm nooby)

Hint:

You have more info than you need in each of the peramaters. Take a look at this, and compair it to yours:

(DO NOT USE THIS CODE, IT WONT WORK FOR YOU)
void FirstScriptArea(string &in asParent, string &in asChild, int alState)
{
        SetMessage("Messages", "DerrekMother", 0);
        SetPlayerMoveSpeedMul(0.5f);
        SetPlayerJumpDisabled(true);
        SetPlayerCrouchDisabled(true);
        PlayMusic("EndFile1.ogg", false, 20, 0, 0, true);
}

Now try to see what is different besides the obvious difference in code.

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

08-22-2011, 05:06 AM
Website Find
Fetishman Offline
Junior Member

Posts: 42
Threads: 3
Joined: Aug 2011
Reputation: 7
#4
RE: Problem adding a diary page (i'm nooby)

(08-22-2011, 05:06 AM)JetlinerX Wrote: Hint:

You have more info than you need in each of the peramaters. Take a look at this, and compair it to yours:

(DO NOT USE THIS CODE, IT WONT WORK FOR YOU)
void FirstScriptArea(string &in asParent, string &in asChild, int alState)
{
        SetMessage("Messages", "DerrekMother", 0);
        SetPlayerMoveSpeedMul(0.5f);
        SetPlayerJumpDisabled(true);
        SetPlayerCrouchDisabled(true);
        PlayMusic("EndFile1.ogg", false, 20, 0, 0, true);
}

Now try to see what is different besides the obvious difference in code.

Thanks for your initial reply! I have made a few changes after looking thought what you have said. This is what I have:
void SetEntityCallbackFunc("diarypage1", "OnPickup")
{
    OnPickup("servantdiary", "AddDiary");
    AddDiary("servantdiary_Name" && "servantdiary_Text", "");
}

Now the error says that it is "Expected data type." Does this mean I have to indicate whether it is int, f, bool, or string?[/code]
08-22-2011, 04:51 PM
Find




Users browsing this thread: 1 Guest(s)