Post your modding questions here

Lejo
Member
 
Posts: 92
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Sun Jan 15, 2017 12:13

Topic: How to fix #1 bad argument to get_player_by_name (string expected, got userdata)
Reason: I want to make a mod.
More Info: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
minetest.register_tool("blood:victimknife", {
   description = "Victimknife",
   inventory_image = "Victimknife.png",
   on_use = function(player)
         local pname = minetest.get_player_by_name(player)
         pname:set_hp(pname:get_hp()-2)
   end,
})
Enjoy my Minigameserver Subgames for all!
https://forum.minetest.net/viewtopic.php?f=10&t=14480
 

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

Re: Post your modding questions here

by Byakuren » Sun Jan 15, 2017 12:53

Lejo wrote:Topic: How to fix #1 bad argument to get_player_by_name (string expected, got userdata)
Reason: I want to make a mod.
More Info: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
minetest.register_tool("blood:victimknife", {
   description = "Victimknife",
   inventory_image = "Victimknife.png",
   on_use = function(player)
         local pname = minetest.get_player_by_name(player)
         pname:set_hp(pname:get_hp()-2)
   end,
})


get_player_by_name takes a string and returns an ObjectRef to the player with that name (or nil if there is no player online with that name). In the on_use callback, player is already an ObjectRef so there is no need to call get_player_by_name on it.

If you would like the player's name, do player:get_player_name() (but it looks like you want the ObjectRef, not the name).
Every time a mod API is left undocumented, a koala dies.
 

Lejo
Member
 
Posts: 92
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Sun Jan 15, 2017 14:00

Byakuren wrote:
Lejo wrote:Topic: How to fix #1 bad argument to get_player_by_name (string expected, got userdata)
Reason: I want to make a mod.
More Info: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
minetest.register_tool("blood:victimknife", {
   description = "Victimknife",
   inventory_image = "Victimknife.png",
   on_use = function(player)
         local pname = minetest.get_player_by_name(player)
         pname:set_hp(pname:get_hp()-2)
   end,
})


get_player_by_name takes a string and returns an ObjectRef to the player with that name (or nil if there is no player online with that name). In the on_use callback, player is already an ObjectRef so there is no need to call get_player_by_name on it.

If you would like the player's name, do player:get_player_name() (but it looks like you want the ObjectRef, not the name).

Ok,
now it looks so:
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_tool("blood:victimknife", {
   description = "Victimknife",
   inventory_image = "Victimknife.png",
   on_use = function(player)
         player:set_hp(player:get_hp()-2)
   end,
})

And I get the Error: attempt to call method 'get_hp' (a nil value)
Enjoy my Minigameserver Subgames for all!
https://forum.minetest.net/viewtopic.php?f=10&t=14480
 

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

Re: Post your modding questions here

by D00Med » Sun Jan 15, 2017 20:19

maybe try using:
local hp = player:get_hp()
player:set_hp(hp-2)
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

mr_dean
Member
 
Posts: 24
Joined: Fri Jan 06, 2017 00:38
In-game: mr_dean

Re: Post your modding questions here

by mr_dean » Sun Jan 15, 2017 21:25

Topic: Game crashing when I run a mod.
Reason: I am trying to modify a mod I made, but now it crashes w/out a error.
Info: So, I made a mod, (random_foods, look it up, WIP mods) I decided to edit it and add some stuff, but now it will not load. the game just stops working, and there's no error message, just a windows message saying that the application has stopped working, and to close it. Here is the 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
 minetest.register_craftitem("custom_food:mudsoup", {
   description = "Mud Soup",
   inventory_image = "food_mudsoup_bowl.png",
   on_use = minetest.item_eat(2)
})

minetest.register_craftitem("custom_food:woodbowl", {
   description = "Wood Bowl",
   inventory_image = "food_woodbowl.png"
})

minetest.register_craftitem("custom_food:cake", {
   description = "Cake",
   inventory_image = "food_cake.png",
   on_use = minetest.item_eat(4)
})

minetest.register_craftitem("custom_food:cooked_mushroom", {
   description = "Cooked Mushroom",
   inventory_image = "cooked_mushroom.png",
    on_use = minetest.item_eat(3)
})

--The added item

minetest.register_craftitem("custom_food:mushroom_stew", {
    discription = "Mushroom Stew",
   inventory_image = "mushroom_stew.png",
   on_use = minetest.item_eat(5)
})

minetest.register_craftitem("custom_food:sugar", {
   description = "Sugar",
   inventory_image = "items_sugar.png",
   on_use = minetest.item_eat(0.5)
})

minetest.register_node("custom_food:sugarweed", {
   description = "Sugar Weed",
   tiles = {"sugarweed.png"},
   groups = {choppy=1, oddly_breakable_by_hand=1,  plantlike=1, flamable=5,
   flora=1},
   drawtype = "plantlike",
   walkable = false,
   buildable_to = true,
   sunlight_propagates = true,
   paramtype = "light",
})

minetest.register_abm({
   nodenames = {"default:dirt_with_grass"},
   neighbors = {"default:water_source", "default:water_flowing"},
   interval = 10.0, -- Run every 10 seconds
   chance = 1000, -- Select every 1 in 1000 nodes
   action = function(pos, node, active_object_count, active_object_count_wider)
      minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "custom_food:sugarweed"})
   end
})

--===================CRAFTING==================--
minetest.register_craft({
   output = "custom_food:woodbowl",
   recipe = {
      {"group:wood", "", "group:wood"},
      {"", "group:wood", ""},
      {"", "", ""}
   }
})
--mud soup:

minetest.register_craft({
   output = "custom_food:mudsoup",
   recipe = {
      {"default:leaves", "default:dirt", "flowers:mushroom_brown"},
      {"", "custom_food:woodbowl", ""},
      {"", "", ""}
   }
})
-- cooked mushroom (red mushrooms only! removes poison efect.)
minetest.register_craft ({
    type = "cooking",
   cooktime = 15,
    output = "custom_food:cooked_mushroom",
   recipe = "flowers:mushroom_red",
})
-- Cakes!
minetest.register_craft({
   output = "custom_food:cake",
   recipe = {
      {"custom_food:cooked_mushroom", "custom_food:sugar", "flowers:mushroom_brown"},
      {"", "farming:bread", ""},
      {"", "", ""}
   }
})
-- Sugar. (replaces my original idea of papyrus in the cake recepie.)
minetest.register_craft ({
    type = "cooking",
   cooktime = 25,
    output = "custom_food:sugar",
   recipe = "custom_food:sugarweed",
})

--The crafting reci for it.

-- Mushroom Stew, still working on bugs.
minetest.register_craft ({
    output = "custom_food:mushroom_stew",
    recepie = {
        {"custom_food:cooked_mushroom", "farming:wheat", "flowers:mushroom_brown"},
      {"", "custom_food:woodbowl", ""},
      {"", "", ""},
   }
})
I know you believe you understand what you think I said, but, I am not sure that what you heard is not what I meant. - Author Unknown
 

Nyarg
Member
 
Posts: 144
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Sun Jan 15, 2017 22:30

mr_dean wrote:Topic: Game crashing

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
 
...
    discription = "Mushroom Stew",
...
    recepie = {
...
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

mr_dean
Member
 
Posts: 24
Joined: Fri Jan 06, 2017 00:38
In-game: mr_dean

Re: Post your modding questions here

by mr_dean » Mon Jan 16, 2017 00:44

Nyarg wrote:
mr_dean wrote:Topic: Game crashing

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
 
...
    discription = "Mushroom Stew",
...
    recepie = {
...


Are you saying that this is where my errors are, or just check those?
I know you believe you understand what you think I said, but, I am not sure that what you heard is not what I meant. - Author Unknown
 

Nyarg
Member
 
Posts: 144
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Mon Jan 16, 2017 01:04

mr_dean wrote:Are you saying that this is where my errors are, or just check those?

First I am checking and found "discription " then I copy code in to MT correct one and anyway get fail without any errors.
Then I take Occam's razor and cut code half by half and finally found block with "recepie". then fix it and obtain profit )
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

mr_dean
Member
 
Posts: 24
Joined: Fri Jan 06, 2017 00:38
In-game: mr_dean

Re: Post your modding questions here

by mr_dean » Mon Jan 16, 2017 14:21

Oh, ok I see now, sorry, I just wasn't getting what you were saying, thx!
I know you believe you understand what you think I said, but, I am not sure that what you heard is not what I meant. - Author Unknown
 

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 » Mon Jan 16, 2017 15:44

(It's called recipe and description.)
As much as I know it isn't possible to give 1/4 hearts like you did with sugar.
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
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Mon Jan 16, 2017 17:13

Is there a way to check if a specific coordinate is curled with a collisionbox?

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
pos1 = {x=0, y=0.0, z=0}
pos2 = {x=0, y=0.1, z=0}
pos3 = {x=0, y=0.2, z=0}
pos4 = {x=0, y=0.3, z=0}
pos5 = {x=0, y=0.4, z=0}


Is it possible to know which of these coordinates collide with the collisionbox at (0, 0, 0)?
 

Lejo
Member
 
Posts: 92
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Mon Jan 16, 2017 18:33

D00Med wrote:maybe try using:
local hp = player:get_hp()
player:set_hp(hp-2)


I still get the same Error :(
Enjoy my Minigameserver Subgames for all!
https://forum.minetest.net/viewtopic.php?f=10&t=14480
 

Nyarg
Member
 
Posts: 144
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Mon Jan 16, 2017 19:09

Lejo wrote:I still get the same Error :(

Quick search gives different for on_use = ...
+ Spoiler
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

BirgitLachner
Member
 
Posts: 135
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Tue Jan 17, 2017 07:46

I want to start a Mod called "TeacherTools" that should make it easy for Teachers to handle a group of pupils on a server with some clicks and without the need to enter code.

For that I want to know:
- How can I get a list of all the users that are online?
- An other possibility ... can I read from inside the game the player that have been signed in once and "see" their privs to filter them?
... If you know a mod tnat already does something like that would be nice.

- How do I execute a text commond with a button?

At first I'm sure that I will not be able to have a list of players and for everyone buttons to ban, freeze or whatever I want to do with him. First idea is to have a textfield to enter a name and the buttons behind the textfield to do everything with him.

Thanks for all hints and informations about already existing Mods.
 

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 » Tue Jan 17, 2017 14:32

@Lejo:
Jep, the player should be the user in "on_use = func(itemstack, user, pointed_thing)". => It has to be written on 2nd place:
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_tool("blood:victimknife", {
       description = "Victimknife",
       inventory_image = "Victimknife.png",
       on_use = function(itemstack,player)
             local hp = player:get_hp()
             player:set_hp(hp-2)
       end,
    })
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
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Tue Jan 17, 2017 17:39

How can I add particles to a node on punching?
where do I start?

ex: I want to add smoke/dust-like particles to stone_with_coal while being mined... (well, that just gave away the whole surprise :P )

and, do the particles only have a certain behavior (like flowing up) or are they fairly code-able to float down as well and maybe set up a next function which calls in a texture/item which would be a small pile of coal dust? which can then be picked up and used in a recipe
Flick?... Flick who?
 

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

Re: Post your modding questions here

by D00Med » Tue Jan 17, 2017 20:06

Use on_destruct or on_dig, and use this for the particles:

minetest.add_particlespawner({
amount = 1,
time = 1,
minpos = {x=0, y=0, z=0},
maxpos = {x=0, y=0, z=0},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=0, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = false,
vertical = false,
texture = "image.png",
playername = "singleplayer" -- probably best to get rid of this
})
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by TumeniNodes » Tue Jan 17, 2017 20:34

D00Med wrote:Use on_destruct or on_dig, and use this for the particles:

minetest.add_particlespawner({
amount = 1,
time = 1,
minpos = {x=0, y=0, z=0},
maxpos = {x=0, y=0, z=0},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=0, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = false,
vertical = false,
texture = "image.png",
playername = "singleplayer" -- probably best to get rid of this
})


awesome... I'll give it a try. Thanks!
Flick?... Flick who?
 

Lejo
Member
 
Posts: 92
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Wed Jan 18, 2017 12:02

@DS-minetest Thanks now it works.
Enjoy my Minigameserver Subgames for all!
https://forum.minetest.net/viewtopic.php?f=10&t=14480
 

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 Jan 18, 2017 14:51

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_particlespawner({
   amount = 1,
   time = 1,
   minpos = {x=0, y=0, z=0},
   maxpos = {x=0, y=0, z=0},
   minvel = {x=0, y=0, z=0},
   maxvel = {x=0, y=0, z=0},
   minacc = {x=0, y=0, z=0},
   maxacc = {x=0, y=0, z=0},
   minexptime = 1,
   maxexptime = 1,
   minsize = 1,
   maxsize = 1,
   collisiondetection = false,
   vertical = false,
   texture = "image.png",
})

remember to change the min/max values
each particle spawned will get a random pos/vel/acc from that range
with the setup as above every particle starts at 0,0,0, does not move, has a size of 1 and exists for exactly 1s.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
GreenDimond
Member
 
Posts: 460
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Post your modding questions here

by GreenDimond » Wed Jan 18, 2017 21:13

Technic question (which it seem no one wants to answer on the Technic thread):
I need to replace a grinder recipe
I am Green. I tend to binge-post. "All of this over a 16x16 representation of a cartoon cat ?!?! what has this world come to..." -TenPlus1, 2017.
Diz mah mods! :D ↑ github.com/minetest/minetest_game/issues/1647#issuecomment-288134572 ↑
Sand Plus - Tac Nayn - Waffles - Coming Soon: Caverealms Plus
 

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

Re: Post your modding questions here

by TumeniNodes » Thu Jan 19, 2017 03:45

orwell wrote:
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_particlespawner({
   amount = 1,
   time = 1,
   minpos = {x=0, y=0, z=0},
   maxpos = {x=0, y=0, z=0},
   minvel = {x=0, y=0, z=0},
   maxvel = {x=0, y=0, z=0},
   minacc = {x=0, y=0, z=0},
   maxacc = {x=0, y=0, z=0},
   minexptime = 1,
   maxexptime = 1,
   minsize = 1,
   maxsize = 1,
   collisiondetection = false,
   vertical = false,
   texture = "image.png",
})

remember to change the min/max values
each particle spawned will get a random pos/vel/acc from that range
with the setup as above every particle starts at 0,0,0, does not move, has a size of 1 and exists for exactly 1s.


Thanks orwell.
Yeh, I'm still stuttering with how to use this, I've made several changes..., switched from destruct to dig, etc... and have yet to see a particle.
I'll try to figure it out some more, before I fold and ask here again...

Sometimes I'll be working on some code and end up making changes in another copy, rather than the one I am currently using and go bezerk till I finally realize...... "Ohhhhhhh...... yeh...." "/ :D
Flick?... Flick who?
 

hajo
Member
 
Posts: 262
Joined: Thu Oct 13, 2016 10:45

Re: Post your modding questions here

by hajo » Thu Jan 19, 2017 08:52

BirgitLachner wrote:I want to start a Mod called "TeacherTools" .. to handle a group of pupils on a server with some clicks ..
- How can I get a list of all the users that are online?

/status ?
- How do I execute a text commond with a button?
Thanks for all hints and informations about already existing Mods.

Have a look at
* morecommands (e.g. /getpos and /sudo)
* sfinv - "Simple Fast Inventory"
* sfinv_buttons - "Simple Fast Inventory Buttons"
* Sfinv Unified Inventory - "Adds unified inventory features to sfinv" as how-to
Also:
* admintoys - /freeze
Some of 'my' wiki-pages: Build-a-home - basic-robot - basic-machines - digtron
 

Muuus
New member
 
Posts: 2
Joined: Thu Jan 19, 2017 18:37
In-game: Muuus

Re: Post your modding questions here

by Muuus » Thu Jan 19, 2017 18:45

Hi there,

I'm new to Minetest and the world of modding, trying to get a grasp over things like formspec, I started creating a mod with a mixer utilitary block, adding new kind of recipes, based on the furnace. I'm basing that on the furnace, so I want a similar GUI, but with a water drop in place of the fire and two slots for src instead of only one. Also, I want to use 'liquid' instead of 'fuel', like putting a water bucket inside the mixer in the 'liquid (ex-'fuel') slot, and then transforming sand and gravel in the src slots into a new block like concrete.

What I'm asking myself, is if it's possible to do that without touching the .cpp files, but only as LUA mod ? I mean, I saw that some of the variable like fuel_totaltime or fuel_time are also used in some .cpp file, so I was wondering if I could do something similar to the furnace_node_timer function for my mixer, without touching the Minetest engine and the .cpp/.h files ?

Sorry if I couldn't make myself clear enough, hope you can help me on that one.
 

hajo
Member
 
Posts: 262
Joined: Thu Oct 13, 2016 10:45

Re: Post your modding questions here

by hajo » Thu Jan 19, 2017 20:43

Muuus wrote:I started creating a mod with a mixer utilitary block,
adding new kind of recipes, based on the furnace. ..
but with a water drop in place of the fire and two slots for src instead of only one. ..
do that .. only as LUA mod ?

Have a look at the mod basic_machines, there is a constructor
that builds all the other machines of that mod.

Also, craftingtable...
Some of 'my' wiki-pages: Build-a-home - basic-robot - basic-machines - digtron
 

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 Jan 19, 2017 21:13

Muuus wrote:Hi there,

I'm new to Minetest and the world of modding, trying to get a grasp over things like formspec, I started creating a mod with a mixer utilitary block, adding new kind of recipes, based on the furnace. I'm basing that on the furnace, so I want a similar GUI, but with a water drop in place of the fire and two slots for src instead of only one. Also, I want to use 'liquid' instead of 'fuel', like putting a water bucket inside the mixer in the 'liquid (ex-'fuel') slot, and then transforming sand and gravel in the src slots into a new block like concrete.

What I'm asking myself, is if it's possible to do that without touching the .cpp files, but only as LUA mod ? I mean, I saw that some of the variable like fuel_totaltime or fuel_time are also used in some .cpp file, so I was wondering if I could do something similar to the furnace_node_timer function for my mixer, without touching the Minetest engine and the .cpp/.h files ?

Sorry if I couldn't make myself clear enough, hope you can help me on that one.

Have a look at /games/minetest_game/default/furnace.lua and try to figure out how it works there, then do your modifications.
I'll explain the concepts of formspecs to you:
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
"size[8,8.5]"..
   "list[current_name;src;2.75,0.5;1,1;]"..
   "list[current_name;fuel;2.75,2.5;1,1;]"..
   "image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
   "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
   "list[current_name;dst;4.75,0.96;2,2;]"..
   "list[current_player;main;0,4.25;8,1;]"..
   "list[current_player;main;0,5.5;8,3;8]"..
   "listring[current_name;dst]"..
   "listring[current_player;main]"..
   "listring[current_name;src]"..
   "listring[current_player;main]"

This is a typical formspec definition. It's just one long string, the quotes and concat dots (..) are just for better readability, because you can't insert newlines in lua strings*. It defines the entire GUI for an inactive furnace. For example, image[...] draws an image at this screen position and list[...] shows an inventory list (or a single slot).
See the lua_api.txt section "Formspecs" for details on what works how.
'doc/lua_api.txt' will help you in a lot of places.

Furnace 'on_construct' 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
on_construct = function(pos)
--get the metadata of the node (a key-value-store and an inventory)
      local meta = minetest.get_meta(pos)
      meta:set_string("formspec", inactive_formspec)
--you can put any data into the metadata, like percentage of items processed. See "NodeMetaRef"
--but the key 'formspec' is reserved for the formspec to be show when the node is right-clicked.
      local inv = meta:get_inventory()
--get the node's inventory and set the sizes of the inventory list. See lua_api.txt section "InvRef"
      inv:set_size('src', 1)
      inv:set_size('fuel', 1)
      inv:set_size('dst', 4)
   end,

On fuel stuff in cpp files: irrelevant. Possibly for compatibility with very old minetest worlds...

* you can by using [[this string
has newlines
in it.]], but this does not look pretty.
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 » Thu Jan 19, 2017 21:26

On "fuel" in cpp files:
- "fuel_totaltime" is contained in a function called
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
static bool content_nodemeta_deserialize_legacy_body(..)

and its only job is to transfer the old meta serialization format into the key-value-store that can be and is accessed from LUA.
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->setString("fuel_totaltime", ftos((float)temp/10));

-----
It appears in some places around the "register_craft" API function. The crafting definitions are saved in the engine, also the ones for the furnace. But you just have to save your crafting definitions inside a lua table.
The minetest_game furnace reads the recipe at line 121 of furnace.lua:
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 cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
   

It handles the rest on the lua side.
So don't worry, everything is achievable without even looking at the cpp code.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

hajo
Member
 
Posts: 262
Joined: Thu Oct 13, 2016 10:45

Re: Post your modding questions here / run mod in multiplaye

by hajo » Sat Jan 21, 2017 16:04

I have a small mod that shows the ingame-time in the HUD.
This works fine in singleplayer, but not when playing on a server.

The mod doesn't affect the world on the server, or items, or anything,
so it should be no problem if I run this mod with multiplayer too.

How can I set this mod to load&run every time I enter a game ?
Some of 'my' wiki-pages: Build-a-home - basic-robot - basic-machines - digtron
 

player_legend
New member
 
Posts: 1
Joined: Sun Jan 22, 2017 00:48
IRC: volk
In-game: player_legend

Re: Post your modding questions here

by player_legend » Sun Jan 22, 2017 01:07

Is there a best way to control the player's physics in a function? I have an idea to implement Quake like strafe jumping and that requires direct control of the player's movement. I'm just introducing myself to this engine, but from what I've read so far, it seems I could regularly poll the player's inputs and do what modifications to their velocity I need to using my own function. Would this work well or would it cause problems with prediction in the netcode or something.
 

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

Re: Post your modding questions here

by Byakuren » Sun Jan 22, 2017 21:19

player_legend wrote:Is there a best way to control the player's physics in a function? I have an idea to implement Quake like strafe jumping and that requires direct control of the player's movement. I'm just introducing myself to this engine, but from what I've read so far, it seems I could regularly poll the player's inputs and do what modifications to their velocity I need to using my own function. Would this work well or would it cause problems with prediction in the netcode or something.


You can't modify a player's velocity, and it would work terribly anyway because there would be no prediction and velocity changes would have the lag of a roundtrip (actually longer because controls are only sent periodically, not on every change).

This might be something doable when client-side scripting comes, because then it will be possible to make an API where you can get the current controls and set velocity with no lag.
Every time a mod API is left undocumented, a koala dies.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 6 guests

cron