GSCompanyMode not working properly

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
thegreatpl
Engineer
Engineer
Posts: 28
Joined: 29 Dec 2008 22:28
Location: my own mind

GSCompanyMode not working properly

Post by thegreatpl »

Either I am trying to use it wrong, or it is not working. Every time I try to use GSCompanyMode to build something (specifically, an airport and levelling the ground around where the airport will go) it fails with an ERR_PRECONDITION_FAILED. From what I can tell, the only precondition that is not valid is the GSCompanyMode.

I've attached the scripts I was using to try this.

I am completely aware I may just have screwed up my script. I have glanced at the SplitScenarioGS though, and can see pretty much the same thing there as what I was trying to do.
Attachments
IS Airport.zip
(14.17 KiB) Downloaded 31 times
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: GSCompanyMode not working properly

Post by Zuu »

Code: Select all

	GSSign.BuildSign(100, "testing"); 
	GSCompanyMode(companyIdx); 
	GSLog.Info("Switched to mode for " + GSCompany.GetName(companyIdx));
You need to store the result from GSCompanyMode() in a variable. The company mode is in effect for as long as this variable is in scope. Basically when the instance is destroyed, the company mode exits. Since you don't store it in a local variable, it is destroyed immediately.

Solution:

Code: Select all

local cm = GSCompanyMode(companyIdx);
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 22 guests