Skip to content
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

add 39 _() comms_station.lua #1396

Merged
merged 2 commits into from
Apr 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions scripts/comms_station.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function commsStationMainMenu(comms_source, comms_target)
end

if comms_target:areEnemiesInRange(5000) then
setCommsMessage("We are under attack! No time for chatting!")
setCommsMessage(_("commsStation", "We are under attack! No time for chatting!"))
return true
end
if not comms_source:isDocked(comms_target) then
Expand All @@ -85,25 +85,25 @@ function commsStationDocked(comms_source, comms_target)
local message

if comms_source:isFriendly(comms_target) then
message = string.format("Good day, officer! Welcome to %s.\nWhat can we do for you today?", comms_target:getCallSign())
message = string.format(_("commsStation", "Good day, officer! Welcome to %s.\nWhat can we do for you today?"), comms_target:getCallSign())
else
message = string.format("Welcome to our lovely station %s.", comms_target:getCallSign())
message = string.format(_("commsStation", "Welcome to our lovely station %s."), comms_target:getCallSign())
end

setCommsMessage(string.format("%s\n\nReputation: %s", message, comms_source:getReputationPoints()))
setCommsMessage(string.format(_("commsStation", "%s\n\nReputation: %d"), message, comms_source:getReputationPoints()))

local reply_messages = {
["Homing"] = "Do you have spare homing missiles for us?",
["HVLI"] = "Can you restock us with HVLI?",
["Mine"] = "Please re-stock our mines.",
["Nuke"] = "Can you supply us with some nukes?",
["EMP"] = "Please re-stock our EMP missiles."
["Homing"] = _("commsStation", "Do you have spare homing missiles for us?"),
["HVLI"] = _("commsStation", "Can you restock us with HVLI?"),
["Mine"] = _("commsStation", "Please re-stock our mines."),
["Nuke"] = _("commsStation", "Can you supply us with some nukes?"),
["EMP"] = _("commsStation", "Please re-stock our EMP missiles.")
}

for _, missile_type in ipairs(MISSILE_TYPES) do
if comms_source:getWeaponStorageMax(missile_type) > 0 then
addCommsReply(
string.format("%s (%d rep each)", reply_messages[missile_type], getWeaponCost(comms_source, comms_target, missile_type)),
string.format(_("commsStation", "%s (%d rep each)"), reply_messages[missile_type], getWeaponCost(comms_source, comms_target, missile_type)),
function(comms_source, comms_target)
handleWeaponRestock(comms_source, comms_target, missile_type)
end
Expand All @@ -119,18 +119,18 @@ end
-- @tparam string weapon the missile type
function handleWeaponRestock(comms_source, comms_target, weapon)
if not comms_source:isDocked(comms_target) then
setCommsMessage("You need to stay docked for that action.")
setCommsMessage(_("commsStation", "You need to stay docked for that action."))
return
end

if not isAllowedTo(comms_source, comms_target, comms_target.comms_data.weapons[weapon]) then
local message
if weapon == "Nuke" then
message = "We do not deal in weapons of mass destruction."
message = _("commsStation", "We do not deal in weapons of mass destruction.")
elseif weapon == "EMP" then
message = "We do not deal in weapons of mass disruption."
message = _("commsStation", "We do not deal in weapons of mass disruption.")
else
message = "We do not deal in those weapons."
message = _("commsStation", "We do not deal in those weapons.")
end
setCommsMessage(message)
return
Expand All @@ -141,26 +141,26 @@ function handleWeaponRestock(comms_source, comms_target, weapon)
if item_amount <= 0 then
local message
if weapon == "Nuke" then
message = "All nukes are charged and primed for destruction."
message = _("commsStation", "All nukes are charged and primed for destruction.")
else
message = "Sorry, sir, but you are as fully stocked as I can allow."
message = _("commsStation", "Sorry, sir, but you are as fully stocked as I can allow.")
end
setCommsMessage(message)
addCommsReply("Back", commsStationMainMenu)
addCommsReply(_("button", "Back"), commsStationMainMenu)
else
if not comms_source:takeReputationPoints(points_per_item * item_amount) then
setCommsMessage("Not enough reputation.")
setCommsMessage(_("commsStation", "Not enough reputation."))
return
end
comms_source:setWeaponStorage(weapon, comms_source:getWeaponStorage(weapon) + item_amount)
local message
if comms_source:getWeaponStorage(weapon) == comms_source:getWeaponStorageMax(weapon) then
message = "You are fully loaded and ready to explode things."
message = _("commsStation", "You are fully loaded and ready to explode things.")
else
message = "We generously resupplied you with some weapon charges.\nPut them to good use."
message = _("commsStation", "We generously resupplied you with some weapon charges.\nPut them to good use.")
end
setCommsMessage(message)
addCommsReply("Back", commsStationMainMenu)
addCommsReply(_("button", "Back"), commsStationMainMenu)
end
end

Expand All @@ -172,17 +172,17 @@ function commsStationUndocked(comms_source, comms_target)
local message

if comms_source:isFriendly(comms_target) then
message = string.format("This is %s. Good day, officer.\nIf you need supplies, please dock with us first.", comms_target:getCallSign())
message = string.format(_("commsStation", "This is %s. Good day, officer.\nIf you need supplies, please dock with us first."), comms_target:getCallSign())
else
message = string.format("This is %s. Greetings.\nIf you want to do business, please dock with us first.", comms_target:getCallSign())
message = string.format(_("commsStation", "This is %s. Greetings.\nIf you want to do business, please dock with us first."), comms_target:getCallSign())
end

setCommsMessage(string.format("%s\n\nReputation: %s", message, comms_source:getReputationPoints()))
setCommsMessage(string.format(_("commsStation", "%s\n\nReputation: %d"), message, comms_source:getReputationPoints()))

-- supply drop
if isAllowedTo(comms_source, comms_target, comms_target.comms_data.services.supplydrop) then
addCommsReply(
string.format("Can you send a supply drop? (%d rep)", getServiceCost(comms_source, comms_target, "supplydrop")),
string.format(_("commsStation", "Can you send a supply drop? (%d rep)"), getServiceCost(comms_source, comms_target, "supplydrop")),
--
commsStationSupplyDrop
)
Expand All @@ -191,7 +191,7 @@ function commsStationUndocked(comms_source, comms_target)
-- reinforcements
if isAllowedTo(comms_source, comms_target, comms_target.comms_data.services.reinforcements) then
addCommsReply(
string.format("Please send reinforcements! (%d rep)", getServiceCost(comms_source, comms_target, "reinforcements")),
string.format(_("commsStation", "Please send reinforcements! (%d rep)"), getServiceCost(comms_source, comms_target, "reinforcements")),
--
commsStationReinforcements
)
Expand All @@ -206,9 +206,9 @@ end
-- @tparam SpaceStation comms_target
function commsStationSupplyDrop(comms_source, comms_target)
if comms_source:getWaypointCount() < 1 then
setCommsMessage("You need to set a waypoint before you can request backup.")
setCommsMessage(_("commsStation", "You need to set a waypoint before you can request backup."))
else
setCommsMessage("To which waypoint should we deliver your supplies?")
setCommsMessage(_("commsStation", "To which waypoint should we deliver your supplies?"))
for n = 1, comms_source:getWaypointCount() do
addCommsReply(
formatWaypoint(n),
Expand All @@ -221,17 +221,17 @@ function commsStationSupplyDrop(comms_source, comms_target)
script:setVariable("position_x", position_x):setVariable("position_y", position_y)
script:setVariable("target_x", target_x):setVariable("target_y", target_y)
script:setVariable("faction_id", comms_target:getFactionId()):run("supply_drop.lua")
message = string.format("We have dispatched a supply ship toward %s.", formatWaypoint(n))
message = string.format(_("commsStation", "We have dispatched a supply ship toward %s."), formatWaypoint(n))
else
message = "Not enough reputation!"
message = _("commsStation", "Not enough reputation!")
end
setCommsMessage(message)
addCommsReply("Back", commsStationMainMenu)
addCommsReply(_("button", "Back"), commsStationMainMenu)
end
)
end
end
addCommsReply("Back", commsStationMainMenu)
addCommsReply(_("button", "Back"), commsStationMainMenu)
end

--- Ask for a waypoint and send reinforcements to defend it.
Expand All @@ -240,27 +240,27 @@ end
-- @tparam SpaceStation comms_target
function commsStationReinforcements(comms_source, comms_target)
if comms_source:getWaypointCount() < 1 then
setCommsMessage("You need to set a waypoint before you can request reinforcements.")
setCommsMessage(_("commsStation", "You need to set a waypoint before you can request reinforcements."))
else
setCommsMessage("To which waypoint should we dispatch the reinforcements?")
setCommsMessage(_("commsStation", "To which waypoint should we dispatch the reinforcements?"))
for n = 1, comms_source:getWaypointCount() do
addCommsReply(
formatWaypoint(n),
function(comms_source, comms_target)
local message
if comms_source:takeReputationPoints(getServiceCost(comms_source, comms_target, "reinforcements")) then
local ship = CpuShip():setFactionId(comms_target:getFactionId()):setPosition(comms_target:getPosition()):setTemplate("Adder MK5"):setScanned(true):orderDefendLocation(comms_source:getWaypoint(n))
message = string.format("We have dispatched %s to assist at %s.", ship:getCallSign(), formatWaypoint(n))
message = string.format(_("commsStation", "We have dispatched %s to assist at %s."), ship:getCallSign(), formatWaypoint(n))
else
message = "Not enough reputation!"
message = _("commsStation", "Not enough reputation!")
end
setCommsMessage(message)
addCommsReply("Back", commsStationMainMenu)
addCommsReply(_("button", "Back"), commsStationMainMenu)
end
)
end
end
addCommsReply("Back", commsStationMainMenu)
addCommsReply(_("button", "Back"), commsStationMainMenu)
end

--- isAllowedTo
Expand Down Expand Up @@ -321,7 +321,7 @@ end
-- @tparam integer i the index of the waypoint
-- @treturn string "WP i"
function formatWaypoint(i)
return string.format("WP %d", i)
return string.format(_("commsStation", "WP %d"), i)
end

-- `comms_source` and `comms_target` are global in comms script.
Expand Down