Page 1 of 1
First mod, would this work?

Posted:
Sat Jan 03, 2015 22:43
by sarusian
Im trying to make it so the when the item is used it creates a hud element, is this is wrong how do i create a hud element on use
minetest.register_craftitem("Village Standings", {
description = "View Standing With Encountered Villages",
inventory_image = "villageStandingBook.png"
stack_max = 1
on_use = function(player){
player:hud_add({
hud_elem_type = "image",
scale = {x=67%, y=80%},
text = "sanding_paper.png",
alignment = {x=0,y=0},
offset = {x=0,y=100},
})
Re: First mod, would this work?

Posted:
Sun Jan 04, 2015 00:22
by Napiophelios
if I understand the point of your mod correctly,
formspec is probably a more reasonable option
Re: First mod, would this work?

Posted:
Sun Jan 04, 2015 10:51
by Krock
You can't use the percent sign in Lua, divide the numbers by 100 instead.
Also, your craftitem name is not valid, it should be something like "amazing_mod:my_hud_item"
Re: First mod, would this work?

Posted:
Sun Jan 04, 2015 13:39
by rubenwardy
If you want 68% of the screen, do scale = { x = -68 }
If you want 68% of the image, do scale = { x = IMAGE_SIZE * 0.68 }
Re: First mod, would this work?

Posted:
Sun Jan 04, 2015 21:34
by HeroOfTheWinds
You also are missing commas at the end of the lines pertaining to inventory_image and stack_max.
Re: First mod, would this work?

Posted:
Tue Jan 06, 2015 06:41
by sarusian
Krock wrote:You can't use the percent sign in Lua, divide the numbers by 100 instead.
Also, your craftitem name is not valid, it should be something like "amazing_mod:my_hud_item"
Thanks, luckily I got it to work, lua is so much easier to read then C# or Java that simply reading other mods has taught me quite a bit