Frictional Games Forum (read-only)

Full Version: Error expected method or property
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
When the launch his mod, I get here this error:[img][Image: bandicam20_4823027_15847164.jpg][/img]

PHP Code:
const string BUTTONS_GO_TIMER "BUTTONS_GO_TIMER_CALLBACK"
 
 class 
ButtonsGo
    
{

            if(
event.KeyInput.PressedDown == true)
            {

                if (
event.KeyInput.Key==KEY_KEY_A)
                    
left=true;
                    {
                    
AddPropForce("barrel01_1"00300"World");
                    
AddPropImpulse("barrel01_1"005000"world");
                    }
                    
            if(
event.KeyInput.PressedDown == false)
            {

                if (
event.KeyInput.Key==KEY_KEY_A)
                    
left=false;
                    {
                    
AddPropForce("barrel01_1"00, -300"World");
                    
AddPropImpulse("barrel01_1"00, -5000"world");
                    }
                }

     }
     
     
ButtonsGo Buttons_obj_1;

void BUTTONS_GO_TIMER_CALLBACK(string &in timer_name)
    { 
Buttons_obj_1.Update(timer_name); } 
Could you explain more of what's going on here? Are you saying you're having a syntax issue with your script?
(01-31-2015, 09:24 PM)Mudbill Wrote: [ -> ]Could you explain more of what's going on here? Are you saying you're having a syntax issue with your script?
How do I know, can write completely your function on C++.I decided to write a function,that happening,during the interaction of keyboard keys (pressing and releasing).
I'm not sure if those native functions work for Amnesia. It's not C++ directly, it's AngelScript which is based on it. Even if the core engine uses those native functions, I don't think you can call them from the map's hps file. I might be wrong, but I have never seen anyone use it, so I assume there's a reason for that.
As far as I know, there is no way to use conditional key press queries in Amnesia. The only one you can do is F, which is of course, the Lantern, through SetLanternLitCallback(); and/or GetLanternActive();

That's all the information I can give though.
Well, for one, you can't use C++ to write scripts for this game; Amnesia uses a scripting language called AngelScript.
Now, while AngelScript does support classes, there are some limitations, and the syntax is not the same as in C++. Finally, you have a bunch of syntax and logic errors. You can't just put an if-statement directly in a class - your class needs to have member functions, and you put executable code (like your if-statements) within these functions. Specifically, you probably intended to wrap these into the Update member function, since that's what you're calling on the object in the callback. But, there are other problems. You use symbols that are not defined for the game. Then, you have two blocks of code ("{ some_code }") that do not belong to anything, which may or may not be allowed in AngelScript (both under the if-statements with the single-line bodies):
PHP Code:
if (event.KeyInput.Key==KEY_KEY_A)    // <---- the game doesn't know what any of these are
                    
left=false;    //  <---- the if-statement ends right here!
{
    
// any code here has nothing to do with the if-statement above


Also, BUTTONS_GO_TIMER_CALLBACK won't be called by anything, unless you somehow tell the game to do so (and when to do so).

Anyway, have you copied some of the code from a different game? Generally, code written for one game won't work at all with another - different games won't support the same things, and if they do, they will have different names and syntax for the same kins of functions, or they might use an altogether different. There's no cross-engine standardization of that sort.
(02-01-2015, 06:30 AM)TheGreatCthulhu Wrote: [ -> ]Well, for one, you can't use C++ to write scripts for this game; Amnesia uses a scripting language called AngelScript.
Now, while AngelScript does support classes, there are some limitations, and the syntax is not the same as in C++. Finally, you have a bunch of syntax and logic errors. You can't just put an if-statement directly in a class - your class needs to have member functions, and you put executable code (like your if-statements) within these functions. Specifically, you probably intended to wrap these into the Update member function, since that's what you're calling on the object in the callback. But, there are other problems. You use symbols that are not defined for the game. Then, you have two blocks of code ("{ some_code }") that do not belong to anything, which may or may not be allowed in AngelScript (both under the if-statements with the single-line bodies):
PHP Code:
if (event.KeyInput.Key==KEY_KEY_A)    // <---- the game doesn't know what any of these are
                    
left=false;    //  <---- the if-statement ends right here!
{
    
// any code here has nothing to do with the if-statement above


Also, BUTTONS_GO_TIMER_CALLBACK won't be called by anything, unless you somehow tell the game to do so (and when to do so).

Anyway, have you copied some of the code from a different game? Generally, code written for one game won't work at all with another - different games won't support the same things, and if they do, they will have different names and syntax for the same kins of functions, or they might use an altogether different. There's no cross-engine standardization of that sort.
That is, to use only C++?
(02-01-2015, 11:33 AM)Icaab2608 Wrote: [ -> ]
(02-01-2015, 06:30 AM)TheGreatCthulhu Wrote: [ -> ]Well, for one, you can't use C++ to write scripts for this game; Amnesia uses a scripting language called AngelScript.
Now, while AngelScript does support classes, there are some limitations, and the syntax is not the same as in C++. Finally, you have a bunch of syntax and logic errors. You can't just put an if-statement directly in a class - your class needs to have member functions, and you put executable code (like your if-statements) within these functions. Specifically, you probably intended to wrap these into the Update member function, since that's what you're calling on the object in the callback. But, there are other problems. You use symbols that are not defined for the game. Then, you have two blocks of code ("{ some_code }") that do not belong to anything, which may or may not be allowed in AngelScript (both under the if-statements with the single-line bodies):
PHP Code:
if (event.KeyInput.Key==KEY_KEY_A)    // <---- the game doesn't know what any of these are
                    
left=false;    //  <---- the if-statement ends right here!
{
    
// any code here has nothing to do with the if-statement above


Also, BUTTONS_GO_TIMER_CALLBACK won't be called by anything, unless you somehow tell the game to do so (and when to do so).

Anyway, have you copied some of the code from a different game? Generally, code written for one game won't work at all with another - different games won't support the same things, and if they do, they will have different names and syntax for the same kins of functions, or they might use an altogether different. There's no cross-engine standardization of that sort.
That is, to use only C++?

YOU CANNOT USE SOME C++ STUFF
The general syntax is the only real similarity to C++. Otherwise, stick to Amnesia compatible code.
(02-01-2015, 03:17 PM)Mudbill Wrote: [ -> ]The general syntax is the only real similarity to C++. Otherwise, stick to Amnesia compatible code.
And this approach?
PHP Code:
#include <iostream>
#include <conio.h>
int main()
{
    
using namespace std;
    
char x;
    
getch();
    switch (
getch()) //перед этим было switch(x)
    
{
    case 
72:
        
cout << "Up" << endl;
        break;
    case 
80:
        
cout << "Down" << endl;
        break;
    case 
75:
        
cout << "Left" << endl;
        break;
    case 
77:
        
cout << "Right" << endl;
        break;
    }
    return 
0;

Pages: 1 2 3