Post your modding questions here

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Post your modding questions here

by Casimir » Fri Aug 08, 2014 13:25

Then I don't think it is possible, you probably have to use on_use.

Does anybody know why this returns "0" ? I'm calling it five seconds after the game started.
local number = table.maxn(minetest.registered_items)
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Fri Aug 08, 2014 13:28

Casimir wrote:local number = table.maxn(minetest.registered_items)

And
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 number = #minetest.registered_items

?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Post your modding questions here

by Casimir » Fri Aug 08, 2014 13:31

Zero

This 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
   local number = 0
   for name, item in pairs(minetest.registered_items) do
      number = number + 1
   end
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Fri Aug 08, 2014 17:21

Quick Question:
(probably been asked before, but I can't seem to find it)

When crafting an item, how can I get an item as an output and then have another item be put back into my inventory? I wish to craft milk in drinking glasses that uses a bucketful of milk from kpgmobs and vessels. I want the output to be 5 glasses of milk, and I also want to have the bucket be returned to a slot in my inventory. How to do so?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Fri Aug 08, 2014 17:25

philipbenr wrote:<snip>

Do you mean replacements?
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_craft( {
   type = "shapeless",
        output = "homedecor:terracotta_base 8",
        recipe = {
      "default:dirt",
      "default:clay_lump",
      "bucket:bucket_water"
        },
   replacements = { {"bucket:bucket_water", "bucket:bucket_empty"}, },
})

Random from homedecor.
It will return you 8 terracotta base and an empty bucket.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Fri Aug 08, 2014 20:45

I believe so. Thank you, Krock.
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

Re: Post your modding questions here

by lag01 » Fri Aug 08, 2014 21:29

Hello,
i want to write lua code to punish players who hit another players at spawn.
How can i detect when that happens?

Or maybe there already is mod for that?
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Post your modding questions here

by Sokomine » Fri Aug 08, 2014 22:19

philipbenr wrote:When crafting an item, how can I get an item as an output and then have another item be put back into my inventory? I wish to craft milk in drinking glasses that uses a bucketful of milk from kpgmobs and vessels.

There's a receipe (afaik in the food mod?) that uses two buckets of milk for one cheese - without returning any buckets. I'm not sure if two items may be returned simultaneously. Perhaps in such cases a special "machine" might be best. I didn't get around to give the barrels from my cottages mod any functionality yet.
A list of my mods can be found here.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

Re: Post your modding questions here

by Topywo » Sat Aug 09, 2014 08:44

Sokomine wrote:
philipbenr wrote:When crafting an item, how can I get an item as an output and then have another item be put back into my inventory? I wish to craft milk in drinking glasses that uses a bucketful of milk from kpgmobs and vessels.

There's a receipe (afaik in the food mod?) that uses two buckets of milk for one cheese - without returning any buckets. I'm not sure if two items may be returned simultaneously. Perhaps in such cases a special "machine" might be best. I didn't get around to give the barrels from my cottages mod any functionality yet.


replacements = { { "bucket:bucket_water", "bucket:bucket_empty"}, { "charcoal:charcoal", "default:torch 4"}}


This seems to work, giving you the standard output, an empty bucket and 4 torches (tested with charcoal mod). I thought I tried something similar a year ago without any luck, so maybe it's a new feature, idk.


Edit: The replacements are placed in the crafting grid. This means that as long as you can craft, the replacements are not placed in the crafting grid, because the crafting materials are in there. So not very suitable for 'mass' crafting production. It would have been nicer if the replacements would be placed directly in your inventory.
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Wed Aug 13, 2014 16:57

I'm getting the hang of modding minetest now. I'm curious about the limits of the modding api. Can someone give me a rough idea of what is possible with the minetest api? What can and cannot be done.
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

Re: Post your modding questions here

by lag01 » Wed Aug 13, 2014 20:47

leeminer wrote:I'm getting the hang of modding minetest now. I'm curious about the limits of the modding api. Can someone give me a rough idea of what is possible with the minetest api? What can and cannot be done.

For now, i noticed two wierd limitations:
you can use your function on chat message event, but cannot change or cancel message itself.
no api to call your code, when player is hit or killed by other player. workaround i used in my mod, was to use minetest.register_on_dieplayer + minetest.get_objects_inside_radius

You probably already had seen http://dev.minetest.net/Category:Methods, http://dev.minetest.net/Player etc. Also more insane way: http://dev.minetest.net/Global_tables
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Thu Aug 14, 2014 06:00

Been banging my head for some time so here goes.

How can you access the player object in singleplayer and modify it? I am trying to modify the player object to decrease gravity or increase jump height but I get an error when I insert my 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
player:set_physics_override({gravity=3.0})


I also tried

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
user:set_physics_override({gravity=3.0})


I found info here, http://dev.minetest.net/Player, however once again I think I am missing something horribly simple and obvious. Any help would be appreciated. I want my character to jump a round like superman ;)
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

Re: Post your modding questions here

by lag01 » Thu Aug 14, 2014 10:41

leeminer wrote:Been banging my head for some time so here goes.

How can you access the player object in singleplayer and modify it? I am trying to modify the player object to decrease gravity or increase jump height but I get an error when I insert my 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
player:set_physics_override({gravity=3.0})


I also tried

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
user:set_physics_override({gravity=3.0})


I found info here, http://dev.minetest.net/Player, however once again I think I am missing something horribly simple and obvious. Any help would be appreciated. I want my character to jump a round like superman ;)


If you want do this to all players in game, i believe you can do this just by minetest.conf

Else, you must call your code somewhere, where "player" is set, for example inside http://dev.minetest.net/minetest.register_on_joinplayer
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Fri Aug 15, 2014 00:21

Getting closer to changing the speed, gravity and jump of the player. Sooo close...
Can someone tell me why this code doesn't work? It throws a lua init error when launching the world with my mod enabled.

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 player = minetest.get_player_by_name("singleplayer")
player:set_physics_override({gravity=3.0,jump=3.0,speed=3.0})


I also tried the example at this page with no luck...

http://dev.minetest.net/minetest.get_player_by_name

So close I can taste it!
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

Re: Post your modding questions here

by lag01 » Fri Aug 15, 2014 10:34

leeminer wrote:Getting closer to changing the speed, gravity and jump of the player. Sooo close...
Can someone tell me why this code doesn't work? It throws a lua init error when launching the world with my mod enabled.

may-be you are calling your code at wrong place or in wrong time. for example right in mod body, while player "singleplayer" not exists yet.
try something 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
minetest.register_on_joinplayer(function(player)
   player:set_physics_override({gravity=3.0,jump=3.0,speed=3.0})
end)
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Post your modding questions here

by 4aiman » Fri Aug 15, 2014 11:03

You can use minetest.get_connected_players() also
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Fri Aug 15, 2014 17:12

Getting a player object has failed me so far. Even with suggestions. I resorted to modifying the main config file and adjusting gravity jump etc there.

However I was wondering if there is a way to debug a script. Does anyone know how? I need more useful errors than the standard can't load the lua file.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Fri Aug 15, 2014 19:15

leeminer, see https://forum.minetest.net/viewtopic.php?f=11&t=7224 for manual change of physics by chat command, or https://forum.minetest.net/viewtopic.php?f=11&t=6329 for automatic change of physics depending on location.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

Re: Post your modding questions here

by prestidigitator » Sun Aug 17, 2014 00:59

leeminer wrote:Getting a player object has failed me so far. Even with suggestions. I resorted to modifying the main config file and adjusting gravity jump etc there.

However I was wondering if there is a way to debug a script. Does anyone know how? I need more useful errors than the standard can't load the lua file.

There is no built-in debugging mechanism. You can use the print() function to send information to Minetest's standard output (or error—not sure which), which is generally visible when you start Minetest from a command line. The minetest.debug() and minetest.log() functions do similar things. I also created a LuaCmd mod which allows you to run snippets of Lua code from Minetest's chat console and is intended to help with some debugging tasks (such as calling global functions and examining global variables). If you use that mod, give this command a try:

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
/lua me:set_physics_override({ gravity=3, jump=3, speed=3 })


That works because the LuaCmd mod does the player lookup for you and provides the special variable "me" that refers to the player object of the player currently issuing the command.

EDIT: Oh, by the way, setting both gravity and jump to 3 might be a bit cross-purpose, as one allows you a stronger initial jump, while the other causes gravity to pull stronger. You might try one or the other, or setting gravity to a fractional value (e.g. 0.333). By increasing both you may have little or no impact on the player's jump height, though falling off a cliff could be different.
 

User avatar
davidthecreator
Member
 
Posts: 179
Joined: Mon Aug 18, 2014 19:48
In-game: DavidDoesMinetest

how to put mods online

by davidthecreator » Mon Aug 18, 2014 19:54

hi im new at this but im kinda trying to make mods and finaly im succeeded so i would like to know how to make them downloadable to others
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

Re: Post your modding questions here

by Chinchow » Tue Aug 19, 2014 01:22

I am very new to entities, and I would like to know this: How are setacceleration, setvelocity, etc used? I've tried to call them, but I can't figure out how.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

Re: how to put mods online

by Topywo » Tue Aug 19, 2014 09:39

davidthecreator wrote:hi im new at this but im kinda trying to make mods and finaly im succeeded so i would like to know how to make them downloadable to others


You could search for an upload site that let's you upload mods and screenshots. Look at the links in mod releases to get an overview of the most common.

I use dropbox, it suites me best at this moment. GitHub is also a possibility, but that may take more time to get accustomed to. Or Bitbucket.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

Re: Post your modding questions here

by LionsDen » Tue Aug 19, 2014 16:54

davidthecreator you can always use the forum attachment function if you mod isn't huge. If you look below where you type a reply or a topic, there is an options tab and an upload attachment tab. Just click the upload attachment tab and then browse to the file you want to upload. Once selected, just click the add the file button and your file will be uploaded to the forum, you can even give it a comment if you want to.
 

User avatar
fireuser
Member
 
Posts: 21
Joined: Wed Jul 02, 2014 21:05

Re: Post your modding questions here

by fireuser » Thu Aug 21, 2014 18:55

I love with the idea of mobs, so I am trying to make some. I made models in blender, but I don't know how to use them in to the mod. I think you should use .x files ,but blender would not let me export the models as .x files.
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

Re: Post your modding questions here

by Evergreen » Thu Aug 21, 2014 19:03

fireuser wrote:I love with the idea of mobs, so I am trying to make some. I made models in blender, but I don't know how to use them in to the mod. I think you should use .x files ,but blender would not let me export the models as .x files.

Export them as .b3d instead. I made a tutorial here: viewtopic.php?p=151207#p151207
 

drkwv
Member
 
Posts: 67
Joined: Thu Jun 28, 2012 13:48

Re: Post your modding questions here

by drkwv » Fri Aug 22, 2014 17:56

I tried to create a first-person-shooter weapon mod https://github.com/yetanotherusernamebe ... omsdayarms using a code of cannons mod, but ran into an issue with the entities: I can shoot through walls when facing it close enough. The reason for this is the initial velocity: bullet spawns inside of a wall, gets velocity and thus not collide with it. When I set velocity to 0, bullet collides successfully. Is there an easy way to workaround this problem? Or maybe I should not use entities for bullets at all?
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

Re: Post your modding questions here

by Evergreen » Fri Aug 22, 2014 18:29

drkwv wrote:I tried to create a first-person-shooter weapon mod https://github.com/yetanotherusernamebe ... omsdayarms using a code of cannons mod, but ran into an issue with the entities: I can shoot through walls when facing it close enough. The reason for this is the initial velocity: bullet spawns inside of a wall, gets velocity and thus not collide with it. When I set velocity to 0, bullet collides successfully. Is there an easy way to workaround this problem? Or maybe I should not use entities for bullets at all?

If you want the bullets to be visual, nothing else would really work (even entities are a bit iffy for something moving that fast). Most gun mods I have seen don't use visuals for the bullet, and just use math for figuring that out.
 

drkwv
Member
 
Posts: 67
Joined: Thu Jun 28, 2012 13:48

Re: Post your modding questions here

by drkwv » Fri Aug 22, 2014 18:55

Evergreen wrote:Most gun mods I have seen don't use visuals for the bullet, and just use math for figuring that out.

Honestly, I'd like to have some visuals. Like the old Ace of Spades had.
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Fri Aug 22, 2014 19:24

Quick one, is it safe to use alpha channel for HUD images?
(by that I am referring to partial transparency)
 

User avatar
HeroOfTheWinds
Member
 
Posts: 470
Joined: Wed Apr 23, 2014 23:16
GitHub: HeroOfTheWinds
IRC: WindHero

Re: Post your modding questions here

by HeroOfTheWinds » Sat Aug 23, 2014 04:28

stu wrote:Quick one, is it safe to use alpha channel for HUD images?
(by that I am referring to partial transparency)

Yup! :) Just take a look at Big Freaking Dig, the tool hotbar uses a semi-transparent overlay for the selected tool, if I remember correctly.
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron