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

Add testeditor to devtest for easier testing. #15206

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

Conversation

sfence
Copy link
Contributor

@sfence sfence commented Sep 29, 2024

  • Goal of the PR
    Make testing of Minetest a little easier.
    It adds a formspec editor for armor groups, nametags, physics override, hud flags, sky, sun, moon, stars, clouds, lighting, flags, and maybe I forgot to notice something.

To do

This PR Ready for Review.

How to test

Run the devtest game and try the command player_editor.

@sfence
Copy link
Contributor Author

sfence commented Sep 29, 2024

screenshot_20240929_142414

@Zughy Zughy added Feature ✨ PRs that add or enhance a feature Roadmap: supported by core dev PR not adhering to the roadmap, yet some core dev decided to take care of it labels Sep 29, 2024
@SmallJoker
Copy link
Member

I don't think this editor scales well enough. Each API function needs a wrapper of 10 lines (in total).
Could we perhaps bring this down using a lookup table? Example (untested):

local funcs = {
	-- [1] = getter, [2] = setter
	clouds = { "get_clouds", "set_clouds" },
	sky = {
		function(p) return p:get_sky(true); end,
		"set_sky"
	}
	-- ...
}

local function exec(player, func, ...)
	if type(func) == "string" then
		return player[func](player, ...)
	end
	if type(func) == "function" then
		return func(player, ...)
	end

	-- error message
	return nil
end


-- in core.register_chatcommand : skim through the table

		local def = funcs[param]
		if def then
			return editor_formspec_create(name, def)
		end
		return false, "Unknown command"

Verbose descriptions are not needed. The developers who would use this tool do know what kind of functions we're testing.

@appgurueu
Copy link
Contributor

Personally I don't need this. I'd either write my own little test mods, or drag something simpler, but more powerful in:

A simple /lua chatcommand and/or a formspec where you can run Lua code, additionally ideally with an environment which contains a me = <player ref of executing player> variable, and pretty-printing of return values.

Then you can just do something like me:set_lighting{...} and observe the effect or me:get_lighting() and inspect the return value.

@Desour
Copy link
Member

Desour commented Dec 31, 2024

A simple /lua chatcommand and/or a formspec where you can run Lua code, additionally ideally with an environment which contains a me = <player ref of executing player> variable, and pretty-printing of return values.

This is what I'm using (yes, a fork of a fork, modified so that it is more usable, ignoring code quality. take it as inspiration for features or so): https://github.com/Desour/luacmd

But there's no reason why we can't have both.

A node with a formspec where you can store code snippets would also be nice. And maybe such that you can easily add buttons, so PRs and issues can for reproduction just provide a configuration for this node.

@sfence
Copy link
Contributor Author

sfence commented Jan 20, 2025

@appgurueu
Yes, I know about the/lua command. I often use it, make a typo error, and lose a few minutes of my time by checking if it does not work or if I made a typo error.

For example, if I want to check all player-specific graphic settings before release, I have to write many lines of /lua commands and I am sure, I make many typo errors.

With player_editor I need only a few commands, and form spec will lead me.

It definitely can be done as a separate mod. I created PR because I find it potentially helpful for Luanti testing purposes.
It looks to me similar to other formspec-based editors included in devtest. Every form spec editor can be removed from devtest and replaced with \lua command.

But if other code devs do not see the benefits of this, let's close this PR.

@appgurueu
Copy link
Contributor

I am not opposed to this PR. I was just saying that I don't find it very useful personally. I agree with Desour that "there's no reason why we can't have both". So feel free to move forward. I may add a /lua chatcommand to devtest in a separate PR at some point.

It definitely can be done as a separate mod.

I think you might have misunderstood me. I just said that I often test features added in PRs via a "testbed" mod of mine, not that this has no place in devtest.

@sfence sfence force-pushed the sfence_devtest_testeditor branch from 0768f3c to 73ad9d1 Compare January 25, 2025 06:57
@sfence
Copy link
Contributor Author

sfence commented Jan 27, 2025

@SmallJoker Wrappers reworked to the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Devtest Game Feature ✨ PRs that add or enhance a feature Possible close Roadmap: supported by core dev PR not adhering to the roadmap, yet some core dev decided to take care of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants