Cycling through nodes

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

Cycling through nodes

by bgsmithjr » Wed Apr 04, 2012 22:09

There should a poll player position function or something, Instead of cycling through every block in the game,about my previous post, this isn't the engines fault. That way you can always get the players position without relying on nodes. To get an object reference to a player, you have to find him in the radius from a node, hit a node, or step on a node. So now I have to use an abm, or the nodes on step function, or the nodes punch or dig funtion. Because I can't cycle through every air block to find it is the right height, then drop a snow entity underneath it without lagging. I was wanting to just add it 30 blocks above the player as long as it is air. Well there was another problem, I couldn't get the position of an air node. If the block 30 spaces above a player was not nil it should drop a snowflake, but it won't let me do that from an abm. Air abm possible???
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Wed Apr 04, 2012 22:32

Ok i got, you read the setting from the config using minetest.get_setting
get the player name
get player by name
player:getpos
But cycling thru so many nodes is still a problem.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Wed Apr 04, 2012 23:16

Why not use something like 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)
    timer = timer + dtime
    if timer >= 2 then
        timer = timer - 2
    else
        return
    end
    for name, p_obj in pairs(minetest.get_connected_players()) do
        pos = p_obj:getpos()
        pos.y = pos.y+30
        if minetest.env:get_node(pos).name == "air" then
            -- Your code here to add snowflake at pos
        end   
    end
end)
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Wed Apr 04, 2012 23:49

Because it is not network related, it just for client, the player that is running the client is automatically the player and you automatically have their position, and I am not familiar with onstep, is this a tick of time.
global step? I would need more help, and what is the function with dtime for?
Last edited by bgsmithjr on Wed Apr 04, 2012 23:50, edited 1 time in total.
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Wed Apr 04, 2012 23:55

I need something that will place a snow flake at the top border of the chunk that is loaded, every other second. but it lags too much. your solution is good, but too many sprites lags it too much to play so its impossible to make anyweather. Unless you try making them craftitems or blocks, but I think blocks will lag too.
 

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » Thu Apr 05, 2012 01:35

You can now use minetest.get_connected_players().
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Thu Apr 05, 2012 03:57

thanks, but there is no way around the lag from having so many sprites.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Thu Apr 05, 2012 10:08

why not for singleplAyer, just make them spawn in front of the player?

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Thu Apr 05, 2012 10:17

I don't know what you mean, one block in front of the player only?
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Thu Apr 05, 2012 11:54

Sorry, I WAS ON A TABLET.

Now, the snow particles should only spawn in front of the player in Singleplayer. and not in multi.

So, if the paticles spawn in front of the camera, shoudn't they reduce lag?

Well actually SSP should do so.

Make them spawn in 16 by 16 blocks around the player.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 36 guests

cron