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

Lua unit:select(true, true) does not fire select events #5931

Open
stevecotton opened this issue Jul 6, 2021 · 1 comment
Open

Lua unit:select(true, true) does not fire select events #5931

stevecotton opened this issue Jul 6, 2021 · 1 comment
Labels
Bug Issues involving unexpected behavior. Lua API Issues with the Lua engine and API.

Comments

@stevecotton
Copy link
Contributor

Game and System Information

  • Very latest version of master on Linux

Describe the bug

According to the docs, unit:select(true, true) will trigger an [event]name=select. It doesn't.

To Reproduce

Add this code to the unit test in PR #5927 :

+++ b/data/test/scenarios/test_synced_state.cfg
@@ -23,6 +23,17 @@
                             return { value = wesnoth.current.synced_state }
                         end)
                     unit_test.assert_equal(result.value, 'local_choice', 'wrong value returned, within synced event')
+                    wml.variables["start_event_happened"] = true;
+                >>
+        [/lua]
+    [/event]
+
+    [event]
+        name=select
+        [lua]
+            code =<<
+                    unit_test.assert_equal(wesnoth.current.synced_state, 'unsynced', 'select should be unsynced')
+                    wml.variables["select_event_happened"] = true;
                 >>
         [/lua]
     [/event]
@@ -32,6 +43,11 @@
         [lua]
             code =<<
                     unit_test.assert_equal(wesnoth.current.synced_state, 'synced', '“turn X” should be synced')
+
+                    local u = wesnoth.units.find_on_map({id = "alice"})
+                    u[1]:select(true, true)
+                    unit_test.assert(wml.variables["start_event_happened"], 'Skipped the start event')
+                    unit_test.assert(wml.variables["select_event_happened"], 'Skipped the select event')
                 >>
         [/lua]
 

Result will be

Assertion failed: Skipped the select event
FAIL TEST: test_synced_state
@stevecotton stevecotton added the Lua API Issues with the Lua engine and API. label Jul 6, 2021
@stevecotton
Copy link
Contributor Author

There's a WML unit test for this in #5938, written in WML so that it can run on 1.14. The event doesn't fire on 1.14 either.

@Wedge009 Wedge009 added the Bug Issues involving unexpected behavior. label Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues involving unexpected behavior. Lua API Issues with the Lua engine and API.
Projects
None yet
Development

No branches or pull requests

2 participants