[0.4.7] ScriptAPI separation

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

[0.4.7] ScriptAPI separation

by PilzAdam » Post

Hello everyone!
The scriptapi in the source code of the engine was moved into a subfolder. This is a huge change in the engine structure and was mostly done by sapier with some tweaks by celeron55 and kahrl. The end-users will most likely not notice anything from this change.

Modders should note, that env functions are now in the global minetest table, that means one calls a function now like this

Code: Select all

minetest.<function>
instead of

Code: Select all

minetest.env:<function>
The old way will be supported for a long while, though, so mods don't break.

Everyone who has a pull request that touches the scriptapi in the engine should rebase it to the new system.

Also the functions minetest.env:add_firefly() and minetest.env:add_rat() are removed, since they are marked as deprecated for a long time and had no functionality.

User avatar
rarkenin
Member
Posts: 668
Joined: Tue Nov 20, 2012 20:48

by rarkenin » Post

It would be good if announcements also had a link to a github revision whenever practical
Admin pro tempore on 0gb.us:30000. Ask me if you have a problem, or just want help.
This is a signature virus. Add me to your signature so that I can multiply.
Now working on my own clone, Mosstest.
I guess I'm back for some time.

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

by kaeza » Post

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
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen
Location: A forest in the midwest
Contact:

by Evergreen » Post

Huhboy, this is going to make a ton of mods not work. It is a good idea though.
Last edited by Evergreen on Sat May 25, 2013 23:50, edited 1 time in total.
Back from the dead!

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

by PilzAdam » Post

Evergreen wrote:Huhboy, this is going to make a ton of mods not work. It is a good idea though.
No mods break. The old way will be supported for a long time.

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

by Evergreen » Post

PilzAdam wrote:
Evergreen wrote:Huhboy, this is going to make a ton of mods not work. It is a good idea though.
No mods break. The old way will be supported for a long time.
Ah okay.
Back from the dead!

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

by paramat » Post

There seems to be a trick for more speed:

Code: Select all

local env = minetest.env
...
env:add_node({x=x,y=y,z=z},{name="default:stone"})
How would i retain the benefit of this trick?
Last edited by paramat on Sun May 26, 2013 03:08, edited 1 time in total.

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

by kaeza » Post

This should do the trick:

Code: Select all

local add_node = minetest.add_node
add_node({x=x,y=y,z=z},{name="default:stone"})
Last edited by kaeza on Sun May 26, 2013 03:41, 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
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

by paramat » Post

Ah cool ... thank you!
Last edited by paramat on Sun May 26, 2013 04:46, edited 1 time in total.

User avatar
Jonathan
Member
Posts: 119
Joined: Tue Apr 02, 2013 14:07
Location: USA

by Jonathan » Post

kaeza wrote:This should do the trick:

Code: Select all

local add_node = minetest.add_node
add_node({x=x,y=y,z=z},{name="default:stone"})
I'm curious, why does this make adding a node faster? Also, I am assuming that this trick would work for the function set_node as well (what exactly is the difference between add_node and set_node anyway, or is there a difference?).
By perseverance the snail reached the ark.
- Charles Spurgeon

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

by PilzAdam » Post

Jonathan wrote:
kaeza wrote:This should do the trick:

Code: Select all

local add_node = minetest.add_node
add_node({x=x,y=y,z=z},{name="default:stone"})
I'm curious, why does this make adding a node faster? Also, I am assuming that this trick would work for the function set_node as well (what exactly is the difference between add_node and set_node anyway, or is there a difference?).
lua-api.txt wrote:minetest.add_node(pos, node): alias set_node(pos, node)

User avatar
Jonathan
Member
Posts: 119
Joined: Tue Apr 02, 2013 14:07
Location: USA

by Jonathan » Post

PilzAdam wrote:
Jonathan wrote:
kaeza wrote:This should do the trick:

Code: Select all

local add_node = minetest.add_node
add_node({x=x,y=y,z=z},{name="default:stone"})
I'm curious, why does this make adding a node faster? Also, I am assuming that this trick would work for the function set_node as well (what exactly is the difference between add_node and set_node anyway, or is there a difference?).
lua-api.txt wrote:minetest.add_node(pos, node): alias set_node(pos, node)
Did they used to be different? I was curious as to why there was two functions.
By perseverance the snail reached the ark.
- Charles Spurgeon

User avatar
qznc
Member
Posts: 55
Joined: Tue Jul 03, 2012 09:02

by qznc » Post

Jonathan wrote:
kaeza wrote:This should do the trick:

Code: Select all

local add_node = minetest.add_node
add_node({x=x,y=y,z=z},{name="default:stone"})
I'm curious, why does this make adding a node faster?
In scripting languages practically everything is a hash map (Javascript,Python,Lua,Ruby,etc). This means "minetest.add_node" performs a lookup into a hash map to get the method called "add_node" from the minetest object. By storing the method in a local variable, you do this lookup only once.

Nevertheless, unless you call the method hundreds or thousands of times, I bet there will be no measurable performance difference.

User avatar
Jonathan
Member
Posts: 119
Joined: Tue Apr 02, 2013 14:07
Location: USA

by Jonathan » Post

qznc wrote:
Jonathan wrote:
kaeza wrote:This should do the trick:

Code: Select all

local add_node = minetest.add_node
add_node({x=x,y=y,z=z},{name="default:stone"})
I'm curious, why does this make adding a node faster?
In scripting languages practically everything is a hash map (Javascript,Python,Lua,Ruby,etc). This means "minetest.add_node" performs a lookup into a hash map to get the method called "add_node" from the minetest object. By storing the method in a local variable, you do this lookup only once.

Nevertheless, unless you call the method hundreds or thousands of times, I bet there will be no measurable performance difference.
Thanks for the info. :)
By perseverance the snail reached the ark.
- Charles Spurgeon

Locked

Who is online

Users browsing this forum: No registered users and 3 guests