Skip to content

Add a button to set the job positions to the vehicle position - #1314

Draft
helgehelge123 wants to merge 2 commits into
Courseplay:mainfrom
helgehelge123:feature/set-positions-to-vehicle
Draft

Add a button to set the job positions to the vehicle position#1314
helgehelge123 wants to merge 2 commits into
Courseplay:mainfrom
helgehelge123:feature/set-positions-to-vehicle

Conversation

@helgehelge123

Copy link
Copy Markdown

Problem

When a job is created from the course generator page, the vehicle is usually already standing on the field, in position - but the target position and the field position still have to be picked on the map. That means two mouse picks for something the vehicle already knows, and it is easy to drop the field position on a neighbouring field or a headland of the wrong field.

What this adds

A Target & field to vehicle button in the job parameter list, which sets the target position (including the direction the vehicle is facing) and the field/silo position to the vehicle's current position with one click.

Set positions to vehicle button

Details:

  • The button gets a group of its own right below the position parameters, so it can't be hit by accident while clicking the position rows.
  • It is only added for jobs that actually have such a position: below the field/silo position if the job has one, otherwise below the target position (silo loader), and not at all for jobs with neither.
  • It clones the position parameter template, so it looks, focuses and behaves exactly like the position rows above it (the invalid marker is hidden, it can't be invalid).
  • After setting the positions, validateParameters() and updateParameterValueTexts() run, so the field boundary detection restarts for the new field position, just like after picking it manually.
  • Positions that can't be changed (getCanBeChanged()) are left alone.

Key binding

The same action is also available as a context button in the lower right corner, bound to a new rebindable input action CP_SET_POSITIONS_TO_VEHICLE, KEY_v by default. KEY_v is not used by any MENU_* action in the base game input bindings, it is only bound to vehicle and construction actions, which are not active while the menu is open.

The context button is only active while a job is being created and while nothing is being picked on the map, so the usual workflow can be done from the keyboard alone: V set the positions, C generate the course, X start the job.

That order is also the reason for the first commit in this PR: getNumberOfItemsInSection() built contextActionMapping by iterating CONTEXT_ACTIONS with pairs(). The table has integer keys, but they are assigned in the table constructor, so pairs() returns them in hash order and the context buttons could show up in any order. Using ipairs() makes the order deterministic and follows the order the actions are defined in.

Translations are added for English and German, other languages fall back to English.

Testing

Tested in game with Courseplay 8.1.0.3 (screenshot above, German UI, bale collecting job): the button sets both positions to the vehicle position including its direction, the V key does the same, the button list keeps the intended order, and the button is not shown outside of job creation.

🤖 Generated with Claude Code

helgehelge123 and others added 2 commits August 23, 2026 16:56
getNumberOfItemsInSection() built contextActionMapping by iterating the
CONTEXT_ACTIONS table with pairs(). That table has integer keys assigned
in the constructor, so pairs() returns them in Lua hash order, not in
index order, and the buttons in the lower right corner could show up in
any order.

Use ipairs() so the buttons always appear in the order the actions are
defined in.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
When creating a job while already standing on the field, the target
position and the field/silo position still have to be picked on the map,
which is fiddly and easy to get wrong.

Add a "Target & field to vehicle" button to the job parameter list that
sets both to the vehicle's current position in one click, the target
position also gets the direction the vehicle is facing. It is placed in
a group of its own right below the position parameters, so it is not
clicked by accident, and only shows up for jobs that actually have such
a position.

The same action is available as a context button in the lower right
corner and bound to a new, rebindable input action
CP_SET_POSITIONS_TO_VEHICLE (KEY_v by default, that key is unused in the
menu), so the usual work flow can be done with the keyboard alone:
V set the positions, C generate the course, X start the job.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Tensuko

Tensuko commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Die Übersetzung muss in die MasterTranslation.xml

https://github.com/Courseplay/Courseplay_FS25/wiki/Translations

@Tensuko

Tensuko commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Passt hier nich mehr.
grafik

@Tensuko
Tensuko marked this pull request as draft August 25, 2026 10:03
@helgehelge123

Copy link
Copy Markdown
Author

@Tensuko Hättest du einen Wunsch in welche Kategorie es mit aufgenommen werden könnte, um eine Zeile zu sparen?
Es war erst in der Kategorie "Feldposition" mit drin, was für viele Missclicks bei mir gesorgt hat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants