Rusted Warfare Mod Workshop
All coursesCreative tools中文

Separate inventory, team stock and unit memory

Use two carriers to see which data is local and which data belongs to the team

Decide who owns the data

Onboard supplies belong to one carrier, fleet stock belongs to the team, and the signal count is a record kept by one vehicle, choose local resources, global resources or memory according to ownership

[resource_v07cells]
displayName: 车载补给 / Onboard supplies
displayInHud: false

[global_resource_v07stock]
displayName: 车队储备 / Fleet stock
displayInHud: true

Use resources for costs and memory for state

A price can directly require a resource and cannot be paid without enough stock, memory stores counters and switches and does not automatically act as a spendable balance

[core]
defineUnitMemory: number signals

[hiddenAction_initialize]
autoTriggerOnEvent: created
setUnitMemory: signals=0
addResources: v07cells=3

[action_useSupply]
text: 使用一份补给 / Use one supply
price: v07cells=1
buildSpeed: 1s
showMessageToPlayer: Supply used

Make the resource flow explicit

First convert 100 credits into one team stock, then let any carrier exchange that stock for three onboard supplies, the shared stock is available to both carriers while only the receiving carrier gains local inventory

[action_buyStock]
text: 采购储备 / Buy stock
price: credits=100
buildSpeed: 2s
addResources: v07stock=1

[action_reload]
text: 领取补给 / Load supplies
price: v07stock=1
buildSpeed: 2s
addResources: v07cells=3

Compare two units to inspect scope

Buy stock with A and collect supplies with B, both should report the same fleet stock while their inventory and signal counts may differ, compare values before and after each step

[action_report]
text: 查看状态 / Status
buildSpeed: 0
showMessageToPlayer: Signals=%{memory.signals}, supplies=%{self.resource.v07cells}, fleet stock=%{self.resource.v07stock}

Try it yourself

Draw the flow from credits to team stock to inventory, marking the owner at each stage

Open interactive lesson and download the companion mod