IsWithinTownInfluence

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

IsWithinTownInfluence

Post 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
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoAI Branch - An AI Framework

Post 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/).
The only thing necessary for the triumph of evil is for good men to do nothing.
reylas
Engineer
Engineer
Posts: 52
Joined: 22 Dec 2007 01:04

Re: NoAI Branch - An AI Framework

Post 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.
User avatar
Ralph
Engineer
Engineer
Posts: 87
Joined: 21 Jun 2004 15:25

Re: NoAI Branch - An AI Framework

Post 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);
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 10 guests