Skip to content

Battery charging station + mobile network - production spec & tracker (collab with @Akita83) #94

Description

@TheCodingDad-TisonK

Short version

Akita built two new tablet features. We are finishing them together.

  • Battery + charging: the tablet has a battery. It runs down while you use it. You charge it back up at a dock.
  • Phone signal: the tablet shows signal bars. When there is no signal, online apps stop showing live numbers and show the last saved numbers instead.

This issue is our shared checklist, so we both know what "finished" means. It follows on from #93.

Two rules for everything here:

  • It is all client-side. It must not break dedicated servers.
  • The tablet is a per-player HUD. Battery and signal are local to each player. They never run on the server.

Who does what (agreed on Discord)

  • Akita: the charging station, battery drain and charge timing, the network build, and tuning.
  • Me (Tison): merge into the current tablet, all 26 languages, settings and console, saving, polish.

Where the code is now

All of it is in src/FarmTabletUI.lua.

Battery:

  • setup :133-140
  • drain :1312-1315
  • empty screen :1085-1113
  • charging :1116-1124 and :1294-1310

Network:

  • setup :142-161
  • provider screen :1019-1083
  • signal :1170-1260
  • toasts :1148-1168

What is still "test only" for now:

  • Battery drops about 1% per real minute the tablet is open. It should use in-game time instead.
  • Charging is just a button that fills up in about 5 real seconds. It should be a charging dock that takes 1 in-game hour.
  • Nothing is saved yet, so it all resets on reload.

System 1: Battery + charging dock (do this first)

The idea

There is a charging dock. You walk up to it and press E. The tablet charges to full over 1 in-game hour. While it sits on the dock it is "put away": if you press the open key, you get a message instead of the tablet opening.

The dock

  • Best option: a real in-world object (placeable or map asset) that looks like a stand with the tablet in it.
  • Simpler option if the object is too much for now: a trigger zone at one fixed spot (for example by the farmhouse) that turns the interaction on.
  • When you stand close, show an E prompt that says "Charge tablet". Use the normal action-prompt system so it shows in the help box and respects key rebinds. Do not poll the key directly.
  • Press E when the battery is not full: start charging.
  • Press E when it is already full: show "Tablet already charged" and change nothing.

How charging works

  • Charge from the current level up to 100% over 1 in-game hour. Use game time, not real seconds.
  • While charging, the tablet stays closed. If you try to open it (key or console), show "Tablet is charging on the dock".
  • Nice to have: a small "charging" indicator in the world or on the HUD so you know it is docked.
  • Messages: one when charging starts, one at 100% ("Tablet fully charged").
  • If you walk away mid-charge: pick one behaviour and write it down. Suggested: charging pauses and carries on when you come back. It keeps whatever % it reached. Do not reset it to 0.

Drain rework

  • Drain on in-game time, not real time. Put the rate in Constants.lua (suggest about X% per in-game hour while open). Decide if it also drains a tiny bit while closed, or not at all, and write down which.
  • At 0%, the tablet only shows the empty screen and points you to the dock. No apps at 0%.
  • Low-battery warning at a set level (for example 20%).

Saving

  • Save the battery % (and the "on dock / charging" flag) so it survives reload. Write it in the save hook (FSCareerMissionInfo:saveToXMLFile), the same way settings are saved. If you only save on change, the save copy can wipe it.
  • Load it back in loadMission00Finished.

Settings and console

  • Settings toggle: battery system on/off. Off means the tablet never drains (the current default for players who do not want it).
  • Settings: drain rate and charge time, or at least a few presets.
  • Console commands for testing: TabletBatterySet <0-100>, TabletCharge, TabletBatterySystem on|off.

Edge cases to check

  • Sleep or time skip while charging: the charge should still move forward correctly (it is on game time).
  • Battery system turned off mid-save: the tablet should just open normally and ignore any stored empty state.
  • Multiplayer: each player has their own battery. The dock is local only, no sync needed. Check a dedicated server shows no errors when the dock object loads.

System 2: Phone signal

The prototype already works well. The missing piece is meaning. Right now the signal is just for show. Let me make "no signal" actually do something so the system is worth having.

Provider

  • Save the chosen provider so it is not asked again every time you open the tablet. The very first open still shows the picker.
  • Let the player change provider later from Settings or a small network panel, not only on first launch.

Signal bars

  • Keep the position-based bars (_calcLocalSignalBars, same bars at the same spot on the map). Good as is.
  • Optional extra: weather lowers signal (storms or heavy rain drop a bar or two). Low priority.

Outages

  • Keep random outages, but make how often and how long they happen configurable (in Constants plus a preset: Off / Rare / Normal / Frequent).
  • Show a toast when an outage starts and when it ends. Mostly done already, just check the wording for each state.

What "no signal" actually does (the important part)

  • Online apps (market, contracts, companion-mod data, anything pulling live numbers) show a "No connection - last synced HH:MM" banner and show the last saved values instead of live ones.
  • Local apps (Notes, Settings, anything self-contained) keep working as normal with no signal.
  • Give apps the signal state through self.system.signal (already there at :1250-1257) so each app can decide what to do. Add a small helper like self:hasSignal() so apps do not have to read the table by hand.

Settings and console

  • Settings toggle: network system on/off. Off means always full signal and no outages.
  • Settings: outage frequency preset, and provider.
  • Console: TabletSignalSet <0-4>, TabletOutage on|off, TabletNetworkSystem on|off.

Saving

  • Save the chosen provider. The outage state does not need to survive reload (it can reset to "ok" on load).

Shared work (mostly mine)

  • Languages: the new ft_battery_* and ft_network_* keys, plus all new settings and console text, in all 26 languages. They are only in DE and EN right now.
  • Settings UI: both on/off toggles and the presets added to the pause-menu settings, using the existing SettingsUI clone helpers.
  • Save/load: wire battery and provider into SettingsManager and the save hook.
  • No regressions: the existing 30+ apps keep working, and the new screens do not break the lock / home / app flow.
  • Version + changelog: bump modDesc.xml, the README version line, and the in-tablet Updates list when this ships.

Two things for us to agree on

  • How fast the battery drains. Starting idea: a full tablet, left open the whole time, runs flat in about 2 in-game days. That makes it a gentle background thing, not a nag. We tune it together.
  • One dock or a buyable one. Start with one fixed dock. If it feels good, we can add a buyable placeable later.

Tagging @Akita83 so we share the checklist. I will tick off the language, settings, and saving rows as I go.

Metadata

Metadata

Labels

enhancementNew feature or requestin-progressBeing actively investigateduser-repliedUser is awaiting response

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions