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

Non-platform specific questions.

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

Postby Turon » Thu Jul 21, 2016 1:05 pm

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);
}
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby schnellboot » Thu Jul 21, 2016 9:08 pm

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
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

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

Postby lcl » Fri Jul 22, 2016 4:38 am

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;
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby Turon » Fri Jul 22, 2016 8:24 am

Thank you, and oh my gosh why didn't I see that?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron