Post your modding questions here

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
Location: Germany
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sun Jun 09, 2013 14:45

AndrOn wrote:Thanks PilzAdam I am new to lua (sorry for the indentation). I didn't knew the object handling in lua. However I have another error with my new code which is:

Code: Select all
minetest.register_chatcommand("run", {
    params = "",
    description = "run",
    func = function()
    for _, p in ipairs(minetest.get_connected_players()) do
            p:set_physics_override(3, 1.2, 1)
            end
    end,
})


(yes for the moment it affects all the players but I couldn't load your code and I want to use it in singleplayer for the moment)

the error when I type /run:

error: 15 : attempt to call method 'set_physics_override' (a nil value)


(better for the indent btw? ;)

I guess you use a too old version of Minetest (you need 0.4.7 IIRC).

Also, indentation is still not completly correct :-p
Code: Select all
minetest.register_chatcommand("run", {
    params = "",
    description = "run",
    func = function()
            for _, p in ipairs(minetest.get_connected_players()) do
                    p:set_physics_override(3, 1.2, 1)
            end
    end,
})
 

User avatar
AndrOn
Member
 
Posts: 38
Joined: Fri May 31, 2013 22:32
Location: Orléans, France

by AndrOn » Sun Jun 09, 2013 16:25

I guess you use a too old version of Minetest (you need 0.4.7 IIRC).

Also, indentation is still not completly correct :-p


Thanks it works! Time to add some particles like in minecraft (and make a less nasty code + improve indentation... I usually code on codeblocks rightclick->format this file)

Also, someone should update the wiki about the new mods directory because I found it tricky
sorry for bad english
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
Location: New York
GitHub: bdjnk

by bdjnk » Sun Jun 09, 2013 16:32

When one does a register_on_dignode, is there some way to get the oldnode's metadata? You know, because get_meta(pos) will get the new metadata, which is null...
 

User avatar
BlockMen
Developer
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
Location: Germany
GitHub: BlockMen

by BlockMen » Sun Jun 09, 2013 16:51

bdjnk wrote:When one does a register_on_dignode, is there some way to get the oldnode's metadata? You know, because get_meta(pos) will get the new metadata, which is null...


Use
Code: Select all
after_dig_node = function(pos, oldnode, oldmetadata, digger)


in node definition instead
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
Location: New York
GitHub: bdjnk

by bdjnk » Sun Jun 09, 2013 18:23

BlockMen wrote:
bdjnk wrote:When one does a register_on_dignode, is there some way to get the oldnode's metadata? You know, because get_meta(pos) will get the new metadata, which is null...


Use
Code: Select all
after_dig_node = function(pos, oldnode, oldmetadata, digger)


in node definition instead


Hm, yes, well that would be fine if I was just doing it for one type of node, but I was thinking for any type of diggable node.
 

User avatar
AndrOn
Member
 
Posts: 38
Joined: Fri May 31, 2013 22:32
Location: Orléans, France

by AndrOn » Mon Jun 10, 2013 09:40

How do you use get_player_control()?
I try to use it but it gives me nothing.
for example, when I do this:

Code: Select all
minetest.register_globalstep(function(dtime,player)
          for _, p in ipairs(minetest.get_connected_players()) do
                     controls = p:get_player_control()   
                     minetest.chat_send_player(p:get_player_name(), #controls)
           end
end)


It displays "0" for the size of controls. So where is my mistake?
I could use get_player_control_bits (at least it sends something about the pressed keys) but I don't really know how to use its bit structure.
Last edited by AndrOn on Mon Jun 10, 2013 09:41, edited 1 time in total.
sorry for bad english
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
Location: Germany
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon Jun 10, 2013 11:29

AndrOn wrote:How do you use get_player_control()?
I try to use it but it gives me nothing.
for example, when I do this:

Code: Select all
minetest.register_globalstep(function(dtime,player)
          for _, p in ipairs(minetest.get_connected_players()) do
                     controls = p:get_player_control()   
                     minetest.chat_send_player(p:get_player_name(), #controls)
           end
end)


It displays "0" for the size of controls. So where is my mistake?
I could use get_player_control_bits (at least it sends something about the pressed keys) but I don't really know how to use its bit structure.

The table returned by get_player_controls() is not indexed by numbers, so its 0.
Try print(dump(controls))
https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1387
 

User avatar
Evergreen
Member
 
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
Location: A forest in the midwest
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Mon Jun 10, 2013 13:44

How would I go about clearing a formspec? Also, where do I name the formspec in the registration. Code for registration:
Code: Select all
local meta = minetest.env:get_meta(pos)
            meta:set_string("formspec",
                "size[8,9]"..
                "button[0,0;2,1;empty;Empty Trash]"..
                 "list[current_name;main;3,1;2,3;]"..
                 "list[current_player;main;0,5;8,4;]")
                meta:set_string("infotext", "Trash Can")
            local inv = meta:get_inventory()
            inv:set_size("main", 8*4)
        end,
Last edited by Evergreen on Mon Jun 10, 2013 13:45, edited 1 time in total.
Back from the dead!
 

User avatar
lor599
Member
 
Posts: 37
Joined: Sun Mar 17, 2013 12:58
Location: United States

by lor599 » Sun Jun 16, 2013 17:16

How can I make a texture for my mod have sides, like a chest or furnace? like:
Code: Select all
tile_images = {"chest_top.png, chest_side.png,chest_front"}

-Thanks in advance
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11
Location: In the unknown depths of Earth

by Dan Duncombe » Sun Jun 16, 2013 17:35

Get the six pictures, for the different sides. Then, list them in the order of top, bottom, side, side, side, front. E.G
Code: Select all
tile_images = {"block_top.png, block_side.png, block_side.png, block_side.png, block_front.png"}
Including 'front' etc is not necessary in the image names.
lor599 wrote:How can I make a texture for my mod have sides, like a chest or furnace? like:
Code: Select all
tile_images = {"chest_top.png, chest_side.png,chest_front"}

-Thanks in advance
Last edited by Dan Duncombe on Sun Jun 16, 2013 17:37, edited 1 time in total.
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
 

User avatar
lor599
Member
 
Posts: 37
Joined: Sun Mar 17, 2013 12:58
Location: United States

by lor599 » Sun Jun 16, 2013 18:07

Dan Duncombe wrote:Get the six pictures, for the different sides. Then, list them in the order of top, bottom, side, side, side, front. E.G
Code: Select all
tile_images = {"block_top.png, block_side.png, block_side.png, block_side.png, block_front.png"}
Including 'front' etc is not necessary in the image names.
lor599 wrote:How can I make a texture for my mod have sides, like a chest or furnace? like:
Code: Select all
tile_images = {"chest_top.png, chest_side.png,chest_front"}

-Thanks in advance

Thanks
I had to find it out my self :P
but
You forgot to put quotes:
Code: Select all
tile_images = {"block_top.png", "block_side.png", "block_side.png", " block_side.png", "block_front.png"}

Notice: I put the quotes between each image^
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sun Jun 16, 2013 19:36

lor599 wrote:
Dan Duncombe wrote:Get the six pictures, for the different sides. Then, list them in the order of top, bottom, side, side, side, front. E.G
Code: Select all
tile_images = {"block_top.png, block_side.png, block_side.png, block_side.png, block_front.png"}
Including 'front' etc is not necessary in the image names.
lor599 wrote:How can I make a texture for my mod have sides, like a chest or furnace? like:
Code: Select all
tile_images = {"chest_top.png, chest_side.png,chest_front"}

-Thanks in advance

Thanks
I had to find it out my self :P
but
You forgot to put quotes:
Code: Select all
tile_images = {"block_top.png", "block_side.png", "block_side.png", " block_side.png", "block_front.png"}

Notice: I put the quotes between each image^

The docs are here: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1676
Translated to layman terms, the order is top, bottom, right, left, back, front.
Edit: Note also that `tile_images' is deprecated; use `tiles' instead:
Code: Select all
tiles = {"block_top.png", "block_bottom.png", "block_right.png", " block_left.png", "block_back.png", "block_front.png"}
Last edited by kaeza on Sun Jun 16, 2013 19:38, edited 1 time in total.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sun Jun 16, 2013 19:43

Evergreen wrote:How would I go about clearing a formspec? Also, where do I name the formspec in the registration. Code for registration:
Code: Select all
local meta = minetest.env:get_meta(pos)
            meta:set_string("formspec",
                "size[8,9]"..
                "button[0,0;2,1;empty;Empty Trash]"..
                 "list[current_name;main;3,1;2,3;]"..
                 "list[current_player;main;0,5;8,4;]")
                meta:set_string("infotext", "Trash Can")
            local inv = meta:get_inventory()
            inv:set_size("main", 8*4)
        end,

For formspecs associated with node meta, the formname is rarely (if ever) needed.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal
 

User avatar
Evergreen
Member
 
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
Location: A forest in the midwest
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun Jun 16, 2013 20:25

kaeza wrote:
Evergreen wrote:How would I go about clearing a formspec? Also, where do I name the formspec in the registration. Code for registration:
Code: Select all
local meta = minetest.env:get_meta(pos)
            meta:set_string("formspec",
                "size[8,9]"..
                "button[0,0;2,1;empty;Empty Trash]"..
                 "list[current_name;main;3,1;2,3;]"..
                 "list[current_player;main;0,5;8,4;]")
                meta:set_string("infotext", "Trash Can")
            local inv = meta:get_inventory()
            inv:set_size("main", 8*4)
        end,

For formspecs associated with node meta, the formname is rarely (if ever) needed.

Ah ok. Then how do I clear the formspec?
Back from the dead!
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sun Jun 16, 2013 21:04

Evergreen wrote:Ah ok. Then how do I clear the formspec?

What do you mean?
Clear the inventory?
Remove the formspec?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04
Location: United Kingdom, Wales

by JBR » Sun Jun 16, 2013 21:14

If you have a player(objectref) stored in a variable, when that player leaves with the value of the variable become nil?
 

User avatar
Evergreen
Member
 
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
Location: A forest in the midwest
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun Jun 16, 2013 21:17

kaeza wrote:
Evergreen wrote:Ah ok. Then how do I clear the formspec?

What do you mean?
Clear the inventory?
Remove the formspec?

Clear the inventory of the formspec. :P
Back from the dead!
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sun Jun 16, 2013 23:04

Evergreen wrote:
kaeza wrote:
Evergreen wrote:Ah ok. Then how do I clear the formspec?

What do you mean?
Clear the inventory?
Remove the formspec?

Clear the inventory of the formspec. :P

Untested code:
Code: Select all
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, inv:get_size("foo") do
  inv:set_stack("foo", i, nil)
end
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal
 

User avatar
Evergreen
Member
 
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
Location: A forest in the midwest
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun Jun 16, 2013 23:12

kaeza wrote:
Evergreen wrote:
kaeza wrote:What do you mean?
Clear the inventory?
Remove the formspec?

Clear the inventory of the formspec. :P

Untested code:
Code: Select all
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, inv:get_size("foo") do
  inv:set_stack("foo", i, nil)
end

Okay, then what do I replace "foo" with?
Back from the dead!
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sun Jun 16, 2013 23:18

Evergreen wrote:Okay, then what do I replace "foo" with?

The inventory list name. from your code, it seems to be "main".
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal
 

User avatar
Evergreen
Member
 
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
Location: A forest in the midwest
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun Jun 16, 2013 23:29

kaeza wrote:
Evergreen wrote:Okay, then what do I replace "foo" with?

The inventory list name. from your code, it seems to be "main".

Okay. It works, but I tried changing "main" to "trash", and it messed it up. Thanks though!
Back from the dead!
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sun Jun 16, 2013 23:38

JBR wrote:If you have a player(objectref) stored in a variable, when that player leaves with the value of the variable become nil?

Nope.
Evergreen wrote:
kaeza wrote:
Evergreen wrote:Okay, then what do I replace "foo" with?

The inventory list name. from your code, it seems to be "main".

Okay. It works, but I tried changing "main" to "trash", and it messed it up. Thanks though!

You must also modify the inventory name in the formspec (and in the set_size() call).
NOTE: Only for the "current_name" inventory!
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11
Location: In the unknown depths of Earth

by Dan Duncombe » Sun Jun 16, 2013 23:48

How I make nodes work like signs? it's just in my Danger signs mod they turn out like dfeault node... help?
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
 

User avatar
Evergreen
Member
 
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
Location: A forest in the midwest
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun Jun 16, 2013 23:52

kaeza wrote:
JBR wrote:If you have a player(objectref) stored in a variable, when that player leaves with the value of the variable become nil?

Nope.
Evergreen wrote:
kaeza wrote:The inventory list name. from your code, it seems to be "main".

Okay. It works, but I tried changing "main" to "trash", and it messed it up. Thanks though!

You must also modify the inventory name in the formspec (and in the set_size() call).
NOTE: Only for the "current_name" inventory!

I did that, and the player inventory showed fine, but the trash formspec (except the button) is invisible.
Back from the dead!
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
Location: New York
GitHub: bdjnk

by bdjnk » Wed Jun 19, 2013 12:07

Is there any way to alter the node definition values on the fly? For example, if I wanted to smoothly transition a node's alpha using a node timer. Is such a thing possible?
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 4 guests