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

Deny Invalid Mex Orders gadget (cmd_mex_denier.lua) issues with inserted/prepended commands #2649

Closed
A-Lias opened this issue Feb 22, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@A-Lias
Copy link

A-Lias commented Feb 22, 2024

Description

It appears that the fix to #2641 introduced a new bug that rejects a valid mex build order if the placement is exactly on the metal spot and the command is inserted at the beginning of the command queue (holding space bar, or whatever hotkey you use).

Additionally, issuing a mex build order at an invalid spot with the prepend key held down correctly snaps to the proper location, but the rest of the queued orders are removed. (This is a related, but different issue. I will open a new issue for this.)

Expected Behaviour

A command to place a mex directly on top of a metal spot should be allowed even when the build command is prepended (holding space bar).

Actual Behaviour

A prepended mex build command directly on top of a metal spot will be denied with the warning "Extractors cannot be placed off of metal spots"

Reproduction steps

To replicate: Issue a mex build order exactly on the metal spot while holding spacebar (or whatever your hotkey is for "insert command"/prepend command). The order will be denied.

Other

There seem to be a number of bugs that cause this issue:

This line

bx, bx = cmdParams[4], cmdParams[6] -- this is where the cmd position is placed in prepended commands with commandinsert
seems wrong: it should be

bx, bz = cmdParams[4], cmdParams[6]

Additionally,

if cmdID == CMD_INSERT then
cmdID = cmdParams[2] -- this is where the ID is placed in prepended commands with commandinsert
end
overwrites cmdID, so the check later
if cmdID == CMD_INSERT then
bx, bx = cmdParams[4], cmdParams[6] -- this is where the cmd position is placed in prepended commands with commandinsert
end
will never execute.

I don't have time to test and issue a PR right now, but I think something like this should work for the main placement issue.

if cmdID == CMD_INSERT then
	adjustedCmdID = cmdParams[2] 
end

if not isMex[-adjustedCmdID] then
	return true
end

local bx, bz = cmdParams[1], cmdParams[3]
if cmdID == CMD_INSERT then
	bx, bz = cmdParams[4], cmdParams[6]
end
@A-Lias A-Lias added the Bug Something isn't working label Feb 22, 2024
@A-Lias
Copy link
Author

A-Lias commented Feb 28, 2024

Fixed by #2652 and #2653 and #2671

@A-Lias A-Lias closed this as completed Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant