News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Factory connected with

Started by Yona-TYT, June 24, 2020, 06:24:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


Hello how are you ?.

I am experimenting with a script that will display a list of the "providers" and "consumers" of the factories with a "script link" that allows "Delete" or "Add" a connection to another factory.

I need to use the tool "tool_link_factory", is this implemented?

I enclose my experiment:

prissi

Since it is a clickable tool in menucof.tab there is already a tool. I think a script can call any tool for which a menu entry exists.

Dwachs

tool_link_factory is there. Did you test your script?

Yona-TYT

Quote from: Dwachs on June 25, 2020, 10:29:16 AMtool_link_factory is there. Did you test your script?
Maybe i'm doing something wrong  ???

    local tool = command_x(tool_link_factory)
    tool.set_flags(2)           
    local err = tool.work(player_x(1), tile, tile_fact, "")


Dwachs

There was indeed a bug, affecting scripted calls to this tool (and the stop mover tool). Please test again with r9154.

Yona-TYT

Quote from: Dwachs on June 25, 2020, 04:49:33 PM
There was indeed a bug, affecting scripted calls to this tool (and the stop mover tool). Please test again with r9154.
I think it works!

Now for the list, I am going to need a function that tells me if the factory is contracted with another factory and if the factory is associable with another factory.

Example:
factory_x().is_connected_with(factory_x()) and factory_x()is_connectable_with(factory_x())

This will allow me to display a list of possible suppliers or consumers that can be connected to the selected factory.

Dwachs

For the first, you can iterate through get_consumer and get_supplier. For the second, there is no function like this. You have to iterate through the list of all factories and search for matching input and output goods.