-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[FR] Setting flags with Lua #4396
Comments
I think there is a function for this although it has a rather confusing Name. But I agree that it should be added. |
i think you have to call |
reopening for now. |
Thanks for catching that. That's what I get for testing the I tried this patch: patch
With this patch, setting flag_icon and color works, but setting flag does not. The lambda is fine, since setting color works. What's missing? I'll revert the setter in the meantime until it's fixed. |
It wasn't working, see #4396 (comment) This partly reverts commit 9bd717c.
i don't see anything wrong, maybe you did a mistake when testing? |
@CelticMinstrel Yes, I did test that setting flag_icon works. I said so in a previous comment. Could it work in some cases and not others, or something? OK, so the setter for flag needs to do what the function you mentioned does, whatever that is. Unrelated, I noticed that after doing |
you call [redraw] iirc. wesnoth.set_terrain does nto do that after perofrmance reasons, but its called at then of every [event] iirc.
is basically just calls reinit_flags_for_side, that's what you ahve already added |
Well, what I mentioned in the comment applies to I don't think we need setters for |
No, I see the problem. set_side_id uses revised patch
We already have a setter for |
By the way, can we come up with a way to make this sort of bug impossible? |
I recall making a pass for that purpose, though it likely never got merged... the basic approach would be to not directly expose the sides array anywhere, so that the exposed API is exclusively 1-based. Then you only have to worry about the -1 in functions internal to... I think it was the model? The game map or something? |
I think i'd also prefer if instead reinit_flags_for_side was changed to use side number of instead of indicies to the array.
I still say the setts are nice to have, celmins main argument, ('one does not expect a real computation form a setter' if i understood correctly) is for this case not really relevant here since one usually does not set flag/color in a loop such that performance here would matter. Also if we even come to the situation where it would matter we can probably change the implementation to a laze calculation of that image where these setts would become simple. |
It absolutely should be, but that's not really in scope for the PR. |
Agreed. What about the other questions, though? As I wrote:
In further consideration I think I prefer to add a setter for |
Flags can be read, but not changed in Lua, e.g. this isn't accepted:
wesnoth.sides[1].flag="hjbd"
That's as documented in the wiki, but I guess it would be good to change flags without WML.
The text was updated successfully, but these errors were encountered: