Transport Fever 2

Transport Fever 2

Construction Mover
WernerK 7 Feb, 2024 @ 7:12am
Conflict with 'Marker Node' and other mods
I've got trouble if I use this mod together with my mod 'Marker Node'. The dot marker is no longer deleted. I implemented a routine for a safety check if the marker to be deleted is the right one. But it only works with objects of type 'ASSET_GROUP'. But now it seems that they are converted to type 'CONSTRUCTION' if your mod is installed.

Also the invisible trigger markers of the Ramp Equalizer are not deleted and remain as garbage.

Meanwhile I have looked inside your code. Patching is easier than I thought. Please add following lines to _excludedConFileNames in mod.lua:

​'wk_dot.con',
'​wk_marker_03.con',
'wk_mrkx_equalize_ramp.con',
'wk_mrkx_splitter.con',
'wk_mrkx_set_tram_masts.con',

I don't know if there is a string.find query. So you could set 'wk_mrkx' as a keyword.

In general I find it a little bit risky to convert asset groups to constructions. There could be some other mods - not from me - who are especially looking for asset groups and then they couldn't find them any longer. Perhaps you could implement an option to switch off this feature temporarily.
Last edited by WernerK; 7 Feb, 2024 @ 5:44pm
< >
Showing 1-9 of 9 comments
lollus  [developer] 8 Feb, 2024 @ 5:32am 
What's an asset group? How did you search for something and fail to find it after I added the terrain? In detail please.
WernerK 8 Feb, 2024 @ 6:02am 
I use this piece of Code to delete the markers and the trigger constructions:

function mrk.deleteModel(entityId, model, modName) if entityId then if api.engine.entityExists(entityId) then local entity = game.interface.getEntity(entityId) if entity and entity.models and entity.models[model] then api.cmd.sendCommand(api.cmd.make.removeField(entityId)) else print(modName .. " > " .. "model entity mismatch - " .. tostring(entityId) .. ", model " .. model) end else print(modName .. " > " .. "model entity does not exist - " .. tostring(entityId) .. ", model " .. model) end end end

If you analyze entity there is a 'type' parameter. This distinguishes between 'ASSET_GROUP' and 'CONSTRUCTION'. Constructions have to be deleted with a proposal. I left out this option because I never expected that someone could convert them.

My asset groups are created by this function:

function mrk.setMarker(fileName, transf) local newCon = api.type.SimpleProposal.ConstructionEntity.new() newCon.fileName = fileName newCon.name = "" newCon.playerEntity = api.engine.util.getPlayer() newCon.params = {seed = 2} for j = 1, 16 do newCon.transf[j] = transf[j] end local proposal = api.type.SimpleProposal.new() proposal.constructionsToAdd[1] = newCon local entityId api.cmd.sendCommand(api.cmd.make.buildProposal(proposal, nil, false), function(res, success) entityId = res.resultEntities[1] end) return entityId end

I never found out when an asset group results and when a construction is created. I think it is changed at the moment you add a terrain. In my studies I found out that a construction without terrain cannot be upgraded. So it gets the type 'ASSET_GROUP' and has to be deleted by 'removeField'. It's no longer a construction; you have to remove it as a model. Maybe the old 'bulldoze' command works for both types but I prefered using the new commands if available.

You find the functions in wkm_markerutil_1_1.lua or in the extended calcutils.
Last edited by WernerK; 8 Feb, 2024 @ 6:17am
lollus  [developer] 8 Feb, 2024 @ 9:28am 
OK makes sense. I am actually exploiting this very difference between constructions and (constructions without edges nor terrainALignment). The latter are these asset groups.
Out of curiosity: do you need to delete models selectively? Or would you rather delete the whole construction at once?
WernerK 8 Feb, 2024 @ 9:51am 
I think that you cannot delete asset groups - if there are more models than one - at once, you have to delete every .mdl separately. Real constructions can and must be deleted at once but as .con. Perhaps except track and street constructions where you may have parts apart from the actual construction. But I'm not so familiar with this stuff. Some research is necessary.
lollus  [developer] 8 Feb, 2024 @ 10:23am 
It's easy: if you have at least a result.edgeLists or a result.groundFaces, it's a real construction. Otherwise, it's an asset group.
Do you have a special need to remove those things selectively? Or would you rather remove them together?
lollus  [developer] 8 Feb, 2024 @ 10:47am 
I can help.
Anyway, I have blacklisted all cons with wk_*.con and made the feature optional. Here is the last commit: https://github.com/lolluslollus/lollo_con_mover_1
If you have no issues by midnight (muah muah muah), I will release it.
WernerK 8 Feb, 2024 @ 12:21pm 
The reason why I'd like to remove them selectively is the different kind of safety request. As asset group I get the name of the model and can compare it with the mod that has originally to be deleted. With real constructions this is not possible. I don't know whether it is still necessary, but in the past there were some unexpected cases when wrong models could be removed. I jump from the GUI Thread to the Engine Thread, and on this way some problems arised in the past. I hope that I've fixed them but I'm not so sure. And - you see - it has indeed caught your changed constructions which normally would have caused a crash. You also do a lot of safety requests in your own code for beeing sometimes not so sure, BTW You seem to do the same with your own splitter "nail". I think you also delete it after it has done its job. How do you solve it? Is it a real construction? Or is there also a filter for it?

As I told you, in future I will look for other ways of safety requests, maybe I'll compare the coordinates. But at this moment I'm heavily busy with this tram project.

Excluding my complete constructions is ok. I don't think there could be something interesting to be moved. Wait ... Perhaps my Track Builder constructions? Oh, I don't think it makes any sense to move them.
Last edited by WernerK; 8 Feb, 2024 @ 12:22pm
WernerK 8 Feb, 2024 @ 1:51pm 
I've tested it and it works fine as far I could check in the short time. The only thing I've noticed is an unnecessary indent in the first line of your mod description, but that's something else. So you could release it. Thanks! :steamhappy:
lollus  [developer] 8 Feb, 2024 @ 8:15pm 
OK
< >
Showing 1-9 of 9 comments
Per page: 1530 50