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

Lua HUD #612

Closed
wants to merge 2 commits into from
Closed

Lua HUD #612

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 7, 2013

No description provided.

@kaeza
Copy link
Contributor

kaeza commented Apr 7, 2013

Some documentation would be nice.
Do you have any mod to test this?

@PilzAdam
Copy link
Contributor

PilzAdam commented Apr 7, 2013

Yea, description is definetly needed here.
This requires a protocol version bump and why are you deleting a commen in camera.cpp that is completly unrelated to your changes?

@ghost
Copy link
Author

ghost commented Apr 7, 2013

Well, I used this to test the hud out:

minetest.register_craftitem("test:test", {
    inventory_image = "default_tool_steelaxe.png",
    on_place = function(itemstack, placer, pointer)
    local id1 = placer:hud_add(id1,
        {type="I", text="default_tool_steelaxe.png",
        position={x=0.5, y=0.5}, scale={x=5, y=5}})
    local id2 = placer:hud_add(id2, {type="T", text="HELLO!",
        scale={x=100, y=100}, position={x=0.5, y=0.25}})
    local id3 = placer:hud_lock_next_bar()
    placer:hud_change(id3, 3, "default_tool_steelaxe.png")
    placer:hud_change(id3, 4, 5)
    local id4 = placer:hud_add(id4, {type="i", text="main", number=5, item=2,
        dir=2, position={x=0.25, y=0.5}})
        minetest.after(1, function()
            dump2(placer:hud_get(id1))
            placer:hud_unlock_bar(id3)
            placer:hud_rm(id1)
            placer:hud_rm(id2)
            placer:hud_rm(id3)
            placer:hud_rm(id4)
        end)
        return itemstack
    end,
})

For documentation, the players now have two extra methods: hud_add and hud_rm. The first arg of both of these is a string for identification. hud_add's second arg specifies the "drawform", a simple string specifying the type and specs of an object on the screen. Examples can be seen in above.
EDIT: updated code.

@PilzAdam
Copy link
Contributor

PilzAdam commented Apr 8, 2013

Can you add documentation to doc/lua-api.txt?

@Zeg9
Copy link
Contributor

Zeg9 commented Apr 8, 2013

👍 This would be really great (if it works, haven't tested, but I guess it does)

@Uberi
Copy link
Contributor

Uberi commented Apr 8, 2013

There's a typo on the third changed line - "completely". You might want to squash the commits too.

Having Lua HUDs is pretty awesome, I can see a ton of potential uses for it.

@PilzAdam
Copy link
Contributor

PilzAdam commented Apr 8, 2013

"but have a comletely different syntax. This may be changed later on."
This isnt good at all.

@ghost
Copy link
Author

ghost commented Apr 9, 2013

Arrrg. Pirates are baad spelllers. :)

Anyway, if you like, I can rewrite the code to use the formspec syntax.

@Zeg9
Copy link
Contributor

Zeg9 commented Apr 9, 2013

I think you can keep this one, but don't say "it might be changed later"... Wait for PilzAdam's answer though ;)

@PilzAdam
Copy link
Contributor

PilzAdam commented Apr 9, 2013

This comes rather out of the blue. We havent discussed it at the IRC or anything else.
I think it would be best if you come to #minetest-dev @ Freenode and discuss the syntax and other stuff with the other core devs.

@ghost
Copy link
Author

ghost commented Apr 9, 2013

+1 hope it gets added

@iqualfragile
Copy link

Please make sure to have some kind of mechanism handling minetests possibilities: having a lot of mods.
You need to provide some way to check if the region one wants to draw in is already occupied by another mod, or even better: do not allow positioning of certain elements from lua (esp. the statbar) but position it automatic.
If no such mechanism gets added minetest will look like a website from the nineties+ a lot of banners within no time so i would be strongly against merging it.

@ghost
Copy link
Author

ghost commented Apr 11, 2013

http://irc.minetest.ru/minetest-dev/2013-04-09#i_3004477

I'm adding this feature, but only so far for statbars. Maybe more will come soon.

Moreover, this would prevent you from overlaying, e.g. some text over an image. A real estate request feature would be nice, but it would not be automatic.

Jonathon Anderson added 2 commits April 13, 2013 08:10
@PilzAdam
Copy link
Contributor

49f6e34

@PilzAdam PilzAdam closed this Apr 18, 2013
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.

None yet

5 participants