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 formspec parameters #1652

Closed
rubenwardy opened this issue Sep 18, 2014 · 3 comments

Comments

Projects
None yet
4 participants
@rubenwardy
Copy link
Member

commented Sep 18, 2014

Having this built in would act as a helper to mod development. It is already done by a lot of mods which all implement their own methods.

minetest.register_chatcommand("a", {func=function(name)
    minetest.show_formspec(name, "test:form", "size[3,2]label[1,1;Hello!]", {one = "1"})
end})

minetest.register_on_player_receive_fields(function(player, formname, fields, params)
    print(dump(params))
end)

Here is an example of implementing it using a Lua mod, however it is hacky:

formspec_params = {}
local _show_formspec = minetest.show_formspec
function minetest.show_formspec(name, formname, formspec, params)
    formspec_params[name] = params
    _show_formspec(name, formname, formspec)
end
minetest.after(0, function()
    for i = 1, #core.registered_on_player_receive_fields do
        local callback = minetest.registered_on_player_receive_fields[i]
        minetest.registered_on_player_receive_fields[i] = function(player, formname, fields)
            return callback(player, formname, fields, formspec_params[player:get_player_name()])
        end
    end
end)
@sapier

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2014

Why not use same thing as html does? invisible form elements, that'd not require adding a completely separate data storage mechanism

@rubenwardy rubenwardy changed the title Add formspec parametres Add formspec parameters Sep 27, 2014

@t4im

This comment has been minimized.

Copy link
Contributor

commented Dec 29, 2014

Hidden fields seem like they would add otherwise preventable options for a manipulated client to change formspec submit outcome.

Like a financial transaction formspec, that might serverside be bound to one source account via parameters might instead be manipulated with hidden forms to let other players pay for oneself.

@rubenwardy

This comment has been minimized.

Copy link
Member Author

commented Dec 29, 2014

They don't need to be hidden fields sent to the client, they can be saved on the server and returned in the fields table on callback. Or my suggestion which adds params.

@rubenwardy rubenwardy closed this May 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.