-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scenario issue] Training: Cruiser DB link hs with some non-existent ships #1686
Comments
Hi @Piglit I I believe you created this scenario, I raise this problem. Could you fix it? |
This isn't trivial because of how ships are added to the Science database and linked to from the Science radar, and it's hard to pin this on @Piglit or any scenario writer because the tools aren't there to do this easily. Today, EE populates the Ships database on scenario launch by parsing ShipTemplates from files in scripts/shiptemplates. The Exuari ships that don't show up in the database aren't in shiptemplates files or ShipTemplate objects, but are standard ships created with a custom type name by using function createExuariTransport()
return CpuShip():setFaction("Exuari"):setTemplate("Personnel Freighter 1"):setTypeName("Exuari transport")
end Doing this breaks the DB link to Personnel Freighter 1, because that link relies on a string comparison of the type name. (#1271) But aside from that, we probably want new entries for the new ships anyway. To minimally "fix" this, the scenario can create entries for those ship types in the Science database: -- Get the Exuari Ships ScienceDatabase object
exuari_ship_db = queryScienceDatabase("Ships","Exuari")
-- Add the entry
exuari_transport = exuari_ship_db:addEntry(_("Exuari transport"))
-- Put something in it
exuari_transport:setLongDescription(_("Exuari transport description goes here")) To copy the base ship template's full data also in that new db entry, you need a Lua function that duplicates as much of an existing ScienceDatabase under a new name as it can: function copyShipDBEntry(base_ship_template,new_ship)
ship_db = queryScienceDatabase("Ships")
-- Search each Ships class's entry for the base ship
for k,entry in ipairs(ship_db:getEntries())
do
base_ship_entry = entry:getEntryByName(base_ship_template)
if base_ship_entry ~= nil
then
break;
end
end
-- Create a new Exuari DB entry for the new ship
exuari_ship_db = ship_db:getEntryByName("Exuari")
new_ship_entry = exuari_ship_db:addEntry(new_ship:getTypeName())
-- Copy base ship data to the new entry
for k,v in pairs(base_ship_entry:getKeyValues())
do
new_ship_entry:setKeyValue(k,v)
end
new_ship_entry:setImage(base_ship_entry:getImage())
-- Impossible without a getModelName() function
-- new_ship_entry:setModelName(base_ship_entry:getModelName())
return new_ship_entry
end Then invoke it and patch up what's specific to the new ship, and manually add the data that scripts can't copy. We can't pull data from ShipTemplates, so we have to spawn a new ship that uses the template. So for Exuari freighters: function createExuariFreighter()
return CpuShip():setFaction("Exuari"):setTemplate("Goods Freighter 5"):setTypeName("Exuari freighter")
end You could add something like: -- Create a dummy ship to use for populating the entry
init_transport = createExuariFreighter()
-- Call our copy function
-- We can't get the template from the ship, so we have to pass it manually
init_transport_entry = copyShipDBEntry("Goods Freighter 5", init_transport)
-- Set the description to something unique
init_transport_entry:setLongDescription(_("The Exuari freighter freights Exuari"))
-- Manually set the model data since we can't get it from the ship nor the entry
-- This requires finding the shiptemplate file and copying and pasting its model
init_transport_entry:setModelDataName("transport_2_5")
-- Immediately destroy the dummy ship
init_transport:destroy() Which results in this when clicking the DB button on any Exuari freighter, since the string lookup now works: No idea if this is enough to satisfy translation requirements, and it's a large number of hoops to jump through for a scenario to paper over how the link feature works, and to copy ship content that mostly already exists.
But something like #1271 would solve the deeper problem of addressing DB entries and links, especially for this use case:
|
Exuari transports, freighters, and shuttles use custom ship type names, which breaks DB links from the Science radar. (daid#1686) Work around this by adding a function that copies the base ship template's data to a new entry with the same ship type name.
Exuari transports, freighters, and shuttles use custom ship type names, which breaks DB links from the Science radar. (daid#1686) Work around this by adding a function that copies the base ship template's data to a new entry with the same ship type name.
Exuari transports, freighters, and shuttles use custom ship type names, which breaks DB links from the Science radar. (#1686) Work around this by adding a function that copies the base ship template's data to a new entry with the same ship type name.
This scenario no longer works at all in the Fr translated version. The incoming call doesnt appear and only 1 enemy ship appears in the same place as us. |
Exuari transports, freighters, and shuttles use custom ship type names, which breaks DB links from the Science radar. (daid#1686) Work around this by adding a function that copies the base ship template's data to a new entry with the same ship type name.
I don't know if we can put here problems concerning scenarios.
The link to the DB for some ships doesn't work. Like "Exuari freighter", "Exuari transport", "Exuari Shuttle"... even in EN language.
Which seems logical since these ships do not/no longer exist in the DB.
The text was updated successfully, but these errors were encountered: