Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

P4: Lua io.AxisInverted always fails

Đang mở Phù hợp với người mới
#7,946 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
70/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, lua
Lĩnh vực
game-dev

Hướng nghiên cứu

Lỗi nằm ở phần kiểm tra ID bộ điều khiển ở đầu io.AxisInverted trong scripting/api/libs/controls.cpp, khoảng dòng 279, và trong vòng lặp tìm binding rồi dừng tại JOY_REL_THROTTLE_AXIS. Hãy bắt đầu bằng việc đọc hàm đó và các setter thuộc tính theo từng trục mà nó phải khớp. Hoàn thành nghĩa là ba lời gọi trong bản tái hiện (đảo chuột, truy vấn chuột, đảo joystick 0) trả về các giá trị mong đợi và io.HeadingAxisPrimaryInverted cùng io.HeadingAxisSecondaryInverted đọc ra true sau đó. Issue để ngỏ việc có nên xóa hàm hay không, nên hãy xác nhận lựa chọn đó với maintainer trước.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

This is minor: it only affects scripts, and the per-axis setters such as io.HeadingAxisPrimaryInverted work as a workaround.

Problem

The Lua function io.AxisInverted(cid, axis, inverted) never does anything. It always returns false, and setting an axis inverted through it doesn't change the binding.

The check on the controller ID at the top of the function (scripting/api/libs/controls.cpp:279) can never pass: the mouse (cid -1) fails joy < CID_JOY0, and every joystick (0 to 3) fails joy != CID_MOUSE. So the function returns its error value before it looks at any binding.

Steps to reproduce

  1. Current master (8afa31842), Debug build, Linux. MediaVPs 5.0.2, no other mods, SM1-01.
  2. By default the mouse X axis and joystick 0's X axis are bound to the heading axis.
  3. From a script, run:
    • io.AxisInverted(-1, 0, true) and then io.AxisInverted(-1, 0)
    • io.AxisInverted(0, 0, true)
  4. Read io.HeadingAxisSecondaryInverted and io.HeadingAxisPrimaryInverted.

Expected vs. actual behavior

Expected: the first call inverts the mouse binding and the second returns true; the third inverts the joystick binding. The heading axis properties then read true.

Actual: all three calls return false, and both heading properties stay false. Setting io.HeadingAxisPrimaryInverted = true directly does work, so the binding itself can be inverted.

Separately, even with the check fixed, the loop that searches for the binding stops at the relative throttle axis, so any axis action added after it would never be found.

Proposed fixes

  1. Change the check to reject only IDs that are neither the mouse nor a joystick: (joy != CID_MOUSE) && ((joy < CID_JOY0) || (joy >= CID_JOY_MAX)).
  2. Same as 1, and loop up to JOY_AXIS_END instead of JOY_REL_THROTTLE_AXIS, so every axis action is searched.
  3. Remove AxisInverted in favor of the per-action properties, if no script relies on it.
Ngôn ngữ chính
C++
Star
488
Fork
184
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
35

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của scp-fs2open/fs2open.github.com

Tất cả issue của scp-fs2open/fs2open.github.com

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.