The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on August 31, 2020, 06:46:18 AM

Title: Use start and end coordinates from a script tool in a scenario
Post by: Yona-TYT on August 31, 2020, 06:46:18 AM
Quote from: Yona-TYT on August 31, 2020, 01:46:41 AM2 - Can you combine a script tool with a scenario script ?, I mean to be able to pass data from the tool to the scenario script, such as the start and end coordinates from "mark_tiles" for example, with this I can solve a problem in the "Split Regions" script to not use toll gates.


What I am looking for is to use a scripted tool to select an area on the map to save the coordinate values (start and end) and use those values in a script scenario.
Title: Re: Use start and end coordinates from a script tool in a scenario
Post by: Dwachs on August 31, 2020, 10:00:52 AM
Why not catch the calls to is_work_allowed_here? The tool id is a special number indicating that a scripted tool is behind.
Title: Re: Use start and end coordinates from a script tool in a scenario
Post by: Yona-TYT on August 31, 2020, 07:09:30 PM
Certainly this can work, using the "tool_id", but how but how would you go about getting the start and end coordinates in a two-click tool?.  ???
Title: Re: Use start and end coordinates from a script tool in a scenario
Post by: Dwachs on September 01, 2020, 07:10:22 AM
Each click should be send to the scenario. But it seems impossible to distinguish first and second.

For your request, I could think of implementing a very low-level communication between scripts: just sending strings and numbers between them.
Title: Re: Use start and end coordinates from a script tool in a scenario
Post by: Yona-TYT on September 01, 2020, 08:00:40 AM
Quote from: Dwachs on September 01, 2020, 07:10:22 AMEach click should be send to the scenario. But it seems impossible to distinguish first and second.
Certainly, it was precisely this that gave me headaches in the past, when I was trying to mark the beginning and the end of a road at the time of its construction.  :o

Quote from: Dwachs on September 01, 2020, 07:10:22 AMFor your request, I could think of implementing a very low-level communication between scripts: just sending strings and numbers between them.
This sounds interesting.  8)