Page 1 of 1

Meaning of cannot convert from 'const int' to 'identifier'?

PostPosted: Thu Jul 21, 2016 1:05 pm
by Turon
I've been trying to rework the current SeaCat (Octopus Game) engine by steelwil to something closer to a normal platformer, something I could build all future platformers with.
the player>draw actor>script editor event had the error "cannot convert from 'const int' to 'identifier':

Code: Select all
    char *key;

    //---------------------------------------
    key = GetKeyState(); // Get entire keyboard state

    if (IsLeft (key))
    {
      ChangeAnimation ("Event Actor", "StandLeft", NO_CHANGE);
      x -= 3;
      action = true;
    }
    if(IsRight (key))
    {
      ChangeAnimation ("Event Actor", "StandRight", NO_CHANGE);
      x +- 3;
      action = true;
    }
    if(IsJump (key))
    {
        if(jump == 1)
        {
          yvelocity = - 8;
          jump = 0;   
        }
        if(IsLeft (key))
        {
          ChangeAnimation ("Event Actor", "JumpLeft", NO_CHANGE);
        }
        else if (IsRight (key))
        {
          ChangeAnimation ("Event Actor", "JumpRight", NO_CHANGE);
        }
    }


The global code is was accepted fine by here it is anways:
Code: Select all
// Actions
#define STAND 0
#define STEP1 1
#define STEP2 2
#define JUMP 3
#define FALL 4
#define SHOOT 5

//Defining keyboard keys
int IsLeft (const char *key)
{
  return (key[KEY_LEFT] == 1 || key[KEY_a] == 1);
}

int IsRight (const char *key)
{
  return (key[KEY_RIGHT] == 1 || key[KEY_d] == 1);
}

int IsJump (const char *key)
{
  return (key[KEY_x] == 1 || key[KEY_k] == 1);
}

Re: Meaning of cannot convert from 'const int' to 'identifie

PostPosted: Thu Jul 21, 2016 9:08 pm
by schnellboot
is there no line number to that error?
pro tip: cut out some part of the code and test it to see what part is the problem

Re: Meaning of cannot convert from 'const int' to 'identifie

PostPosted: Fri Jul 22, 2016 4:38 am
by lcl
If the variables 'action' and 'jump' are properly defined, then the only error I was able to spot at a quick glance was this:

Inside the scope of the condition if (IsRight(key)) there is this error:
Code: Select all
x +- 3;

The line should be:
Code: Select all
x += 3;

Re: Meaning of cannot convert from 'const int' to 'identifie

PostPosted: Fri Jul 22, 2016 8:24 am
by Turon
Thank you, and oh my gosh why didn't I see that?