Post your modding questions here

bobomb
Member
 
Posts: 115
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Tue Apr 19, 2016 23:00

I stumbled on this older version of the lua api txt file and found what appears to be a way to create your own settings files. https://github.com/minetest/minetest/bl ... .txt#L3063
the usage is not explained though.
I tried:
<pre>
testconf = Setting(path_and_file_name)
</pre>
but then when I try to do things like testconf.write() or testconf.set("foo", "bar") i get errors and anyway the current documentation shows that the methods should be testconf.setting_write(), etc

just wondering if there is a way to make our own per-world conf files?
 

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

Re: Post your modding questions here

by rubenwardy » Tue Apr 19, 2016 23:31

You probably mean to use a colon, ie conf:write() instead of conf.write()

conf:write() is short for conf.write(conf)
 

bobomb
Member
 
Posts: 115
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Wed Apr 20, 2016 02:14

oh yeah of course. that all works now. where is this documented? the new lua api txt file doesn't mention this...
 

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

Re: Post your modding questions here

by kaeza » Thu Apr 21, 2016 16:46

bobomb wrote:oh yeah of course. that all works now. where is this documented? the new lua api txt file doesn't mention this...

From Function Calls in the Lua manual:
The form

functioncall ::= prefixexp `:´ Name args

can be used to call "methods". A call v:name(args) is syntactic sugar for v.name(v,args), except that v is evaluated only once.

Emphasis mine.
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
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Thu Apr 21, 2016 16:53

What is the meaning of evaluating v?
Last edited by Hybrid Dog on Sat Apr 23, 2016 14:51, edited 1 time in total.

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

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

Re: Post your modding questions here

by rubenwardy » Thu Apr 21, 2016 16:57

Evaluate means to find or work out the value of something. So evaluating v is finding out the value of v.
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Thu Apr 21, 2016 17:06

v is a table which means it's a reference to it l think
and the value of v is this reference, isn't it?
So if v is written, the reference to the table is searched (evaluation), thus v.name(v,args) causes two evaluations, doesn't it?
Last edited by Hybrid Dog on Sat Apr 23, 2016 14:51, edited 1 time in total.

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

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

Re: Post your modding questions here

by kaeza » Thu Apr 21, 2016 17:14

Hybrid Dog wrote:v is a table which means it's a reference to it l think
and the value of v is this reference, isn't it?
so if a field of v gets changed somehow, there's no difference if v was evaluated only once or more times, is it?

Consider this example:
Code: Select all
a.b.c.d:func()

The alternative is:
Code: Select all
a.b.c.d.func(a.b.c.d)

Evaluating a.b.c.d only once gives great savings, but is otherwise equivalent.
Now think about things like this:
Code: Select all
somefile:read():sub(...)
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
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Fri Apr 22, 2016 07:04

thanks

kaeza wrote:Now think about things like this:
Code: Select all
somefile:read():sub(...)

This could do the same
Code: Select all
local txt = somefile.read(somefile)
txt.sub(txt, ...)
Last edited by Hybrid Dog on Sat Apr 23, 2016 14:51, edited 1 time in total.

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

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

Re: Post your modding questions here

by kaeza » Fri Apr 22, 2016 07:22

That is the best way IMHO, but my point is that evaluating some expressions may cause side-effects, so it would cause tons of bugs if evaluated more than once.
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
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Fri Apr 22, 2016 07:41

Obviously the sub of another text works on the text

Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print(("unused text").sub("use this",3))
e this

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

User avatar
TortueGaming
New member
 
Posts: 9
Joined: Mon Feb 02, 2015 01:03
In-game: TortueGaming

Re: Post your modding questions here

by TortueGaming » Fri Apr 22, 2016 22:25

How do I use tnt.boom from the new TNT API that's coming in 0.4.14?

I want to make a chest that has a tiny tiny chance of exploding when items are moved to and from it, I have the latest build of Minetest and Minetest_game from Git, and I have the position part of "tnt.boom(position, definition)" down, but I don't know how to fill in "definition".
 

User avatar
Krock
Developer
 
Posts: 4445
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Sat Apr 23, 2016 12:13

TortueGaming wrote:but I don't know how to fill in "definition".


https://github.com/minetest/minetest_ga ... i.txt#L220
It is the same definition like you would use to register a TNT node but you won't need to define the keys "name", "description" and "tiles" for your function call.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

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

Re: Post your modding questions here

by BrunoMine » Sat Apr 23, 2016 17:52

I use a method for to search the generated mapblock with jungletree

Code: Select all
-- small algorithm to detect generation jungles.
minetest.register_on_generated(function(minp, maxp, seed)
   
   -- check height
   if maxp.y < 10 or minp.y > 90 then return end
   
   -- center pos
   local cp = vector.add(minp, 40)
   
   -- load map
   minetest.get_voxel_manip():read_from_map(minp, maxp)
   
   -- search jungle tree
   if minetest.find_node_near(cp, 40, {"default:jungletree"}) == nil then return end
   
   -- More code ...
   
end)

This algorithm seems to work fine, but does not seem to be very efficient for computer processing.
Does anyone have an algorithm that performs the same function?
 

User avatar
MineYoshi
Member
 
Posts: 5372
Joined: Wed Jul 08, 2015 13:20

Re: Post your modding questions here

by MineYoshi » Sun Apr 24, 2016 19:15

A simple question, how to make when i eat, by example: "test:test_food" give me a text, heal me and be replaced by another item???
Happy new Year 2020: let's all aim finally for a clear vision of what we want to make of Minetest!
 

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: Post your modding questions here

by ErrorNull » Sun Apr 24, 2016 22:59

Topic: Immediately halting player's movement

I'm making a mod that needs to freeze a player's movement immediately upon a timer hitting zero. However, I've found that if the player happens do be moving at that moment (up/down/left/right movement key pressed down) and when my timer hits zero.. player:set_physics_override({speed=0}) ...does not register until AFTER the player releases the input... resulting in the player sliding/gliding indefinitely until hitting an obstacle or dropping down a node.

If player was not moving at the time my timer hits, player:set_physics_override({speed=0}) functions as expected and player can longer move.

Is there anything I can do to remedy this? Is there a way to block or ignore player input?
 

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

Re: Post your modding questions here

by iangp » Mon Apr 25, 2016 00:06

ErrorNull wrote:Topic: Immediately halting player's movement

I'm making a mod that needs to freeze a player's movement immediately upon a timer hitting zero. However, I've found that if the player happens do be moving at that moment (up/down/left/right movement key pressed down) and when my timer hits zero.. player:set_physics_override({speed=0}) ...does not register until AFTER the player releases the input... resulting in the player sliding/gliding indefinitely until hitting an obstacle or dropping down a node.

If player was not moving at the time my timer hits, player:set_physics_override({speed=0}) functions as expected and player can longer move.

Is there anything I can do to remedy this? Is there a way to block or ignore player input?

Have you tried treat the player as a entity, SAO object ? (I dunno the right terminology)...
player:setacceleration({x=0, y=0, z=0})
player:setvelocity({x=0, y=0, z=0})
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: Post your modding questions here

by ErrorNull » Mon Apr 25, 2016 03:23

iangp wrote:Have you tried treat the player as a entity, SAO object ? (I dunno the right terminology)...
player:setacceleration({x=0, y=0, z=0})
player:setvelocity({x=0, y=0, z=0})


Thanks for the pointers iangp. I tried inserting both into my code, but neither made any effect to the outcome. I'm still still fairly new to modding minetest and this is just my first mod. I'll need to into working with SAO entity objects. How would I treat the player as an SAO entity? The lua_api.txt states that those functions are "LuaEntitySAO-only (no-op for other objects)" .. so not sure if I can work with these?
 

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

Re: Post your modding questions here

by kaeza » Mon Apr 25, 2016 06:55

It's not possible ATM to modify the player velocity, and the physics override as you say suffer from some misfeatures(though they may actually be useful).

I suggest creating a dummy, invisible entity at the player's position, and attaching the player to it. Look for `set_attach` in the Minetest API.
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
 

KCoombes
Member
 
Posts: 412
Joined: Thu Jun 11, 2015 23:19
Location: SW Florida, USA
In-game: Knatt

Re: Post your modding questions here

by KCoombes » Mon Apr 25, 2016 11:06

MineYoshi wrote:A simple question, how to make when i eat, by example: "test:test_food" give me a text, heal me and be replaced by another item???


I think you want on_use
 

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

Re: Post your modding questions here

by iangp » Mon Apr 25, 2016 11:33

@ErrorNull and @kaeza XD I have a bad memory...
I have missed that: http://dev.minetest.net/ObjectRef
"Note that all ObjectRefs except player are actually LuaEntitySAO."
I just had misremembered ObjectRef as LuaEntitySAO...

-- thats just pseudo-pseudo-code, read the about the right syntax on api_lua.txt
-- As cabeza said try to make a dummy entity:
minetest.register_entity("dummy" ... blablabla.. invisible textures... little size... not pointable...
-- Now you just call it when the timer hit zero, If i'm not wrong... but, whatever, its computationally acceptable to test it...
dummy = minetest.entity_add( on player position, the "dummy" object...
player:set_attach(dummy, "", {0,0,0}, {0,0,0}) --set_attach(parent, bone, position, rotation)`
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
xeranas
Member
 
Posts: 155
Joined: Fri Feb 05, 2016 11:06

Re: Post your modding questions here

by xeranas » Mon Apr 25, 2016 20:25

How I can reset player skybox to default server? I want temporally change user skybox and then return to 'normal'.
 

User avatar
Foghrye4
Member
 
Posts: 24
Joined: Sun Mar 13, 2016 13:38
IRC: Foghrye4
In-game: Foghrye4

Re: Post your modding questions here

by Foghrye4 » Sat May 07, 2016 10:28

xeranas wrote:How I can reset player skybox to default server? I want temporally change user skybox and then return to 'normal'.

save player:get_sky() parameters somewhere, then call them back.

My question.
When i call minetest.sound_stop(whatever) in a middle of a sound i heard a nasty clicks. Calling it exactly on an end of a track is not an option, because it is looped. Is this a bug of OS audio driver or game, or Irrlicht engine? Can i workaround this somehow?
 

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Sat May 07, 2016 12:08

I have a question about this thread. Why?

From my experience with forums (I'm hosting my own forum since 16 years) threads like this doesn't make sense.

- Any answer is lost in over 100 of pages.
- No one can find an answer with the search function
- No one can link to an answer if someone asks an already answered question
- Discussions from different questions can be mixed and confuse more then they help.

It would make more sense to make a modding question subforum instead of this monster thread.

Just my two cent
 

User avatar
benrob0329
Member
 
Posts: 1313
Joined: Thu Aug 06, 2015 22:39
Location: Michigan
GitHub: Benrob0329
IRC: benrob0329
In-game: benrob03

Re: Post your modding questions here

by benrob0329 » Tue May 10, 2016 19:00

Image

Code: Select all
minetest.register_node("usable_decor:cabnet", {
   description = "Wood Cabnet",
   drawtype = "mesh",
   mesh = "usable_decor_cabnet.b3d",
   tiles = {"usable_decore_cabnet.png", "usable_decore_cabnet.png"}
})


Any ideas as to why its black when placed, but not when wielded?
Social: YouTube Peertube Matrix Room: #minetest:matrix.org | Games: The Infinite IKEA
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest