Post your modding questions here

vitalie
Member
 
Posts: 66
Joined: Wed Feb 24, 2016 07:38
GitHub: ciubotaru

Re: Post your modding questions here

by vitalie » Tue May 31, 2016 17:12

How should I register a node, so that it disappears on digging without appearing in player's inventory and without dropping anything?
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Tue May 31, 2016 17:48

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.register_node("fruitgrow:apples", {
   description = "Apples",
   paramtype = "light",
   tiles = {"default_apple.png^default_leaves.png^default_torch_animated.png"},
   drawtype = "allfaces_optional",
   is_ground_content = false,
   groups = {dig_immediate=3, leafdecay=1, leaves=1},
   drop = {
      max_items = 0,
},
})


Here you go !
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

vitalie
Member
 
Posts: 66
Joined: Wed Feb 24, 2016 07:38
GitHub: ciubotaru

Re: Post your modding questions here

by vitalie » Tue May 31, 2016 18:41

azekill_DIABLO, thank you!

I wrote "drops = " instead of "drop = ", and couldn't understand why it doesn't work.
 

Soudon
Member
 
Posts: 167
Joined: Wed Apr 08, 2015 17:14
In-game: Soudon

init.lua error can't figure it out please help.

by Soudon » Fri Jun 03, 2016 02:36

Ok so I am attempting to make my own mod and it is one that is adding a few more "modern" weapons to the game. This is the error I get

init.lua:4: '<eof>' expected near 'end'

First my init.lua looks 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
local modpath = minetest.get_modpath(minetest.get_current_modname())

dofile(modpath.."/guns.lua")
end


and I do have a separate lua called guns.lua and it looks 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
modernguns:register_weapon("modernguns:mp5holo", {
   description = "MP5(ranged damage 3|max ammo 30)",
   inventory_image = "modernguns_mp5holo.png",
   rounds = 10,
   shots = 3,
   spec = {
      range = 285,
      step = 20,
      tool_caps = {full_punch_interval=0.125, damage_groups={fleshy=3}},
      groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
      sound = "modernguns_mp5",
      particle = "modernguns_bullet.png",
   },
})
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Fri Jun 03, 2016 02:44

Remove "end" in the first file.
 

Soudon
Member
 
Posts: 167
Joined: Wed Apr 08, 2015 17:14
In-game: Soudon

Re: Post your modding questions here

by Soudon » Fri Jun 03, 2016 02:46

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
2016-06-02 22:44:55: WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
2016-06-02 22:44:55: WARNING[Main]: Undeclared global variable "modernguns" accessed at ...test\bin\..\games\minetest_game\mods\modernguns/guns.lua:1
2016-06-02 22:44:55: ERROR[Main]: ModError: Failed to load and run script from C:\Games\Minetest\bin\..\games\minetest_game\mods\modernguns\init.lua:
2016-06-02 22:44:55: ERROR[Main]: ...test\bin\..\games\minetest_game\mods\modernguns/guns.lua:1: attempt to index global 'modernguns' (a nil value)
2016-06-02 22:44:55: ERROR[Main]: stack traceback:
2016-06-02 22:44:55: ERROR[Main]:    ...test\bin\..\games\minetest_game\mods\modernguns/guns.lua:1: in main chunk
2016-06-02 22:44:55: ERROR[Main]:    [C]: in function 'dofile'
2016-06-02 22:44:56: ERROR[Main]:    ...test\bin\..\games\minetest_game\mods\modernguns\init.lua:3: in main chunk
2016-06-02 22:44:56: ERROR[Main]: Check debug.txt for details.


Throws this now that I removed end,

OK I got it to load into the game now I just need to figure out this "projectile thing"

instead of reinventing the wheel I'm going to use the mod shooter and just revamp it with new weapons
 

Izaya
New member
 
Posts: 1
Joined: Fri Jun 03, 2016 08:33
GitHub: XeonSquared
IRC: XeonSquared
In-game: XeonSquared

Re: Post your modding questions here

by Izaya » Sat Jun 04, 2016 16:09

Topic: Lua 5.1 replacements for bit32?
Reason: Need to extract bits from bytes
I've played with bit32 in lua 5.2 but 5.1 lacks it. What other options do I have in the context of Minetest?
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sun Jun 05, 2016 04:20

With the new doors api, is it possible to make doors utilize 2 node spaces..., so doors are place in the center of nodes and then able to occupy a portion of the next node when in the open position?
It took me a few minutes to figure out why, when I changed the doors pos, that it would just swing to the side within the same space (looking extremely odd)
Flick?... Flick who?
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Sun Jun 05, 2016 05:11

TumeniNodes wrote:With the new doors api, is it possible to make doors utilize 2 node spaces..., so doors are place in the center of nodes and then able to occupy a portion of the next node when in the open position?
It took me a few minutes to figure out why, when I changed the doors pos, that it would just swing to the side within the same space (looking extremely odd)


No, the doors API only supports the classical door mesh that is 1 node wide/deep, and 2 nodes high.
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Re: Post your modding questions here

by amadin » Sun Jun 05, 2016 12:19

How change formspec background image and buttons background in inventory_plus (http://github.com/cornernote/minetest-i ... s/init.lua)?
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sun Jun 05, 2016 15:42

sofar wrote:
TumeniNodes wrote:With the new doors api, is it possible to make doors utilize 2 node spaces..., so doors are place in the center of nodes and then able to occupy a portion of the next node when in the open position?
It took me a few minutes to figure out why, when I changed the doors pos, that it would just swing to the side within the same space (looking extremely odd)


No, the doors API only supports the classical door mesh that is 1 node wide/deep, and 2 nodes high.


Bummer
Flick?... Flick who?
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Sun Jun 05, 2016 16:51

amadin wrote:How change formspec background image and buttons background in inventory_plus (http://github.com/cornernote/minetest-i ... s/init.lua)?


Hope I am not overstepping by trying to answer this?
Inventory Plus seems to use the default gui images. The background image is simply a tile, which is repeated to cover the area set in the x, and y coords, and the slots is the same.
You may need to figure out the overall "area" of the bg and convert it to px sizes, then create the background image to that size, then replace the default "gui_formbg.png" with your new image.
For the buttons (or slots I presume you mean), simply create a 49px X 49px image to replace the default "gui_hb_bg.png" with.
At least this is what I see from a quick glance
*VERY IMPORTANT! Just remember..., and NEVER forget to back up the original copies before you begin. If anything goes wrong you can use the backups to revert too.
If you need some help with this, I can offer it, simply ask. I have played around with similar aspects in Minetest, it just takes some poking around and no fear in experimenting : )
Flick?... Flick who?
 

oscar14
Member
 
Posts: 34
Joined: Sat Dec 26, 2015 17:40
GitHub: camus14

Re: Post your modding questions here

by oscar14 » Mon Jun 06, 2016 17:32

Topic: how can i make a node that's only placeable in a tipe of node?

Reason: I want to make a mod of a furnace for alloys that's too hot and can only be placed on stone.

More Info: I am new in modding but I want to learn. Also sorry for my english, is not my native language.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Mon Jun 06, 2016 19:07

you might check the default:furnace code, as I know there's an effect if you use a furnace next to/on ice (not sure if TenPlus1 coded that for Xanadu)
 

oscar14
Member
 
Posts: 34
Joined: Sat Dec 26, 2015 17:40
GitHub: camus14

Re: Post your modding questions here

by oscar14 » Mon Jun 06, 2016 20:38

KCoombes wrote:you might check the default:furnace code, as I know there's an effect if you use a furnace next to/on ice (not sure if TenPlus1 coded that for Xanadu)


Ok thanks, I will check that.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Tue Jun 07, 2016 10:11

oscar14 wrote:Topic: how can i make a node that's only placeable in a tipe of node?

Reason: I want to make a mod of a furnace for alloys that's too hot and can only be placed on stone.

More Info: I am new in modding but I want to learn. Also sorry for my english, is not my native language.


Define the "on_place" field of the node's definition. More specifically, override it so that if the placement is in a good spot, you call minetest.item_place and return its output. Otherwise, return the original itemstack without doing anything. This would look something like:
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.register_node("mymod:my_node", {
  -- Other fields coming before
  on_place = function(itemstack, placer, pointed_thing)
    local undernode = ... -- Get the node under the location the player tried to place
    local is_good = ... -- Check that the node is valid for placing a furnace on.

    if is_good then
      return minetest.item_place(itemstack, placer, pointed_thing)
    else
      return itemstack
    end
  end,
  -- Other fields coming after
})
Every time a mod API is left undocumented, a koala dies.
 

oscar14
Member
 
Posts: 34
Joined: Sat Dec 26, 2015 17:40
GitHub: camus14

Re: Post your modding questions here

by oscar14 » Tue Jun 07, 2016 11:10

Byakuren wrote:Define the "on_place" field of the node's definition. More specifically, override it so that if the placement is in a good spot, you call minetest.item_place and return its output. Otherwise, return the original itemstack without doing anything. This would look something like:
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.register_node("mymod:my_node", {
  -- Other fields coming before
  on_place = function(itemstack, placer, pointed_thing)
    local undernode = ... -- Get the node under the location the player tried to place
    local is_good = ... -- Check that the node is valid for placing a furnace on.

    if is_good then
      return minetest.item_place(itemstack, placer, pointed_thing)
    else
      return itemstack
    end
  end,
  -- Other fields coming after
})


Thanks!! I was thinking in something like that but didn't know how to do it specifically.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Thu Jun 09, 2016 00:59

Izaya wrote:Topic: Lua 5.1 replacements for bit32?
Reason: Need to extract bits from bytes
I've played with bit32 in lua 5.2 but 5.1 lacks it. What other options do I have in the context of Minetest?

If you know how to set up native libraries (hint: it's not hard, but not trivial either, particularly on Windows; see IRC mod for some tips), you can find a native bit library somewhere by using Google.

If you don't care about/need lightning fast performance, I have some code implementing bitwise operators in pure Lua. </selfpromotion>

EDIT: Also, if running under LuaJIT, you have a bit library at your disposal.
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
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Thu Jun 09, 2016 14:39

can a decoration have a drop, or do I have to use the farming mod to accomplish that?
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Thu Jun 09, 2016 20:35

KCoombes wrote:can a decoration have a drop, or do I have to use the farming mod to accomplish that?


AFAIK, to register a decoration you do:
- register the node for it, where you can insert anything what can be put into any other node definition, like drops
and then
- call register_decoration to make the mapgen place that node at random places in the world.

so it should be no problem to write drop="mydecorations:whatever" into the node definition (register_node)

------------
Question: has anyone here experience with animated models? I need to export a model from blender. What should be exported and what not for it to work in MT, and is there a way to display information about an exported mesh in minetest to see if it worked?
(the best would be if someone experienced could export this model. note, if you just export everything the model does not appear in MT (maybe it's the lamp?))
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Sun Jun 12, 2016 04:56

Is there a way to make minetest.line_of_sight cut corners?
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Re: Post your modding questions here

by amadin » Sun Jun 12, 2016 06:09

There i can find information about textpos? I need change indent on the edges of sign (left, right, up and down) in this code:
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
signs_lib.metal_wall_sign_model = {
   nodebox = {
      type = "fixed",
      fixed = {-0.4375, -0.25, 0.4375, 0.4375, 0.375, 0.5}
   },
   textpos = {
      {delta = {x =  0,     y = 0.07, z =  0.43  }, yaw = 0},
      {delta = {x =  0.43,  y = 0.07, z =  0     }, yaw = math.pi / -2},
      {delta = {x =  0,     y = 0.07, z = -0.43  }, yaw = math.pi},
      {delta = {x = -0.43,  y = 0.07, z =  0     }, yaw = math.pi / 2},
   }
}
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Sun Jun 12, 2016 12:00

pithy wrote:Is there a way to make minetest.line_of_sight cut corners?

You could use your own line function,
the direction vector is given, sort the coords by its abs size (e.g. {x=9, y=6, z=-7} → "x", "z", "y")
and then loop, the inner loop is of the smaller coords
etc.
 

Sobralia
New member
 
Posts: 6
Joined: Tue Jun 07, 2016 12:41
In-game: Sobralia

Re: Post your modding questions here

by Sobralia » Sun Jun 12, 2016 14:04

Considering registering privliges like that:
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.register_privilege("foo", privilege definition)


And using it in chat command ie:
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.register_chatcommand("foo", {
   params = "<bar>",
   description = "Do bar with foo",
   privs = {foo = true},
   func = function( _ , text)
      minetest.chat_send_all(text)
      return true, "foo did bar well"
   end,
})


I'm wondering why we must provide a boolean list to chat command, why not a string list?
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sun Jun 12, 2016 14:34

It makes things easier when doing 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
local privs = minetest.get_player_privs("name") -- not sure if right function
if privs.shout then
    -- has shout
else
    -- doesn't have shout
end


Otherwise you'd need to do a linear search, or sort the list and do a binary search.
For example:

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 privs = minetest.get_player_privs("name") -- not sure if right function
for i, priv in pairs(privs) do
    if priv == "shout" then
        -- has shout
        return
    end
end

-- doesn't have shout
return
 

Gerald
Member
 
Posts: 47
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7

Re: Post your modding questions here

by Gerald » Sun Jun 12, 2016 18:48

I want to execute a function every time a day passes (clock strikes midnight or player sleeps in bed).
Is there a better solution than 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
function check_day(old_count)
   local new_count = minetest.get_day_count()
   if new_count > old_count then
      execute()
   end
   minetest.after(10, check_day, new_count)
end
 

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

Re: Post your modding questions here

by iangp » Sun Jun 12, 2016 22:44

Gerald wrote:I want to execute a function every time a day passes (clock strikes midnight or player sleeps in bed).
Is there a better solution than 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
function check_day(old_count)
   local new_count = minetest.get_day_count()
   if new_count > old_count then
      execute()
   end
   minetest.after(10, check_day, new_count)
end

Why you don't simple get the time of day instead?
I haven't tested but something like that:
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
function check_day()
       if minetest.get_timeofday() == 1 -- 1 is midnight, end of day
            execute() --Do what you whant
       end
       local time_speed = setting_get("time_speed")
       minetest.after(24*60*60*60/time_speed, check_day)
end
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

Gerald
Member
 
Posts: 47
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7

Re: Post your modding questions here

by Gerald » Sun Jun 12, 2016 23:40

iangp wrote:Why you don't simple get the time of day instead?

(timefoday == 1) I do not know if and how long this statement is evaluated to true and it will not work if something manipulates time.
 

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

Re: Post your modding questions here

by iangp » Tue Jun 14, 2016 01:34

Then your solution is fine enough
I don't like use globalsteps and afters but it's currently the only way...
We haven't yet a event listener or something like that in modding api (and I don't even know how to implement that and how difficult it is, I can't C (lol ok I'll stop))
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.add_listener(<var - to - bind>, <desired - value> ,<callback - function>)
--or even some expression
minetest.add_listener(<boolean function>,<callback function>)
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
ynong123
Member
 
Posts: 17
Joined: Fri Mar 11, 2016 13:24
GitHub: ynong123
IRC: ynong123
In-game: ynong123

Re: Post your modding questions here

by ynong123 » Wed Jun 15, 2016 12:26

Topic: How to know that user clicks "Esc" to exit a formspec?
Reason: I want to update my mod "Password Chest".
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron