Post your modding questions here

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 » Wed Jun 15, 2016 22:00

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

Check for a field named `quit` in your receive fields callback:

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
if fields.quit then
  -- Do something here
end
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
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Wed Jun 15, 2016 22:25

https://s31.postimg.org/5nhckihnf/screenshot_20160616_081407.png
I've been trying to make a centipede for mobs_redo.
The head segment is a seperate mob, and it spawns segments behind it.
Unfortunately there are two problems;
1: there is a gap between the head and body(as shown in the screenshot)
Currently this is what spawns the bodyparts:
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
do_custom = function(self, dtime)
      local pos = self.object:getpos()
      minetest.env:add_entity(pos, "horror:centipede_body")

      minetest.after(0.5, function()
      minetest.env:add_entity(pos, "horror:centipede_body")
      end)
   end,

Is there a faster of better way I could do this?
2: The body segments keep running away and not chasing after the head as they should.
They are set to attack monsters(the head), so they should be following it. Is there a better way to make them follow the head?
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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 » Thu Jun 16, 2016 00:40

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

Documentation :D your best friend:
http://dev.minetest.net/minetest.regist ... ive_fields

"If a player uses ESC to exit a formspec, this will return {["quit"] = "true"}."
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

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 16, 2016 17:23

D00Med wrote:https://s31.postimg.org/5nhckihnf/screenshot_20160616_081407.png
I've been trying to make a centipede for mobs_redo.
The head segment is a seperate mob, and it spawns segments behind it.
Unfortunately there are two problems;
1: there is a gap between the head and body(as shown in the screenshot)
Currently this is what spawns the bodyparts:
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
do_custom = function(self, dtime)
      local pos = self.object:getpos()
      minetest.env:add_entity(pos, "horror:centipede_body")

      minetest.after(0.5, function()
      minetest.env:add_entity(pos, "horror:centipede_body")
      end)
   end,

Is there a faster of better way I could do this?
2: The body segments keep running away and not chasing after the head as they should.
They are set to attack monsters(the head), so they should be following it. Is there a better way to make them follow the head?



You can define a 'follow' item that is wielded by the head (could be invisible), but all body segments would "stand" on top of each other trying to follow the head - I've seen this happen with taming mobs.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Thu Jun 16, 2016 20:47

How does a mob hold an item? I had a look in the mobs_redo api, and it looks like mobs only follow what players are holding. I have managed to improve it a little by changing the speed of the segments and body, and the time after which they disappear. It works ok until the centipede hits a tree or a wall.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

Diamond knight
Member
 
Posts: 262
Joined: Sun Apr 19, 2015 19:50
In-game: Diamondknight or diamond_knight

Re: Post your modding questions here

by Diamond knight » Thu Jun 16, 2016 23:48

What time speed do i set the minetest.conf to to make days last an irl hour and nights last an irl hour
I can never get enough MESE!!!!!!!!!

my subgame: https://forum.minetest.net/viewtopic.php?f=50&t=11901
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Thu Jun 16, 2016 23:56

# Examples: 72 = 20min, 360 = 4min, 1 = 24hour, 0 = day/night/whatever stays unchanged. That's a setting, though, not a modding code. (The answer is 1.)
 

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

Re: Post your modding questions here

by KCoombes » Fri Jun 17, 2016 00:01

Diamond knight wrote:What time speed do i set the minetest.conf to to make days last an irl hour and nights last an irl hour


Based on the examples in the previous post, the time setting of 12 should give you a 2 hour day cycle (1 day and 1 night).
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Fri Jun 17, 2016 08:05

DOOmed, if you add head and segments together you can use something like this:

local mob = minetest:add_entity(pos, "horror:centipede_head")
local ent = mob:get_luaentity()

mob = minetest:add_entity(pos, "horror:centipede_body")
local ent2 = mob:get_luaentity()
ent2.following = ent -- this makes body (ent2) follow head (ent) and can be used on as many segments as u like to follow previous parts...

...this gives you access to MANY of the internal variables that mobs api uses to control them from attack styles, health, gotten (for milk/wool) etc.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Fri Jun 17, 2016 08:12

Haha it's with two 0's :P
But thanks, I'll try this now
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Fri Jun 17, 2016 08:30

Ok... I just realised I have no idea what I'm doing with this, where do I put it?
Do I need to make a new way to spawn the centipede, using that function(that is a function isn't it?)?
Haha thanks for all your help with my mobs.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Fri Jun 17, 2016 10:00

When you spawn the centipede head, place body parts inside do_custom by adding a flag 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
   do_custom = function(self)
      if not self.centipede then
         minetest.chat_send_all(">>> This message is only shown once at spawn")
         self.centipede = true
      end
   end,

... and remember on adding each segment to use the code above to have it follow the previous one.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Fri Jun 17, 2016 21:25

Ok I tried that(in lots of different ways since I still don't really understand), and I keep getting the error:
"Invalid position coordinate 'x'(expected number got nil)"
I have tried using local pos = self.object:getpos(), and adding 'pos' to function(blah, 'pos' here)...
This is difficult to explain without knowing the right terminology.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Sat Jun 18, 2016 06:32

Insert this code into the centipede head definition and see if it works:


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
do_custom = function(self)

    if not self.centipede then
        self.centipede = true -- flip switch so this part is done only once

        -- get head position and define a few temp variables
        local pos = self.object:getpos()
        local mob, ent, ent2

        -- get head entity
        ent = self.object:get_luaentity()

        -- add body and make it follow head
        mob = minetest:add_entity(pos, "horror:centipede_body")
        ent2 = mob:get_luaentity()
        ent2.following = ent

        -- add body and make it follow previous body segment
        mob = minetest:add_entity(pos, "horror:centipede_body")
        ent = mob:get_luaentity()
        ent.following = ent2

    end
end,
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sat Jun 18, 2016 06:50

Still the same problem. Even when I used a specific location instead of 'pos', I got the same error.
I tried googling the error too, and found nothing very helpful.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by Byakuren » Sat Jun 18, 2016 06:56

D00Med wrote:Still the same problem. Even when I used a specific location instead of 'pos', I got the same error.
I tried googling the error too, and found nothing very helpful.


Post your code and error on a paste site (like lpaste.net) in separate pastes.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sat Jun 18, 2016 07:27

Why? can't I just paste it here?
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-18 17:24:09: ERROR[Main]: ServerError: Lua: Runtime error from mod 'horror' in callback ScriptApiEntity::luaentity_Step(): Invalid position coordinate 'x' (expected number got nil).
2016-06-18 17:24:09: ERROR[Main]: stack traceback:
2016-06-18 17:24:09: ERROR[Main]:    [C]: in function 'add_entity'
2016-06-18 17:24:09: ERROR[Main]:    ...est-0.4.14-dev-win64-decbd39\bin\..\mods\horror/mobs.lua:84: in function 'do_custom'
2016-06-18 17:24:09: ERROR[Main]:    ...t-0.4.14-dev-win64-decbd39\bin\..\mods\mobs_redo/api.lua:2108: in function <...t-0.4.14-dev-win64-decbd39\bin\..\mods\mobs_redo/api.lua:2052>

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
do_custom = function(self)

        if not self.centipede then
            self.centipede = true -- flip switch so this part is done only once

            -- get head position and define a few temp variables
            local pos = self.object:getpos()
            local mob, ent, ent2

            -- get head entity
            ent = self.object:get_luaentity()

            -- add body and make it follow head
            mob = minetest:add_entity(pos, "horror:centipede_body")
            ent2 = mob:get_luaentity()
            ent2.following = ent

            -- add body and make it follow previous body segment
            mob = minetest:add_entity(pos, "horror:centipede_body")
            ent = mob:get_luaentity()
            ent.following = ent2

        end

and this?
I'll do it if it's needed though
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by Byakuren » Sat Jun 18, 2016 07:54

It's so we can find the line numbers mentioned in the error. It's hard to figure out where they are without the entire file, and it's hard to navigate the entire file from the forum code viewer.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sat Jun 18, 2016 08:02

Oh ok, well the code is here: http://lpaste.net/166733
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Sat Jun 18, 2016 09:06

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
do_custom = function(self)

        if not self.centipede then
            self.centipede = true -- flip switch so this part is done only once

            -- get head position and define a few temp variables
            local pos = self.object:getpos()
            local obj, obj2, ent

            -- add body and make it follow head
            obj = minetest:add_entity(pos, "horror:centipede_body")
            ent = obj:get_luaentity()
            ent.following = self.object

            -- add body and make it follow previous body segment
            obj2 = minetest:add_entity(pos, "horror:centipede_body")
            ent = obj2:get_luaentity()
            ent.following = obj

            -- add body and make it follow previous body segment
            obj = minetest:add_entity(pos, "horror:centipede_body")
            ent = obj:get_luaentity()
            ent.following = obj2

        end
end,
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sat Jun 18, 2016 09:14

Still the same, perhaps it would be best if I just improved the method I was using before.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by Byakuren » Sat Jun 18, 2016 10:06

What gets printed out if you print(dump(pos)) before trying to add the entity?
Every time a mod API is left undocumented, a koala dies.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sat Jun 18, 2016 21:01

I think this is it: WARNING[Main]: Map::getNodeMetadata(): Block not found
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by Byakuren » Sat Jun 18, 2016 23:54

It should be printing out a table, look for 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
{
   x = 42,
   y = 69,
   z = 666,
}


(Or post your debug output)
Every time a mod API is left undocumented, a koala dies.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sun Jun 19, 2016 00:31

I tried printing/dumping, but couldn't find anything in debug.txt, so I did it in chat, using pos_to_string, and I a similar result to what you have there, so that means that the position isn't the problem right?
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by Byakuren » Sun Jun 19, 2016 05:17

I tested it on my own computer and found the bug after half an hour. You are calling add_entity with method syntax, which passes the minetest table as the first input.
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_entity(pos, "blah")

-- Which translates to
minetest.add_entity(minetest, pos, "blah")


add_entity's first argument is supposed to be the position, so it looks for the x coordinate in minetest, which of course there is none, and then complains. You need to call it as
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_entity(pos, "blah")


+ Spoiler
Every time a mod API is left undocumented, a koala dies.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Sun Jun 19, 2016 06:50

It works, thanks!
I am now kicking myself for not trying that earlier, I've had similar problems before.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

darkflamez
New member
 
Posts: 4
Joined: Wed Jun 22, 2016 21:15

Re: Post your modding questions here

by darkflamez » Thu Jun 23, 2016 14:42

I would like to know on how should I start modding the game since I am a newbie. Also I have read a few tutorials on the game but I am still not clear.

I would also like to know on how some of the modders on this forum got started.
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Thu Jun 23, 2016 15:08

This is usually the first step in modding in minetest: http://rubenwardy.com/minetest_modding_book/
 

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

Re: Post your modding questions here

by Hybrid Dog » Thu Jun 23, 2016 17:32

darkflamez wrote:I would also like to know on how some of the modders on this forum got started.

l edited other mods, at first just simple stuff and then gradually more and more complicated changes,
I DID NEVER LEARN FROM THAT MODDING BOOK, tenplus1

Even if you e.g. only change "Dirt" (the description of the default:dirt node) to "brown node" in the nodes.lua file of the default mod, you performed modding.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron