Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: setLocation Usage  (Read 1911 times)

Psiyon

  • Admiral
  • *****
  • Posts: 772
  • Trippy
    • View Profile
setLocation Usage
« on: August 17, 2012, 03:50:57 PM »

A quick question: how does one use the setLocation(float x, float y) method in CampaingFleetAPI?

I'm trying to use it like this:

playerfleet.setLocation(-11500, 11500);

But I've got a feeling that's completely wrong because I get this error:

Quote
A method named "setLocation" is not declared in any enclosing class nor any supertype, nor through a static import

...and I have no idea what that means. I have CampaignFleetAPI imported at the top of the file, so that's not an issue. Here's the relevant code:


Code
		StarSystemAPI system = getSector().getStarSystem("God");
FactionAPI csix = getSector().getFaction("csix");
FactionAPI player = getSector().getFaction("player");
SectorEntityToken dockyard = system.getEntityByName("Dockyard");
SectorEntityToken wn = system.getEntityByName("Warp Node");

SectorEntityToken playerf = system.getEntityByName("Fleet");


CargoAPI cargoh = wn.getCargo();
CargoAPI cargoplayer = playerf.getCargo();



boolean jumptl = cargoplayer.removeItems(CargoAPI.CargoItemType.RESOURCES, "jumptl", 1);
boolean jumptr = cargoplayer.removeItems(CargoAPI.CargoItemType.RESOURCES, "jumptr", 1);
boolean jumpbr = cargoplayer.removeItems(CargoAPI.CargoItemType.RESOURCES, "jumpbr", 1);
boolean jumpbl = cargoplayer.removeItems(CargoAPI.CargoItemType.RESOURCES, "jumpbl", 1);



if (jumptl) {

playerf.setLocation(-11500, 11500); //line that the error report gives as problematic.

Global.getSectorAPI().addMessage("Mass hyperstream jump successful.", Color.green);

cargoh.addItems(CargoAPI.CargoItemType.RESOURCES, "jumptl", 1);

}

Any help would be greatly appreciated.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: setLocation Usage
« Reply #1 on: August 17, 2012, 04:04:36 PM »

You defined playerf as a SectorEntityToken, not a CampaignFleetAPI, so it doesn't have access to CampaignFleetAPI's methods.

Try this:
Code
CampaignFleetAPI playerf = getSector().getPlayerFleet();
« Last Edit: August 17, 2012, 04:06:31 PM by LazyWizard »
Logged

Psiyon

  • Admiral
  • *****
  • Posts: 772
  • Trippy
    • View Profile
Re: setLocation Usage
« Reply #2 on: August 17, 2012, 06:33:59 PM »

Ah. That makes sense, though it makes me look like an idiot. :P I ought to take some time and really learn how to program at some point. Would probably make university a lot easier.

Anyway, thanks, it worked perfectly. My inter-orbital teleportation system is fully operational now.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7214
  • Harpoon Affectionado
    • View Profile
Re: setLocation Usage
« Reply #3 on: August 18, 2012, 02:04:39 PM »

Oooh, warpnodes. Cool!
Logged