Page 101 of 169

Re: Post your modding questions here

PostPosted: Tue Jan 12, 2016 19:08
by rubenwardy
Try print(dump(inv:get_lists()))?

Re: Post your modding questions here

PostPosted: Tue Jan 12, 2016 19:41
by Evergreen
Solved, see last post.

Re: how can I delete a variable?

PostPosted: Wed Jan 13, 2016 00:43
by BrunoMine
qwertymine3 wrote:This is faster, but messes up the order of the table

but if it is not an ordinary table?
For example:
Code: Select all
database = {}
-- Keeps a value when the player connect
minetest.register_on_joinplayer(function(player)
   local name = player:get_player_name()
   database[name] = {<data_of_mod>}
end)
-- Remove the value when the player leaves
minetest.register_on_leaveplayer(function(player)
   local name = player:get_player_name()
   database[name] = nil
end)

This saves no memory?

Re: how can I delete a variable?

PostPosted: Wed Jan 13, 2016 03:21
by qwertymine3
BrunoMine wrote:but if it is not an ordinary table?
For example:
Code: Select all
database = {}
-- Keeps a value when the player connect
minetest.register_on_joinplayer(function(player)
   local name = player:get_player_name()
   database[name] = {<data_of_mod>}
end)
-- Remove the value when the player leaves
minetest.register_on_leaveplayer(function(player)
   local name = player:get_player_name()
   database[name] = nil
end)

This saves no memory?


I would recommend reading this http://www.lua.org/gems/sample.pdf - this is my main reference for lua specific optimisations

+ My Attempt at an Answer

Re: Post your modding questions here

PostPosted: Wed Jan 13, 2016 11:36
by Merlin
Hi,

I've run into a problem when exporting DirectX files for mobs.
I tried to create a .x file like the ones PilzAdam uses in his SimpleMobs-Mod, but my .x just doesn't look like his and I am rather new to all that stuff and have no idea why.
I posted the whole story over here http://blenderartists.org/forum/showthread.php?390252-How-to-make-these-x-files-look-alike with all important files attached.
As no one yet answered there, I thought I'd try my luck here.

Thanks in advance!

Re: Post your modding questions here

PostPosted: Wed Jan 13, 2016 12:07
by iangp
Merlin wrote:Hi,

I've run into a problem when exporting DirectX files for mobs.
I tried to create a .x file like the ones PilzAdam uses in his SimpleMobs-Mod, but my .x just doesn't look like his and I am rather new to all that stuff and have no idea why.
I posted the whole story over here http://blenderartists.org/forum/showthread.php?390252-How-to-make-these-x-files-look-alike with all important files attached.
As no one yet answered there, I thought I'd try my luck here.

Thanks in advance!

Did you have checked out the Export animation field before your exportation?
And did you have selected all objects of your model?

Re: Post your modding questions here

PostPosted: Wed Jan 13, 2016 12:23
by Merlin
Yes and yes. I did an export with all options checked. It's more about the structure of the files. There are differences in the .blend files which are responsible for the differences of the .x files I guess, but as total noob, I'm unable to spot them.

Re: Post your modding questions here

PostPosted: Wed Jan 13, 2016 13:38
by iangp
hmmm probably is because you have checked all options... (PilzAdam, maybe, only checked out some of them) and so that's can be the difference... got it?
but, why do you want this? planning some script for create .x files from zero in lua? or is a problem in-game?

Re: Post your modding questions here

PostPosted: Wed Jan 13, 2016 16:53
by Hybrid Dog
For calculating those nether trees, would it work faster or slower if l used minetest.hash_node_position instead of the functions from vector.extras?

Re: Post your modding questions here

PostPosted: Thu Jan 14, 2016 00:27
by Byakuren
How is set_attach's rotation argument supposed to be formatted? Is it rotation per axis?

Re: Post your modding questions here

PostPosted: Fri Jan 15, 2016 09:23
by ABJ
I am trying to do this.
Say I have a craft recipe that crafts 9 item1 when 1 item2 is placed in grid. Now I want to make a function that, when called, automatically creates a reverse recipe where 9 item1 goes into 1 grid each to create 1 item2. Anyone have any ideas?

difference of teleport?

PostPosted: Sun Jan 17, 2016 17:45
by BrunoMine
Code: Select all
player:setpos(pos)

player:moveto(pos)

These two perform exactly the same task?
What is the difference?

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 19:53
by iangp
setpos -> teleport/magic
moveto -> the player will walk from where he are to this point "pos"
(But I haven't tested this yet)

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 20:03
by BrunoMine
In 'moveto' the player is teleported.

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 20:28
by iangp
our savior archive: lua_api.txt

* `setpos(pos)`; `pos`=`{x=num, y=num, z=num}`
* `moveto(pos, continuous=false)`: interpolated move

check out this option "continuous" (turn it true and after that false) and see what happens with the player...
I really don't know why moveto are, by default, the same as setpos...

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 21:24
by BrunoMine
iangp wrote:check out this option "continuous" (turn it true and after that false) and see what happens with the player...

I did not realize the difference.

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 23:16
by iangp
that's a strange issue... I will finally make some simple script to test this (how do you implemented that?)
Are your minetest version the 0.4.13 one?
Well that can be a too new function... In rubenwardy's documentation (read it as: "nicer formatted version of lua_api.txt, the documentation that came with minetest.") there's a callback called on_secondary_use
that are called when the player left-click pointing to air (nothing) [I wanted this for my starwars mod] I tried and didn't worked... but I just downloaded the latest github code of minetes and then it worked...
Your situation can be similar to mine...

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 23:27
by rubenwardy
It's not my documentation you're refering to.

The page on my website is just a nicer formatted version of lua_api.txt, the documentation that came with minetest.

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 23:29
by iangp
I'm getting the same... I think this should be reported as an issue...
@rubenwardy do you know something about that?

Re: Post your modding questions here

PostPosted: Sun Jan 17, 2016 23:30
by iangp
rubenwardy wrote:It's not my documentation you're refering to.

The page on my website is just a nicer formatted version of lua_api.txt, the documentation that came with minetest.

yes yes :D sorry about that...

Re: Post your modding questions here

PostPosted: Mon Jan 18, 2016 18:54
by Hybrid Dog
moveto makes it look like object is grabbed and put to pos very fast, whereas
setpos makes it look like object is suddenly at pos

Re: Post your modding questions here

PostPosted: Mon Jan 18, 2016 19:06
by iangp
@Hybrid Dog
it would be cool if this function uses "velocity" as a parameter ...
because this way there's no real reason for use that function... I can't see one...

Re: Post your modding questions here

PostPosted: Mon Jan 18, 2016 19:17
by rubenwardy
iangp wrote:@Hybrid Dog
it would be cool if this function uses "velocity" as a parameter ...
because this way there's no real reason for use that function... I can't see one...


It's for interpolation, to minimise the appearence of lag. When a player walks, you don't want them to suddenly disappear then reappear in a new place, you want the to slide across. Velocity results in extrapolation, if the player is moving/turning fast then it will be unpredictable, so you'd end up with this:

Image

^--- note the player starts here, at the bottom left.

Re: Post your modding questions here

PostPosted: Mon Jan 18, 2016 20:36
by iangp
When a player walks, you don't want them to suddenly disappear then reappear in a new place, you want the to slide across.

Of course
It's for interpolation, to minimise the appearence of lag.

it's for: given a set of positions, if you want the player run through these points... you should use this function to the path seems more smooth...
Right?

Re: Post your modding questions here

PostPosted: Tue Jan 19, 2016 04:52
by OmniStudent
Hello! Can anyone help me with this?

Topic: Need example code that "locks" doors when an object is rightpunched.
Reason: I want to make an "airlock" for entering dungeons.
More Info: I've only done the initial lua tutorial yet, but I am savvy in other languages.