Page 1 of 1

IsWithinTownInfluence

Posted: 09 Jun 2008 00:45
by reylas
Another question about IsWithinTownInfluence. If I use AIStation.IsWithinTownInfluence, it works. But If I use AITile.IsWithinTownInfluence, I get an index IsWithinTownInfluence does not exist.

Is that a bug or am I using it wrong.

Area.Validate(AITile.IsWithinTownInfluence,current_town);

Thanks,
MarkS

Re: NoAI Branch - An AI Framework

Posted: 09 Jun 2008 09:53
by TrueBrain
reylas wrote:Another question about IsWithinTownInfluence. If I use AIStation.IsWithinTownInfluence, it works. But If I use AITile.IsWithinTownInfluence, I get an index IsWithinTownInfluence does not exist.

Is that a bug or am I using it wrong.

Area.Validate(AITile.IsWithinTownInfluence,current_town);

Thanks,
MarkS
Well, it should work, so the most logic reason I can think up: are you using the latest binaries? As that function is added not too long ago, so please make sure you have the latest binary (r13418, http://nightly.openttd.org/noai/files/).

Re: NoAI Branch - An AI Framework

Posted: 09 Jun 2008 21:23
by reylas
TrueLight wrote:
reylas wrote:Another question about IsWithinTownInfluence. If I use AIStation.IsWithinTownInfluence, it works. But If I use AITile.IsWithinTownInfluence, I get an index IsWithinTownInfluence does not exist.

Is that a bug or am I using it wrong.

Area.Validate(AITile.IsWithinTownInfluence,current_town);

Thanks,
MarkS
Well, it should work, so the most logic reason I can think up: are you using the latest binaries? As that function is added not too long ago, so please make sure you have the latest binary (r13418, http://nightly.openttd.org/noai/files/).
Ok, that was it. I was using an old binary. I know where to check now, so I will check that first.

Next question. Is it possible to copy a List from one variable to another? I am building two TownLists then running some Valuators on them. I noticed that except for one Valuator, they are the same. In order not to run my custom function more than once, I would like to run it on one list, then copy that list to another variable like this:

local Town1 = AITownList();
local Town2 = AITownList();

(some Valuators on Town1)

Town2 = Town1;

This fails with no error (openTTD just goes into la la land). I have tried both with and without the declaration of Town2. What am I doing wrong?

Thanks,
MarkS.

Re: NoAI Branch - An AI Framework

Posted: 09 Jun 2008 21:36
by Ralph
reylas wrote:
Next question. Is it possible to copy a List from one variable to another? I am building two TownLists then running some Valuators on them. I noticed that except for one Valuator, they are the same. In order not to run my custom function more than once, I would like to run it on one list, then copy that list to another variable like this:

local Town1 = AITownList();
local Town2 = AITownList();

(some Valuators on Town1)

Town2 = Town1;

This fails with no error (openTTD just goes into la la land). I have tried both with and without the declaration of Town2. What am I doing wrong?

Thanks,
MarkS.
This may work (not tested)

Code: Select all


local oldlist = AITownList();

oldlist.Valuate(blah blah blah);
oldlist.keepValue(blah);

local newlist = AIList();
newlist.AddList(oldlist);