Post your modding questions here

User avatar
AndrOn
Member
 
Posts: 38
Joined: Fri May 31, 2013 22:32

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:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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
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:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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: 2131
Joined: Sun Jan 06, 2013 01:22
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

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

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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

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
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

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
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
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
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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?
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

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: 2131
Joined: Sun Jan 06, 2013 01:22
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
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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?
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
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!
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11

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: 2131
Joined: Sun Jan 06, 2013 01:22
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.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
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?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Wed Jun 19, 2013 12:10

bdjnk wrote: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?

Not currently, other than defining a bunch of nodes with different alpha values, and switch them on the fly.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

dannydanger
Member
 
Posts: 40
Joined: Mon May 06, 2013 23:55

by dannydanger » Wed Jun 19, 2013 13:34

how do i make lava torches?
like
nnn
nln
nsn

n - nothing
l - lava
s - stick

or how do i do it?
 

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

by PilzAdam » Wed Jun 19, 2013 13:43

dannydanger wrote:how do i make lava torches?
like
nnn
nln
nsn

n - nothing
l - lava
s - stick

or how do i do it?

Ehm..... I dont think this question belongs in this topic.
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Wed Jun 19, 2013 17:36

I know this isn't related to modding, but what is the limit to the amount of days/votes that there can be in a poll on the minetest forums? I keep getting an error about it when I try to post.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Wed Jun 19, 2013 17:57

Also, how would I go about detecting a dropped item on top of a node, and if detected, delete it?
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11

by Dan Duncombe » Wed Jun 19, 2013 18:01

Are dropped items counted as entities? If they are, might that help?
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Wed Jun 19, 2013 18:06

Dan Duncombe wrote:Are dropped items counted as entities? If they are, might that help?
Yes they are entities. I already knew that. :P
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

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

by bdjnk » Thu Jun 20, 2013 04:36

I've got some code I'd like to execute whenever a certain type of node is added to the world, including when starting / playing / connecting to the game. Node definitions have lua functions for when hooking to events, for instance on_construct which seemed to most likely candidate, but that doesn't work. Is there some way to do this?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Thu Jun 20, 2013 04:46

bdjnk wrote:I've got some code I'd like to execute whenever a certain type of node is added to the world, including when starting / playing / connecting to the game. Node definitions have lua functions for when hooking to events, for instance on_construct which seemed to most likely candidate, but that doesn't work. Is there some way to do this?

on_construct is only called when the node is placed. Unfortunately, what you require is not so easy (if even practical) to implement.

Edit: I assume you mean the code is run *only* once after connecting. Am I mistaken?
Last edited by kaeza on Thu Jun 20, 2013 04:48, 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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

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

by bdjnk » Thu Jun 20, 2013 06:12

kaeza wrote:
bdjnk wrote:
I've got some code I'd like to execute whenever a certain type of node is added to the world, including when starting / playing / connecting to the game. Node definitions have lua functions for when hooking to events, for instance on_construct which seemed to most likely candidate, but that doesn't work. Is there some way to do this?



on_construct is only called when the node is placed. Unfortunately, what you require is not so easy (if even practical) to implement.

Edit: I assume you mean the code is run *only* once after connecting. Am I mistaken?



I wasn't very clear, sorry. Yeah, I want it to run once, but probably just when the game / server starts. I don't think I need it for all connecting / joining. I would've thought there'd be some kind of mapping / node creation process that occurred which I'd be able to link into...

Still, I gonna try and use register_on_joinplayer or register_on_newplayer and a find_nodes_in_area. I don't think it's the "right" answer, but it might work.

Oh, on that note, what is the difference between register_on_joinplayer and register_on_newplayer? The wiki isn't very clear about it.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron