Post your modding questions here

User avatar
rubenwardy
Moderator
Posts: 6291
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

ZenonSeth wrote:
Krock wrote: You can do more than just show the formspec in on_rightclick. [snipped]
Ah ok, I see. I wasn't sure about using a mod-global list of names cause I wasn't sure of the access order - e.g. if I store the pos in a table, my form shows, but then another of my form's right click is process before mine, using up the pos. I think just being new to the minetest modding api, and having bad experiences with global tables like that before, made me cautious.

The approach I 'solved' it with is essentially the same, only i stored the pos in the formspec itself, using:

Code: Select all

"field[-1,-1;0,0;"..fieldNodePos..";;" .. spos .. "]"..
where spos is a comma-separated coord list. Though even if 'hidden' the field can still be edited. A solution that just occured to me is to store the pos in the field name, as in have the name be some known prefix, say fieldNodePos, concatinated with the comma-separated coords. Would probably work, just have to iterate over all fields on the formspec callback.

But I mean, if the minetest_game uses the global lookup table to store right clicked position, I should too. Thanks
That's hacky and a bad idea. I suggest reading about contexts

Remember that a malicious client can modify anything that you send to it, so don't give it the ability to choose a position unless you check that the position is in range in the callback, and always check for permissions in the callback too.

ZenonSeth
Member
Posts: 15
Joined: Mon Sep 18, 2017 19:23

Re: Post your modding questions here

by ZenonSeth » Post

rubenwardy wrote: That's hacky and a bad idea. I suggest reading about contexts

Remember that a malicious client can modify anything that you send to it, so don't give it the ability to choose a position unless you check that the position is in range in the callback, and always check for permissions in the callback too.
Cool, thanks for the link, I've already been reading that site, but I hadn't seen that section.

Yeah, I understand that sending that data over to client can be very problematic. I had already added protection to prevent mis-use, in the form of checking a unique meta data string that only my node has. So at worse it would've just failed to do anything. But either way - I've switched to using the context way, having a global key/value of playerName/Position, and it works fine :)

User avatar
rubenwardy
Moderator
Posts: 6291
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

Note that meta data is also usually sent to the client, so make sure you mark any such secret fields as private: https://rubenwardy.com/minetest_modding ... name1name2

ZenonSeth
Member
Posts: 15
Joined: Mon Sep 18, 2017 19:23

Re: Post your modding questions here

by ZenonSeth » Post

rubenwardy wrote:Note that meta data is also usually sent to the client, so make sure you mark any such secret fields as private: https://rubenwardy.com/minetest_modding ... name1name2
Hah, I *just* realised that you're the author of that site. Thanks - didn't know about private meta-data either, I'll have to play around with it.

In the meanwhile I have another issue. I'm trying to give the player items when he right-clicks on a node (they're copied, not moved from the node's internal intentory).

So I realized that on_rightclick can return an ItemStack that is the modified wielded stack. And that meant that if it got added to during the function, and I wasn't returning anything, it seemed to overwrite the stack. My code in the on_rightclick function looks like this: (or you can see my full code with context here: https://github.com/ZenonSeth/treasure_c ... t.lua#L138)

Code: Select all

-- itemStackToAdd is an ItemStack -  obtained from Node inventory (I'm not removing it from there)
itemStackToAdd = playerInv:add_item("main", itemStackToAdd);

if not itemStackToAdd:is_empty() then
    minetest.item_drop(itemStackToAdd, player, player:get_pos());
end

return playerInv:get_stack(player:get_wield_list(), player:get_wield_index());
I have some weird behavior here. All item stacks I tried this with, it works - even if you're wielding them, the stack gets incremented. But with Trees (any tree log item)... it doesn't. Meaning, if the stack of tree items is wielded, and I add to it via the code above, after it's done executing, the stack remains unchanged. Not sure why..

Byakuren
Member
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Post

BirgitLachner wrote:
Byakuren wrote: Currently nodes aren't flexible enough for what you want. You either need to register a node for every combination, or use entities to display the pictures.
Okay, no problem ... if you mean that for every kind of size 1x1, 1x2, 2x1, 2x2 and so on ... we need a special node, that's okay.

The questions are:
1.) How can we make it flexible, to have a given frame and then a choosen picture.
2.) Is it possible to replace the starting-node, where you can choose the size and picture, the the wanted size node and the wanted picture.

Birgit
I mean every combination of picture + size + frame texture.
Every time a mod API is left undocumented, a koala dies.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: Post your modding questions here

by hajo » Post

BirgitLachner wrote:make a mod to show pictures on the wall. ..
mod "gemalde" viewtopic.php?id=4635
On the server linuxworks, they have a big map
of the train-network that stretches over several nodes.

But I guess that is simply done using several textures.

So, if that is usable for your purpose depends on how many different pictures
you want to show, and how often they change.

User avatar
Devy
Member
Posts: 132
Joined: Sat Jan 21, 2017 02:31
GitHub: CoderForTheBetter
In-game: devy

Re: Post your modding questions here

by Devy » Post

BirgitLachner wrote:
Byakuren wrote: Currently nodes aren't flexible enough for what you want. You either need to register a node for every combination, or use entities to display the pictures.
Okay, no problem ... if you mean that for every kind of size 1x1, 1x2, 2x1, 2x2 and so on ... we need a special node, that's okay.

The questions are:
1.) How can we make it flexible, to have a given frame and then a choosen picture.
2.) Is it possible to replace the starting-node, where you can choose the size and picture, the the wanted size node and the wanted picture.

Birgit
1. You could make the frame and the pictures entities and have items for placing the entities. So, when you right click with the item, you can check if the thing you are clicking on is a frame, and if it is a frame then you can make the picture a child of the picture frame.

2. I'm not sure what you are asking here.

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

Re: Post your modding questions here

by BirgitLachner » Post

Byakuren wrote:
BirgitLachner wrote:
Byakuren wrote: Currently nodes aren't flexible enough for what you want. You either need to register a node for every combination, or use entities to display the pictures.
Okay, no problem ... if you mean that for every kind of size 1x1, 1x2, 2x1, 2x2 and so on ... we need a special node, that's okay.

The questions are:
1.) How can we make it flexible, to have a given frame and then a choosen picture.
2.) Is it possible to replace the starting-node, where you can choose the size and picture, the the wanted size node and the wanted picture.

Birgit
I mean every combination of picture + size + frame texture.
Hmmm, easy but not comfortable. Okay.

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

Re: Post your modding questions here

by BirgitLachner » Post

hajo wrote:
BirgitLachner wrote:make a mod to show pictures on the wall. ..
mod "gemalde" viewtopic.php?id=4635
On the server linuxworks, they have a big map
of the train-network that stretches over several nodes.

But I guess that is simply done using several textures.

So, if that is usable for your purpose depends on how many different pictures
you want to show, and how often they change.
Thanks for this hint. I'll serach for the mod that does it. I think that I have already heard about it.

Birgit

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: Post your modding questions here

by Stix » Post

Question: why is there a player.png in the default textures folder? why is it there if Minetest_Game now uses 3d characters, instead of 2d ones? is there a way to enable its use in Minetest_Game?
Hey, what can i say? I'm the bad guy.

User avatar
Krock
Developer
Posts: 4572
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

Stix wrote:is there a way to enable its use in Minetest_Game?
It's still used as a fallback texture when the defined model failed to load. Some skin mods also make use of this behaviour to let players use (ancient) 2D player textures.
Trigger for the 2D-mode with custom textures:

Code: Select all

-- New, in-development minetest_game version
player_api.set_model(player)
player_api.set_textures(player, {"player.png", "player_back.png"})
-- 0.4.16 compatibility
default.player_set_model(player)
player:set_properties({
	textures = {"player.png", "player_back.png"}
})
EDIT: Forgot "player" param for set_textures.
Last edited by Krock on Wed Sep 27, 2017 08:13, edited 1 time in total.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: Post your modding questions here

by Stix » Post

Krock wrote:
Stix wrote:is there a way to enable its use in Minetest_Game?
It's still used as a fallback texture when the defined model failed to load. Some skin mods also make use of this behaviour to let players use (ancient) 2D player textures.
Trigger for the 2D-mode with custom textures:

Code: Select all

-- New, in-development minetest_game version
player_api.set_model(player)
player_api.set_textures({"player.png", "player_back.png"})
-- 0.4.16 compatibility
default.player_set_model(player)
player:set_properties({
	textures = {"player.png", "player_back.png"}
})
where do i put this code?
Hey, what can i say? I'm the bad guy.

User avatar
Krock
Developer
Posts: 4572
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

Stix wrote:where do i put this code?
Meh, just download the mod below to get the 2D player back. I couldn't figure out how to correct the Y position of the sprite for the in-development versions. However, it should display fine with the 0.4.16 stable.
Attachments
2d_player.zip
License: CC0
(571 Bytes) Downloaded 21 times
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: Post your modding questions here

by Stix » Post

Krock wrote:
Stix wrote:where do i put this code?
Meh, just download the mod below to get the 2D player back. I couldn't figure out how to correct the Y position of the sprite for the in-development versions. However, it should display fine with the 0.4.16 stable.
thx!
Hey, what can i say? I'm the bad guy.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: Post your modding questions here

by Stix » Post

i tried it and the 2d_avatar looked a little squashed.....
Hey, what can i say? I'm the bad guy.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: Post your modding questions here

by Stix » Post

im trying to get it where i use an abm and if a certain neighbore node is near the node that runs the abm will be replaced by a different node, how do i do this???
Hey, what can i say? I'm the bad guy.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: Post your modding questions here

by hajo » Post

Stix wrote:abm .. node replace by a different node
you mean like dirt --> dirt-with-grass ?

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: Post your modding questions here

by Stix » Post

hajo wrote:
Stix wrote:abm .. node replace by a different node
you mean like dirt --> dirt-with-grass ?
yes.
Hey, what can i say? I'm the bad guy.

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

Re: Post your modding questions here

by BirgitLachner » Post

Devy wrote:
BirgitLachner wrote:
Byakuren wrote: Currently nodes aren't flexible enough for what you want. You either need to register a node for every combination, or use entities to display the pictures.
Okay, no problem ... if you mean that for every kind of size 1x1, 1x2, 2x1, 2x2 and so on ... we need a special node, that's okay.

The questions are:
1.) How can we make it flexible, to have a given frame and then a choosen picture.
2.) Is it possible to replace the starting-node, where you can choose the size and picture, the the wanted size node and the wanted picture.

Birgit
1. You could make the frame and the pictures entities and have items for placing the entities. So, when you right click with the item, you can check if the thing you are clicking on is a frame, and if it is a frame then you can make the picture a child of the picture frame.

2. I'm not sure what you are asking here.
Okay, I did not use entities before. But I'll have a look at it. Thanks.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: Post your modding questions here

by hajo » Post

Stix wrote:abm ... dirt --> dirt-with-grass
Have a look at the intro to the developer-wiki.

User avatar
rubenwardy
Moderator
Posts: 6291
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

hajo wrote:
Stix wrote:abm ... dirt --> dirt-with-grass
Have a look at the intro to the developer-wiki.
I'd also recommend my ABM chapter over that (I wrote most of the tutorial the intro is based on, btw). You'll need to remove the +1 to the y axis, as it currently places the node above the ABM node

User avatar
Lone_Wolf
Member
Posts: 2412
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: Lone_Wolf or LoneWolfHT
In-game: Lone_Wolf
Location: Not there, THERE!

Re: Post your modding questions here

by Lone_Wolf » Post

Is there a way to check for another mod and if the mod is found: Register a node/item/recipe?

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

Re: Post your modding questions here

by Lejo » Post

You can use:

Code: Select all

if minetest.global_exists("sfinv") then  --sfinv is the modname
 --your code
end

User avatar
v-rob
Developer
Posts: 792
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: Post your modding questions here

by v-rob » Post

EDIT: Never mind, I figured it out
GUI Core Developer | My Best Mods: Bridger - Slats - Stained Glass | To contact me, send a PM

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: Post your modding questions here

by John_Constructor » Post

Topic: Moreblocks conflicts with my Construction mod, how can I fix this?

Reason: I want Construction to be fully compatible with Moreblocks.

Extra Information: My code is legitimately correct, but it throws up an error message when I run Construction and Moreblocks in combination while "construction_compatibility_issue" is active.

Code: Select all

-- Compatibility Issue Solver
if minetest.settings:get_bool("construction_compatibility_issue") then

	minetest.clear_craft({
		output = ("moreblocks:wood_tile"),
	})
	
minetest.register_craft({
	output = "moreblocks:wood_tile 4",
	recipe = {
		{'', '', ''},
		{'', 'default:wood', 'default:junglewood'},
		{'', 'default:junglewood', 'default:wood'},
	}
})

end
Image

I am running Minetest 0.4.16.
Attachments
Incompatibility.PNG
Incompatibility issue solver.
(16.52 KiB) Not downloaded yet
Constructing mechs and wingless aircraft since 2016.

Locked

Who is online

Users browsing this forum: No registered users and 1 guest