Post your modding questions here

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

Try print(dump(inv:get_lists()))?
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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:

Re: Post your modding questions here

by Evergreen » Post

Solved, see last post.
Back from the dead!

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

Re: how can I delete a variable?

by BrunoMine » Post

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?

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: how can I delete a variable?

by qwertymine3 » Post

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
Spoiler
That should save memory as the {<data_of_mod>} can now be removed from memory.

If {<data_of_mod>} contained a string stored else where, that string will not be removed from memory - but the rest of the table will be.

The database[] table will not get smaller in memory though i.e. if it had 2 people and you removed one, it would still have 2 'slots' of memory reserved to be able to put a person in

Overall:

Code: Select all

local annoying_extra_string = "stored string"
local constant = 5
local do_generic_stuff Longer= function() return nil; end

database = { --this table will have enough 'slots' to store the largest no. people you had in it (and a few extra)
    template = {

        string_one = "stored_string", --this string is stored by annoying_extra_string - when the table is deleted only the
                                      --memory used for the 'slot' will be saved
        string_two = "unique_string", --this is unique - when the table is deleted both the memory for the string and slot 
                                      --will be saved

        --What I think would happen with numbers and functions - These are educated guesses however
        number = 5, --when the table is deleted I think any memory used by this can be freed
        another_number = constant, --same as above

        do_stuff = function() return nil; end, --when the table is deleted I assume that all the memory can be
                                         -- freed
        do_more_stuff = do_generic_stuff -- when the table is deleted I assume that only memory from the 
                                         -- 'slot' is saved as the function is still stored by do_generic_stuff
    },
}
Avatar by :devnko-ennekappao:

User avatar
Merlin
Member
Posts: 63
Joined: Tue Dec 09, 2014 22:07
GitHub: sct-0
In-game: my
Location: germany

Re: Post your modding questions here

by Merlin » Post

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/showthr ... look-alike with all important files attached.
As no one yet answered there, I thought I'd try my luck here.

Thanks in advance!

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

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/showthr ... 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?
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
Merlin
Member
Posts: 63
Joined: Tue Dec 09, 2014 22:07
GitHub: sct-0
In-game: my
Location: germany

Re: Post your modding questions here

by Merlin » Post

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.

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

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?
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

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?

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Post

How is set_attach's rotation argument supposed to be formatted? Is it rotation per axis?
Every time a mod API is left undocumented, a koala dies.

ABJ
Member
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.

Re: Post your modding questions here

by ABJ » Post

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?

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

difference of teleport?

by BrunoMine » Post

Code: Select all

player:setpos(pos)

player:moveto(pos)
These two perform exactly the same task?
What is the difference?

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

setpos -> teleport/magic
moveto -> the player will walk from where he are to this point "pos"
(But I haven't tested this yet)
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

Re: Post your modding questions here

by BrunoMine » Post

In 'moveto' the player is teleported.

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

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...
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

Re: Post your modding questions here

by BrunoMine » Post

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.

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

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 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...
Last edited by iangp on Sun Jan 17, 2016 23:33, edited 2 times in total.
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

I'm getting the same... I think this should be reported as an issue...
@rubenwardy do you know something about that?
Last edited by iangp on Sun Jan 17, 2016 23:32, edited 1 time in total.
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

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...
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

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

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

@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...
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
iangp
Member
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp
Location: Brasil - ES

Re: Post your modding questions here

by iangp » Post

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?
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):


OmniStudent
Member
Posts: 261
Joined: Sat Nov 03, 2012 06:40

Re: Post your modding questions here

by OmniStudent » Post

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.

Locked

Who is online

Users browsing this forum: No registered users and 3 guests