[0.4.7] ScriptAPI separation

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

[0.4.7] ScriptAPI separation

by PilzAdam » Fri May 24, 2013 23:16

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
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.<function>

instead of
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.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.
 

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

by rarkenin » Sat May 25, 2013 13:14

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
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sat May 25, 2013 13:21

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 » Sat May 25, 2013 23:49

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.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

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

by PilzAdam » Sat May 25, 2013 23:53

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: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun May 26, 2013 00:09

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.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Sun May 26, 2013 03:07

There seems to be a trick for more speed:
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 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.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

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 May 26, 2013 03:40

This should do the trick:
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 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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Sun May 26, 2013 04:45

Ah cool ... thank you!
Last edited by paramat on Sun May 26, 2013 04:46, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

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

by Jonathan » Tue May 28, 2013 19:02

kaeza wrote:This should do the trick:
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 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

by PilzAdam » Tue May 28, 2013 19:29

Jonathan wrote:
kaeza wrote:This should do the trick:
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 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

by Jonathan » Tue May 28, 2013 19:40

PilzAdam wrote:
Jonathan wrote:
kaeza wrote:This should do the trick:
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 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
 

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

by qznc » Tue May 28, 2013 20:38

Jonathan wrote:
kaeza wrote:This should do the trick:
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 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

by Jonathan » Tue May 28, 2013 20:44

qznc wrote:
Jonathan wrote:
kaeza wrote:This should do the trick:
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 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
 


Return to Minetest News

Who is online

Users browsing this forum: No registered users and 3 guests

cron