-
Notifications
You must be signed in to change notification settings - Fork 137
update Debug.ShowHint #747
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
base: master
Are you sure you want to change the base?
Conversation
support all things which can `tostring`
https://www.lua.org/manual/5.4/manual.html#pdf-tostring If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result. Otherwise, if the metatable of v has a __name field with a string value, tostring may use that string in its final result. Calling another function sounds like asking for troubles. https://www.lua.org/manual/5.4/manual.html#2.1 修正: Debug.ShowHint(tostring(114514)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the debug message and hint functions to support a broader range of inputs by using Lua's "tostring" conversion. Key changes include:
- Adding a check for the parameter count in debug_message.
- Refactoring debug_show_hint to convert any value to string using Lua’s tostring, removing the strict string type check.
lua_pcall(L, 1, 1, 0); | ||
pduel->write_buffer8(MSG_SHOW_HINT); | ||
const char* pstr = lua_tostring(L, 1); | ||
const char* pstr = lua_tostring(L, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider checking the return value of lua_pcall to ensure that the conversion to string succeeded and handling potential errors appropriately.
Copilot uses AI. Check for mistakes.
but reasonable for calling __tostring. this is how it likes on js |
support all things which can
tostring
close Fluorohydride/ygopro-scripts#2913