[NoGo] TileLabels library

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
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

[NoGo] TileLabels library

Post by Zuu » 18 Feb 2012 14:53

TileLabels is a library that let you put signs in a scenario and then access the location of those tiles by their name. This library removes all the signs and keep them in memory for you so that players won't see them.

The library supports (and encourages) a prefix for these special signs. Signs that doesn't contain this prefix will be untouched.

For more information see the README.txt or download the library. Version 7 of the Beginner Tutorial will use this library, but there is also a simple example in the readme.

Download
Use in-game download or the bananas website
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

McZapkie
Tycoon
Tycoon
Posts: 1176
Joined: 18 Jan 2014 18:10

Re: [NoGo] TileLabels library

Post by McZapkie » 28 Jun 2014 12:40

Hello,
I need advice, as game script beginner, how to change example from readme.txt, to iterate among many labels.
I want to read all labels and create list or array of tile id and parameters derived from label string.
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] TileLabels library

Post by Zuu » 29 Jun 2014 08:53

There is no such public function in this library. All it got is really the GetTile method that get the tile from a label string.

If you are adventures, you could neglect that you shouldn't deal with internal parts of an library and read the tile_table member yourself. However, it would be better to take a step back and ask yourself what questions do you like to ask to the list of all tiles and add a public method to this library for those questions. You cannot upload changes to the library, only I can, but you can submit me a patch or tell me what the questions are and hope that I have time to add that.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Ma-ma
Engineer
Engineer
Posts: 1
Joined: 30 Jun 2014 11:56

Re: [NoGo] TileLabels library

Post by Ma-ma » 30 Jun 2014 12:20

Code: Select all

foreach( sign_name, tile_index in this.tile_labels.tile_table )
{
  //  sign_name type is string
  // tile_index type is TileIndex

  print( "name " + sign_name + "   tile " + tile_index )

}
Sign names must be unique,
function TileLabels::ReadFromMap line
local pre_part = sign_content.slice(0, this.prefix.len());

produces "Your script made an error: slice out of range"
if prefix is longer than shortest sign on map

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests