Post your modding questions here

ph8jPf9M
Member
 
Posts: 70
Joined: Sat Jul 16, 2016 10:29
GitHub: 22i

Re: Post your modding questions here

by ph8jPf9M » Fri Aug 19, 2016 18:43

how can i randomise or shuffle items in a chest?
 

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

Re: Post your modding questions here

by Hybrid Dog » Sat Aug 20, 2016 11:42

ph8jPf9M wrote:how can i randomise or shuffle items in a chest?

If it wasn't blocked, you could use
newlist = table.sort(list, function() return math.random(2) == 1 end)
 

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 » Sat Aug 20, 2016 23:44

ph8jPf9M wrote:how can i randomise or shuffle items in a chest?

This may help you.

You can get the items as a list with the `get_list` method of inventories (look it up in `lua_api.txt`):

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 inv = get_inv_from_somewhere()
local list = inv:get_list("main")
-- Shuffle list here
inv:set_list("main", list)
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
cx384
Member
 
Posts: 249
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sun Aug 21, 2016 20:59

How can I set and get a table for a node in meta data?
I know set_string(name, value) get_string(name) set_int(name, value) get_int(name) .
Is it possible to save a whole table in meta?
A table like that {"default:coal_lump", "default:sandstone", test, {"default:stone", "default:sandstone"}}
Can your read this?
 

User avatar
Pyros
Member
 
Posts: 24
Joined: Thu Jul 07, 2016 19:45
In-game: Pyros

Re: Post your modding questions here

by Pyros » Sun Aug 21, 2016 23:54

I'm having a problem with my airplane mod: my version of the Wright Flyer!
(Okay, okay, I admit. I'm just editing Pavel_S's helicopter mod.)

However, I have an error:

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
Failed to load and run script from /home/pyros/.minetest/wrightflyer/init.lua:
/usr/share/minetest/builtin/game/register.lua:97: attempt to index local ‘prototype’ (a nil value)
stack traceback:
/usr/share/minetest/builtin/game/register.lua:97 in function ‘register_entity’
/home/pyros/.minetest/mods/wrightflyer/init.lua:203: in main chunk
Check debug.txt for details.


Can anybody help?

EDIT: Sorry, cx384, for bumping in ahead of you. Oops.
00001-00010-00011-00100-00101-00110-00111-01000-01001- etc...
 

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 » Mon Aug 22, 2016 07:19

cx384 wrote:How can I set and get a table for a node in meta data?
I know set_string(name, value) get_string(name) set_int(name, value) get_int(name) .
Is it possible to save a whole table in meta?
A table like that {"default:coal_lump", "default:sandstone", test, {"default:stone", "default:sandstone"}}

So, if I understand you right, you want to save a table as a single metadata key.
Metadata do not allow to save tables directly. Instead, you can serialize it (convert it into a string).
Save table:
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
meta:set_string("your_key", minetest.serialize(your_table))

Retrieve table:
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
your_table=minetest.deserialize(meta:get_string("your_key"))
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

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 » Mon Aug 22, 2016 07:21

Pyros wrote:I'm having a problem with my airplane mod: my version of the Wright Flyer!
(Okay, okay, I admit. I'm just editing Pavel_S's helicopter mod.)

However, I have an error:

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
Failed to load and run script from /home/pyros/.minetest/wrightflyer/init.lua:
/usr/share/minetest/builtin/game/register.lua:97: attempt to index local ‘prototype’ (a nil value)
stack traceback:
/usr/share/minetest/builtin/game/register.lua:97 in function ‘register_entity’
/home/pyros/.minetest/mods/wrightflyer/init.lua:203: in main chunk
Check debug.txt for details.


Can anybody help?

EDIT: Sorry, cx384, for bumping in ahead of you. Oops.

In your init.lua in line 203, you are calling minetest.register_entity, but the entity prototype you pass there is nil(not defined).
Look at the last line of the stacktrace.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
cx384
Member
 
Posts: 249
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Mon Aug 22, 2016 08:34

Pyros wrote: Sorry, cx384, for bumping in ahead of you. Oops.

No problem.
orwell wrote:
cx384 wrote:How can I set and get a table for a node in meta data?
I know set_string(name, value) get_string(name) set_int(name, value) get_int(name) .
Is it possible to save a whole table in meta?
A table like that {"default:coal_lump", "default:sandstone", test, {"default:stone", "default:sandstone"}}

So, if I understand you right, you want to save a table as a single metadata key.
Metadata do not allow to save tables directly. Instead, you can serialize it (convert it into a string).
Save table:
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
meta:set_string("your_key", minetest.serialize(your_table))

Retrieve table:
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
your_table=minetest.deserialize(meta:get_string("your_key"))

Thank you very much!
Can your read this?
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Mon Aug 22, 2016 13:37

Will you release this mod?
 

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

Re: Post your modding questions here

by burli » Tue Aug 23, 2016 07:08

Can I change cloud height from a mod?
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Tue Aug 23, 2016 08:57

Surely, what you really will want to ask is "can I change ANYTHING in minetest.conf from a mod?"
 

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 Aug 23, 2016 08:58

burli wrote:Can I change cloud height from a mod?

mmmh....may be hard... maybe you could make the mod write a setting in mt.conf but....
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 !!!
 

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 » Wed Aug 24, 2016 10:55

Isn't there a builtin command /set to set conf options?
Look in builtin/chatcommands.lua, you should find how to change settings
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

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 Aug 25, 2016 16:06

Ok, third time's a charm (I hope)

Here's my code (depends on crafter mod viewtopic.php?f=9&t=3465&hilit=crafter ):
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
   on_punch = function(pos, node, puncher)
      local meta = minetest.get_meta(pos)
      local name = puncher:get_player_name()
      local inv = meta:get_inventory()
      local srclist = inv:get_list("src")
      local dstlist = inv:get_list("dst")
      local cooked = nil
      if srclist then
         cooked = crafter.get_craft_result({method = "churn", width = 3, items = srclist})
      end
            -- check if churn is ready to operate
      if inv:is_empty("src") then
         minetest.chat_send_player(name,"Churn is empty!")
         elseif not inv:room_for_item("dst",cooked.item) then
         minetest.chat_send_player(name,"Churn is full!")
      else
      -- this is the actual working function of the churn
               -- Put result in "dst" list
         inv:add_item(dstlist, cooked)
               -- take stuff from "src" list
         inv:remove_item(srclist, 1)
      end
   end,


The unfortunate result of this is a crash to desktop, with debug file showing only:

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-08-25 11:41:35: INFO[Main]: Started digging
2016-08-25 11:41:35: VERBOSE[Server]: TOSERVER_INTERACT: action=0, item=2, pointed=[node under=5,5,32 above=6,5,32]
2016-08-25 11:41:35: VERBOSE[Main]: OpenALSoundManager::maintain(): 0 playing sounds, 58 sound names loaded
2016-08-25 11:41:36: INFO[Main]: Left button released (stopped digging)
 

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 Aug 25, 2016 19:20

lua_api.txt wrote:remove_item(listname, stack)

You see the name in there?
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
inv:add_item("dst", cooked)
inv:remove_item("src", 1)

should be the right way to do it.

No problem, anybody makes mistakes...
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

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 Aug 25, 2016 19:45

orwell wrote:
lua_api.txt wrote:remove_item(listname, stack)

You see the name in there?
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
inv:add_item("dst", cooked)
inv:remove_item("src", 1)

should be the right way to do it.

No problem, anybody makes mistakes...


See, I knew it was something so simple I'd kick myself - thanks a bunch!
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Fri Aug 26, 2016 17:20

Is it possible to change the playermodel and ground collision model?
 

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 » Fri Aug 26, 2016 20:12

It is possible somehow, but I don't know how exactly. Look into 3d-armor, they do it.

I asked this question some time ago:
How do I export an animated model from Blender so that I can use it in Minetest? Which options to set and what to export?
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

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

Re: Post your modding questions here

by D00Med » Fri Aug 26, 2016 20:29

It is possible to change the player model, I don't know about the collision.
Have a look at player.lua in the default mod of minetest_game
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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 » Fri Aug 26, 2016 21:34

ABJ wrote:Is it possible to change the playermodel and ground collision model?

Player model is possible, via use of the Player API (requires `default` mod).

The collision box is editable for other entities, but hardcoded for the player. I'm pretty sure there are pull requests/issues requesting this functionality, but too lazy to search for them.

HTH
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
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 » Sat Aug 27, 2016 11:33

kaeza wrote:
ABJ wrote:Is it possible to change the playermodel and ground collision model?

Player model is possible, via use of the Player API (requires `default` mod).

The collision box is editable for other entities, but hardcoded for the player. I'm pretty sure there are pull requests/issues requesting this functionality, but too lazy to search for them.

HTH

yes they are some pull request
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 !!!
 

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

Re: Post your modding questions here

by burli » Sat Aug 27, 2016 14:09

What is the maximum lenght for footstep sounds?
 

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 » Sat Aug 27, 2016 17:09

IDK.
very long i think
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 !!!
 

ph8jPf9M
Member
 
Posts: 70
Joined: Sat Jul 16, 2016 10:29
GitHub: 22i

Re: Post your modding questions here

by ph8jPf9M » Sat Aug 27, 2016 19:47

how can i make a mod that when i right click the bed at night it only lets me sleep if i answer beds quiz question correctly? Perhaps with formspecs?
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Aug 27, 2016 20:11

Similar things have already been done. AFAIK IIRC the "if" keyword is what you want to look into here.
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Wed Sep 07, 2016 13:05

is there a way to get the mouse scrolling?
Do not call me -minetest.
Call me DS or DS-minetest.
I am German, so you don't have to pm me English if you are also German.
The background is a lie.
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re: Post your modding questions here

by AnxiousInfusion » Tue Sep 13, 2016 05:05

Losing my mind a little... I have a mod that functions well when I manually substitute the playername "singleplayer" but cannot get it to acquire the playername of an item user.

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_craftitem.....
.....
   on_use = function(user)
   minetest.chat_send_all(tostring(user))
   my_function(user)
   end

(I've condensed this to the relevant bits for example)

Trying to use user:get_player_name() crashes out with nil value and chat_send_all reports the value as 0x41da..... and get_player_name works so well in another mod I've authored.
 

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

Re: Post your modding questions here

by D00Med » Tue Sep 13, 2016 07:16

have you tried using 'placer' instead of 'user'? That seems to work for me sometimes, but I don't really know.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Post your modding questions here

by taikedz » Tue Sep 13, 2016 09:33

You are specifying the arguments in the on_use wrong

https://github.com/minetest/minetest/bl ... .txt#L3566

This should work:

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
   on_use = function(itemstack, user, pointed_thing)
   minetest.chat_send_all(user:get_player_name() )
   my_function(user)
   end
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re: Post your modding questions here

by AnxiousInfusion » Tue Sep 13, 2016 18:16

my_function still seems to be receiving userdata when it's expecting a string. I'll have to dissect this line by line.

Edit: So I'm kind of an idiot. "player" apparently needs to be used to refer to the player when defining a function parameter where I was trying to use "user".
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests

cron