Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Aug 21, 2017 11:37 pm

All times are UTC




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Apr 19, 2017 8:06 pm 
Offline
Engineer
Engineer

Joined: Mon Dec 29, 2008 10:28 pm
Posts: 26
Location: my own mind
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 15 times
Top
   
PostPosted: Fri Apr 28, 2017 3:44 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4531
Location: /home/sweden
Code:
   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:
local cm = GSCompanyMode(companyIdx);

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.