Meine Bemühungen, Objekte in einer Map global auszutauschen/zu verändern, wachsen und gedeihen. Bei Straßen und Schienen klappt's schon mal, jetzt bin ich bei Konstruktionen, und da hakt es noch. Für die Funktion SimpleProposal in Bezug auf Objekte habe ich keine Beispiele gefunden, womöglich hat noch nie jemand damit gearbeitet. Im Wiki steht im schönsten Schweizerdeutsch (oder ist es Fachchinesisch?):
ZitatAlles anzeigenSimpleProposalA structure holding information to build/remove and update constructions and streets. It offers much more functionality than a simple ".con" file. See also build_street.lua for an example. The most important operations that can be performed with a Simple Proposal is adding/removing and modifying the following objects: constructions (stations, depots, ), (base) edges and (base) nodes, and edgeobjects (signals, street terminals, waypoints).
In general, there are a few rules concerning this proposal. First, old entities are reference with the usual non-negative id, whilst new entities are assigned a decreasing negative number starting at -1.
The general rule is that the modification/upgrade of a construction entails removing it and adding it anew. The same rule applies to streets and edgeobjects.
The proposal will take care of updating lines, stop, people and cargo.
Fields:
streetProposal SimpleStreetProposal a block defining modification and addition of streets
constructionsToAdd Vector[type.ConstructionEntity] a list of constructions to add (the entity id for constructions in this vector are an decreasing starting from -1)
constructionsToRemove Vector[Entity] a list of construction entities to remove
old2new Table[Entity,int] a mapping from old construction entities to new construction entities (must be an index in
constructionsToAdd}
.
Und jetzt frage ich mich, was ich machen muss, um innerhalb eines Game Scripts (also nicht im Spiel über die normale Dialogeingabe) Konstruktionen zu ersetzen/upzudaten? proposal.old2new ist mir noch ein Rätsel. Dort werden offenbar zwei Zahlen in einer Tabelle erwartet, und ich hätte getippt, eine davon ist die EntityID der zu ersetzenden Konstruktion, und die andere -1, sofern es nur eine einzige neue Konstruktion gibt. Analog zum Ersetzen von Edges. Klappt aber scheinbar nicht. Oder muss da vielleicht gar nicht die EntityID, sondern die ID der Konstruktion selbst rein? Auch vergeblich versucht. Ich kann mir auch versuchsweise eine Tabelle ConstructionEntity mit passenden Parametern basteln, aber wie kriege ich die dann mit der neuen ID verknüpft? Bei Streets und Tracks gibt es api.type.SegmentAndEntity.new(), aber etwas Vergleichbares für Konstruktionen gibt es scheinbar nicht. ConstructionsToRemove klappt schon mal perfekt mit der aktuellen EntityID, aber was bei ConstructionsToAdd rein muss, ist mir völlig unklar. Zahlenwerte wurden jedenfalls abgelehnt, -1 geht nicht, auch Tabellen mag es nicht, gefragt ist nach Userdata, aber welche, und wie setze ich einen Zeiger darauf? Brauche ich überhaupt Add/Remove für die ganze Aktion? Fragen über Fragen.
Versteht jemand die Anleitung? Irgendjemand ne Idee?