Game script: Get the companys name after bankrupt.

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
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Game script: Get the companys name after bankrupt.

Post by idioty »

I thried with this code:

Code: Select all

case GSEvent.ET_COMPANY_BANKRUPT:
	local instance = GSEventCompanyBankrupt.Convert(ev);
	local company_id = instance.GetCompanyID();
	if (company_id == GSCompany.COMPANY_INVALID) break;
	GSNews.Create(GSNews.NT_GENERAL, GSText(GSText.STR_COMPANY, company_id), GSCompany.COMPANY_INVALID);
	break;

in english.txt: STR_COMPANY	:company neve: {COMPANY}
And the {COMPANY} text is empty.
How can I get the name of bankrupted company?
Sorry my bad english, I don't speak english!
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: Game script: Get the companys name after bankrupt.

Post by Lord Aro »

i suspect you can't, as the company is already gone (as in, the object that represents it in the code has already been destroyed)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: Game script: Get the companys name after bankrupt.

Post by idioty »

I thought :(
And if these company showing in an StroryPage Element, the text also gone.
And the same is the case with old company if two companies merged?
Sorry my bad english, I don't speak english!
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4765
Joined: 09 Sep 2007 05:03
Location: home

Re: Game script: Get the companys name after bankrupt.

Post by Alberth »

Save the name when a new company is started (or renamed)?
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: Game script: Get the companys name after bankrupt.

Post by idioty »

Alberth wrote:Save the name when a new company is started (or renamed)?
I tried, but I can't show in GSStoryPage.

Code: Select all

local compName = GSCompany.GetName(company_id);
STR_COMPANY	:company name: {STRING}
GSStoryPage.NewElement(szabalyokPageID, GSStoryPage.SPET_TEXT, 0, GSText(STR_COMPANY, compName));
and this show error: invalid parameter...
Sorry my bad english, I don't speak english!
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Game script: Get the companys name after bankrupt.

Post by Zuu »

Isn't {STRING} used for another english.txt string?. Is {RAW_STRING} available? If not, I guess it is currently not possible.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: Game script: Get the companys name after bankrupt.

Post by idioty »

Zuu wrote:Isn't {STRING} used for another english.txt string?. Is {RAW_STRING} available? If not, I guess it is currently not possible.
Unfortunately the {RAW_STRING} does not work.
But it works:

Code: Select all

local compName = GSCompany.GetName(company_id);
GSNews.Create(GSNews.NT_GENERAL, "test: " + compName, GSCompany.COMPANY_INVALID);
Sorry my bad english, I don't speak english!
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: Game script: Get the companys name after bankrupt.

Post by idioty »

Hopp!

it also works:

Code: Select all

GSStoryPage.NewElement(szabalyokPageID, GSStoryPage.SPET_TEXT, 0, "test: " + compName);
Can I convert the GSText to raw string (static char *)?
Sorry my bad english, I don't speak english!
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests