Need some help with my coding

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
alc
Engineer
Engineer
Posts: 24
Joined: 04 Sep 2019 18:42

Need some help with my coding

Post by alc »

Hi guys,
I can't figure out what I am doing wrong with the declarations or passing the parameters that I can't make my GS work the way a want. I get "Your script made an error: the index "_storypage" does not exist" where _storypage is a global array.
When I run the same commands directly on the calling function, it works ok, but when I create a function I get this error.

Code: Select all

this.UpdateStoryPage(company + fruitwaiting, Vehicles);

function MainClass::UpdateStoryPage(page, Vehicles);
{
	local Vehicle = null;
	if (GSStoryPage.IsValidStoryPage(_storypage[page])) {
		// Remove previous elements
		local StoryPageElementList = GSStoryPageElementList(page)
		GSLog.Info("Cantidad de elementos " + StoryPageElementList.Count ());
		for (local StoryPageElement = StoryPageElementList.Begin(); !StoryPageElementList.IsEnd(); StoryPageElement = StoryPageElementList.Next()) {
			GSStoryPage.RemoveElement(StoryPageElement)
		}
		// Add new elements
		GSStoryPage.SetDate(page, GSDate.GetCurrentDate());
		for (Vehicle = Vehicles.Begin(); !Vehicles.IsEnd(); Vehicle = Vehicles.Next()) {
			GSStoryPage.NewElement(this._storypage[page], GSStoryPage.SPET_LOCATION, GSVehicle.GetLocation(Vehicle), GSVehicle.GetName(Vehicle));
		}
	}
}
I believe I have some missing declaration or somethins as also I need to do an intersection function with two tile lists and have the same problem. I saw some others GS and AIs and I didn't find some different declaration... ?(

Thanks,
Alberto
Attachments
Assistant GS.tar
(23.5 KiB) Downloaded 59 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests