Cannot convert 'Object' to 'int'[SOLVED]

Started by Loslem, Sat 21/10/2017 21:05:29

Previous topic - Next topic

Loslem

Hi guys,

so for the first time I want to use some custom functions to generate me some shortcuts.

It's just about getting the charcater to play a pickup animation, making the object invisible and adding the item to the inventory.
That'S really an old issue, and I started by digging up some old Code-Advice that Khris scripted 10 Years ago or so.
So, in the Globalscript I have
Code: ags
function PickUpLow(int dir, int obj, InventoryItem*inv) {
  player.LockView(6); // change this to the pick up-view 
  player.Animate(2, 5, eOnce, eBlock); // play pick up-animation, make sure it's blocking
  object[obj].Visible=false; // turn off object
  player.AddInventory(inv);
  player.UnlockView();
}


Int he GLobalscript Header:
Code: ags
import function PickUpLow(int dir, int obj, InventoryItem*inv);


In my Roomscript it will be;
Code: ags
function oBlueCup_AnyClick()
{
  if (Verbs.MovePlayer(523, 531)) {
    // LOOK AT
    if(Verbs.UsedAction(eGA_LookAt)) {
      player.Say("It's a blue cup.");
    }
    // USE
    else if(Verbs.UsedAction(eGA_Use)) {
      player.Say("I'd rather pick it up.");
    }
    // Push
    else if(Verbs.UsedAction(eGA_Push)) {
      player.Say("It might break.");
    }
    // Pull
    else if(Verbs.UsedAction(eGA_Pull)) {
      Verbs.Unhandled();
    }  
    // PICKUP
    else if(Verbs.UsedAction(eGA_PickUp)) {
      PickUpLow(eDir_Right, oBlueCup, iCup);  
    }
    //USE INV
    else if(Verbs.UsedAction(eGA_UseInv)) {
      Verbs.Unhandled();
    }
    // don't forget this
    else Verbs.Unhandled();
  }
}


My Error reads:
Error (line 105): Type mismatch: cannot convert 'Object' to 'int'


My guess is that maybe some codestuff was updated in the timespan of ten years, and I'm just missing something obvious. 
So... Any thought?

Cassiebsg

My guess, is that your function is defining an int (int obj) but then you telling it to pickup oBlueCup, which is an object.

Try using the object number instead?
There are those who believe that life here began out there...

Loslem

Thanks Dude! That was quick and did the trick :)
That's really one of my rookie prolems... using commands is no problems, but what all these different types of things do... no clue.
Well that's what help forums are there for, thanks again!

Khris

You don't have to use the literal number, you can do this:

Code: ags
    PickUpLow(eDir_Right, oBlueCup.ID, iCup);


This should also work:
Code: ags
function PickUpLow(int dir, Object* obj, InventoryItem*inv) {
  player.LockView(6); // change this to the pick up-view 
  player.Animate(2, 5, eOnce, eBlock); // play pick up-animation, make sure it's blocking
  obj.Visible=false; // turn off object
  player.AddInventory(inv);
  player.UnlockView();
}

Loslem


SMF spam blocked by CleanTalk