8000 update Debug.ShowHint by mercury233 · Pull Request #747 · Fluorohydride/ygopro-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mercury233
Copy link
Collaborator

support all things which can tostring
close Fluorohydride/ygopro-scripts#2913

@salix5
Copy link
Collaborator
salix5 commented Apr 25, 2025

https://www.lua.org/manual/5.4/manual.html#pdf-tostring
tostring (v)
Receives a value of any type and converts it to a string in a human-readable format.

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.
如果metatable有__tostring欄位
tostring會呼叫放在那裡的另一個函數
這怎麼看都像是更多麻煩的預兆


https://www.lua.org/manual/5.4/manual.html#2.1
There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.

修正:
一個顯示文字的函數
要求腳本要自己呼叫tostring應該不是很過分的要求

Debug.ShowHint(tostring(114514))

@salix5 salix5 requested a review from Copilot April 25, 2025 15:22
Copy link
@Copilot Copilot AI left a 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.

Comment on lines +182 to +184
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);
Copy link
Preview
Copilot AI Apr 25, 2025

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.

@purerosefallen
Copy link
Collaborator

https://www.lua.org/manual/5.4/manual.html#pdf-tostring tostring (v) Receives a value of any type and converts it to a string in a human-readable format.

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. 如果metatable有__tostring欄位 tostring會呼叫放在那裡的另一個函數 這怎麼看都像是更多麻煩的預兆

https://www.lua.org/manual/5.4/manual.html#2.1 There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.

修正: 一個顯示文字的函數 要求腳本要自己呼叫tostring應該不是很過分的要求

Debug.ShowHint(tostring(114514))

but reasonable for calling __tostring. this is how it likes on js console.log(123)
and at least we have to make ShowHint and Message the same behavior.

@mercury233 mercury233 changed the title update Debug.ShowHint & fix Debug.Message update Debug.ShowHint May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0