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 more getter functions/methods for the Lua API #1496

Closed
Wuzzy2 opened this issue Jul 16, 2014 · 11 comments
Closed

Add more getter functions/methods for the Lua API #1496

Wuzzy2 opened this issue Jul 16, 2014 · 11 comments
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API

Comments

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Jul 16, 2014

The Lua API has a lot of setter functions/methods (for setting a value) but it lacks many corresponding getter functions (for receiving a value). I suggest to add these getter functions.

I personally think there is in most cases no reason not to have such functions. It is just inconsistent and incomplete.

The suggested function/method names are like the setter functions, but with “get” instead of “set”. There is a single exception. After the arrow, I write the suggested return value. It is just the same as the input parameters. Remember that Lua functions can return multiple values at once, for example: return 1,2,3,4. I wrote the functions which I consider the most important in bold type.

So, here I list the functions I think are lacking in the Lua API:

For ObjectRefs:

  • get_propertiesobject_property_table
  • get_armor_groupstable_of_group_ratings (I tested it with the luacmd mod this function does not exist for players; since players are basically ObjectRefs, I conclude that this is true for other ObjectRefs as well)
  • get_animationgroup_rating_table, frame_speed, frame_blend
  • get_attachparent, bone, position, rotation
  • get_bone_positionbone, position, rotation

For player objects:

  • get_physics_override → the same table used as input for set_physics_override
  • hud_get_hotbar_itemcount → number
  • hud_get_hotbar_image → texture path
  • hud_get_hotbar_selected_image → texture path
  • get_skybgcolor, type, {texture names}
  • get_day_night_ratio (getter function for to override_day_night_ratio) → ratio or nil
  • get_local_animation → see input parameters of set_local_animation
  • get_eye_offsetfirst_person_offset, third_person_offset

Global functions:

  • minetest.get_gen_notify → flags (a string)
  • minetest.get_player_password (OK, let’s just forget this suggestion, shall we?)
  • minetest.get_mapgen_paramsMapgenParams
  • minetest.get_noiseparam_defaults → see minetest.set_noiseparam_defaults

For all suggested function names, I checked lua_api.txt if it already exists. It did not.

If you think I missed a function, please write a comment.

@sfan5
Copy link
Member

sfan5 commented Jul 16, 2014

minetest.get_player_password → I don’t know, need to think about this.

It would be a major security concern if adding this functionality would even be possible.

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented Jul 16, 2014

OK, then let’s throw this part of the suggestion out of the window then. The rest of the suggestion still stands, of course.

@ShadowNinja
Copy link
Member

Minetest stores passwords hashed and (mildly) salted, so getting the original password should be impossible without brute-forcing it. However, you can easily get the password hash from minetest.auth_table[player_name].password, or, of course, by opening and reading auth.txt.

@sfan5
Copy link
Member

sfan5 commented Jul 17, 2014

[...], so getting the original password should be impossible without brute-forcing.

getting the original password is impossible without brute-forcing!

@webD97
Copy link

webD97 commented Jul 17, 2014

Security problems! honestly? modders have unlimited access to the io functions, that's the problem.
A getter function for a player's password can be useful sometimes, e.g. "pls confirm this action with your password". An alternative would be something like compare_with_playerpassword("string") -> true|false

@sfan5
Copy link
Member

sfan5 commented Jul 17, 2014

compare_with_playerpassword("string") -> true|false

that's easy

function minetest.compare_player_password(name, password)
    return minetest.get_password_hash(name, password) == minetest.auth_table[name].password
end

@webD97
Copy link

webD97 commented Jul 17, 2014

Cool. It should be in builtin :)

@ShadowNinja ShadowNinja added @ Script API Feature request Issues that request the addition or enhancement of a feature labels Oct 1, 2014
@nerzhul
Copy link
Member

nerzhul commented Mar 31, 2015

@ShadowNinja because you are working on mod_security can you provide us some advices on this issue ?

@ShadowNinja
Copy link
Member

@nerzhul: This doesn't interact with mod security.

@TeTpaAka
Copy link
Contributor

This can get closed now. c0335f7

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented May 28, 2015

Thank you very much! Finally it is in. :-)

@Wuzzy2 Wuzzy2 closed this as completed May 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants