First mod, would this work?

sarusian
Member
 
Posts: 11
Joined: Sat Jan 03, 2015 22:40
Location: Oshawa, Ontario, Canada
GitHub: sarusian
IRC: sarusian
In-game: sarusian

First mod, would this work?

by sarusian » Sat Jan 03, 2015 22:43

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},
})
My Mods
___________________________________________________________________
Science adjusts its views based on what's observed. Faith is the denial of observation so that belief can be preserved.

- Tim Minchin
 

User avatar
Napiophelios
Member
 
Posts: 981
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: First mod, would this work?

by Napiophelios » Sun Jan 04, 2015 00:22

if I understand the point of your mod correctly,
formspec is probably a more reasonable option
 

User avatar
Krock
Developer
 
Posts: 4347
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: First mod, would this work?

by Krock » Sun Jan 04, 2015 10:51

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"
>> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

User avatar
rubenwardy
Moderator
 
Posts: 5802
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: First mod, would this work?

by rubenwardy » Sun Jan 04, 2015 13:39

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 }
 

User avatar
HeroOfTheWinds
Member
 
Posts: 470
Joined: Wed Apr 23, 2014 23:16
Location: Hawaii
GitHub: HeroOfTheWinds
IRC: WindHero

Re: First mod, would this work?

by HeroOfTheWinds » Sun Jan 04, 2015 21:34

You also are missing commas at the end of the lines pertaining to inventory_image and stack_max.
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P
 

sarusian
Member
 
Posts: 11
Joined: Sat Jan 03, 2015 22:40
Location: Oshawa, Ontario, Canada
GitHub: sarusian
IRC: sarusian
In-game: sarusian

Re: First mod, would this work?

by sarusian » Tue Jan 06, 2015 06:41

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
My Mods
___________________________________________________________________
Science adjusts its views based on what's observed. Faith is the denial of observation so that belief can be preserved.

- Tim Minchin
 


Return to Modding Discussion



Who is online

Users browsing this forum: addi and 2 guests