Script to remove all signs
Moderator: OpenTTD Developers
Script to remove all signs
Hi,
I have a problem that I described here:
viewtopic.php?p=1266013#p1266013
I would like to remove all signs from the list. I found this class:
https://docs.openttd.org/gs-api/classGSSignList#details
this class has the Clear() function
https://docs.openttd.org/gs-api/classGS ... f69e9443f5
but I don't know how to use it.
I think it's easy to create a script using this function, but I've never done it. Can I ask for help on how to do this? Maybe someone could write me such a script?
Thank you and best regards
I have a problem that I described here:
viewtopic.php?p=1266013#p1266013
I would like to remove all signs from the list. I found this class:
https://docs.openttd.org/gs-api/classGSSignList#details
this class has the Clear() function
https://docs.openttd.org/gs-api/classGS ... f69e9443f5
but I don't know how to use it.
I think it's easy to create a script using this function, but I've never done it. Can I ask for help on how to do this? Maybe someone could write me such a script?
Thank you and best regards
Re: Script to remove all signs
Code: Select all
local sign_list = AISignList();
sgn_list.Clear;
Code: Select all
function _SuperLib_Helper::ClearAllSigns(except_tile = -1)
{
local sign_list = AISignList();
foreach(i, _ in sign_list)
{
if (except_tile != -1 && AISign.GetLocation(i) == except_tile) continue;
AISign.RemoveSign(i);
}
}
Code: Select all
function AIAI::SignMenagement() {
if (AIAI.GetSetting("clear_signs")) {
Helper.ClearAllSigns();
}
}
Re: Script to remove all signs
Thank you HGus for this code.
But I don't know how to use it.
Where should I enter this code?
Unfortunately, I've never scripted for OpenTTD.
But I don't know how to use it.
Where should I enter this code?
Unfortunately, I've never scripted for OpenTTD.
Re: Script to remove all signs
Sorry. I thought you are an AI developer.
Find CPU-1.4.tar in your OpenTTD\ai or OpenTTD\content_download\ai folder.
Extract and edit main.nut
At line 448, insert this:
Repack main.nut into the tar file.
Rerun the game. The signs should be deleted in a few ticks. You can then exit and restore the original code.
Find CPU-1.4.tar in your OpenTTD\ai or OpenTTD\content_download\ai folder.
Extract and edit main.nut
At line 448, insert this:
Code: Select all
local sign_list = AISignList();
foreach(i, _ in sign_list)
{
AISign.RemoveSign(i);
}
Rerun the game. The signs should be deleted in a few ticks. You can then exit and restore the original code.
Re: Script to remove all signs
Thank you.
Unfortunately, I'm not an AI programmer. I do some programming in various programming languages, but I've never programmed anything in OpenTTD before. I'm using Fedora 39.
I found the CPU-1.4.tar file in ~/.openttd/content_download/ai
I inserted this piece of code and it looks like this:
I repackaged it into CPU-1.4.tar
I started the game, but I don't know what to click to make the signs disappear
Unfortunately, I'm not an AI programmer. I do some programming in various programming languages, but I've never programmed anything in OpenTTD before. I'm using Fedora 39.
I found the CPU-1.4.tar file in ~/.openttd/content_download/ai
I inserted this piece of code and it looks like this:
Code: Select all
{...]
function CPU::Start() {
AILog.Info("TestAI Started.");
SetCompanyName();
AICompany.SetAutoRenewStatus(true);
//set a legal railtype.
local types = AIRailTypeList();
AIRail.SetCurrentRailType(types.Begin());
local towns = AITownList();
//Keep running. If Start() exits, the AI dies.
local step=-2;
while (true) {
this.Sleep(100);
local sign_list = AISignList();
foreach(i, _ in sign_list)
{
AISign.RemoveSign(i);
}
step+=1;
while (AIEventController.IsEventWaiting()) {
{...]
I started the game, but I don't know what to click to make the signs disappear
Re: Script to remove all signs
It only works if the AI is running. If it died then all signs become un-owned and the only way to delete them is including the GS version in a Game Script if your game already included one. After modifying the script, reload a savegame with the AI still running.
Who is online
Users browsing this forum: No registered users and 18 guests