Page 74 of 121

Re: [Game] MineClone 2 [0.65.2]

Posted: Mon May 11, 2020 18:37
by LMD
Nebbie: Lua's boolean operators (and, or etc) all take advantage of lazy evaluation.
This means that there is absolutely no difference between:

Code: Select all

if a_complex_check() then
    if another_complex_check() then
        do_something()
    end
end
And the better, and shorter:

Code: Select all

if a_complex_check() and another_complex_check() then
    do_something()
end

Re: [Game] MineClone 2 [0.65.2]

Posted: Mon May 11, 2020 19:25
by sorcerykid
When optimizing conditionals, it's a good idea to eliminate the most unlikely candidates early on and proceed down the chain. In other words, you want the first check to be the most likely to fail. That way there are fewer checks performed during each iteration.

For example, if you wanted find all doors with certain metadata between a given range of coordinates it would make the most sense to first check that the node is even a door before checking the metadata or the coordinates, since latter two checks would rarely fail for many nodes.

Re: [Game] MineClone 2 [0.65.2]

Posted: Mon May 11, 2020 19:40
by LMD
Optimization is not an easy matter.

I'd add to sorcerykid's excellent explanation that this has to be weighted by the performance of the checks. Checking the type of node is a rather quick check compared to metadata access.

Re: [Game] MineClone 2 [0.65.2]

Posted: Mon May 11, 2020 21:55
by Wuzzy
LMD nailed it!

Re: [Game] MineClone 2 [0.65.2]

Posted: Tue May 12, 2020 01:18
by leo_rockway
Nebbie wrote:
Sun May 10, 2020 17:23
So what about the liquid stuff? I must reiterate that was the biggest issue.
Old, old bug in the engine.

Re: [Game] MineClone 2 [0.65.2]

Posted: Tue May 12, 2020 02:04
by Nebbie
LMD wrote:
Mon May 11, 2020 18:37
Nebbie: Lua's boolean operators (and, or etc) all take advantage of lazy evaluation.
This means that there is absolutely no difference between:

Code: Select all

if a_complex_check() then
    if another_complex_check() then
        do_something()
    end
end
And the better, and shorter:

Code: Select all

if a_complex_check() and another_complex_check() then
    do_something()
end
This is true for a lone if, but there's an elseif chain going on. Consider the following two bits of code:
Spoiler

Code: Select all

if complex_check_1() and other_complex_check_1() then
	do_something()
elseif  complex_check_2() and other_complex_check_2() then
	do_something_else()
end

Code: Select all

if complex_check_1() then
	if other_complex_check_1() then
		do_something()
	end
elseif  complex_check_2() then
	if other_complex_check_2() then
		do_something_else()
	end
end
In the case where complex_check_1() is true, but other_complex_check_1() and complex_check_2() are false, the first bit of code will do 3 checks, but the second bit of code will do only 2 because complex_check_2() doesn't happen. This is because in the first bit of code, other_complex_check_1() being false means the elseif has to be gone into.
Note the difference in the instructions generated by luac -l -p on the two (line 8 has a different jump that goes to return instead of further checks):
Spoiler

Code: Select all

        1       [1]     GETTABUP        0 0 -1  ; _ENV "complex_check_1"
        2       [1]     CALL            0 1 2
        3       [1]     TEST            0 0
        4       [1]     JMP             0 7     ; to 12
        5       [1]     GETTABUP        0 0 -2  ; _ENV "other_complex_check_1"
        6       [1]     CALL            0 1 2
        7       [1]     TEST            0 0
        8       [1]     JMP             0 3     ; to 12
        9       [2]     GETTABUP        0 0 -3  ; _ENV "do_something"
        10      [2]     CALL            0 1 1
        11      [2]     JMP             0 10    ; to 22
        12      [3]     GETTABUP        0 0 -4  ; _ENV "complex_check_2"
        13      [3]     CALL            0 1 2
        14      [3]     TEST            0 0
        15      [3]     JMP             0 6     ; to 22
        16      [3]     GETTABUP        0 0 -5  ; _ENV "other_complex_check_2"
        17      [3]     CALL            0 1 2
        18      [3]     TEST            0 0
        19      [3]     JMP             0 2     ; to 22
        20      [4]     GETTABUP        0 0 -6  ; _ENV "do_something_else"
        21      [4]     CALL            0 1 1
        22      [5]     RETURN          0 1

Code: Select all

        1       [1]     GETTABUP        0 0 -1  ; _ENV "complex_check_1"
        2       [1]     CALL            0 1 2
        3       [1]     TEST            0 0
        4       [1]     JMP             0 7     ; to 12
        5       [2]     GETTABUP        0 0 -2  ; _ENV "other_complex_check_1"
        6       [2]     CALL            0 1 2
        7       [2]     TEST            0 0
        8       [2]     JMP             0 13    ; to 22
        9       [3]     GETTABUP        0 0 -3  ; _ENV "do_something"
        10      [3]     CALL            0 1 1
        11      [4]     JMP             0 10    ; to 22
        12      [5]     GETTABUP        0 0 -4  ; _ENV "complex_check_2"
        13      [5]     CALL            0 1 2
        14      [5]     TEST            0 0
        15      [5]     JMP             0 6     ; to 22
        16      [6]     GETTABUP        0 0 -5  ; _ENV "other_complex_check_2"
        17      [6]     CALL            0 1 2
        18      [6]     TEST            0 0
        19      [6]     JMP             0 2     ; to 22
        20      [7]     GETTABUP        0 0 -6  ; _ENV "do_something_else"
        21      [7]     CALL            0 1 1
        22      [9]     RETURN          0 1
The existing code makes sense (aside of the other thing with checking whether a mob takes damage from the given type twice) if it is significantly more performant to check a mob's vulnerabilities (which aren't mutually exclusive and thus can't be used as an outer shell of if-elseif chaining) than the node group.

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 15, 2020 09:28
by WarHawk
so are iron golems supposed to take dmg from falling or not?

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 15, 2020 15:27
by leo_rockway
Is riding supposed to be working? I put a saddle on a pig, but couldn't ride it. I can't saddle horses / donkeys; I believe they are supposed to be tamed first, but I couldn't tame them either.

This is in survival mode.

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 15, 2020 22:41
by Nebbie
WarHawk wrote:
Fri May 15, 2020 09:28
so are iron golems supposed to take dmg from falling or not?
Supposed to not (that's the Minecraft behavior).

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 15, 2020 23:44
by WarHawk
ok.. so is there no way to create an automatic farm for them?
using a spawner.

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 15, 2020 23:49
by leo_rockway
I was actually looking at an iron golem farm video from Minecraft yesterday. The ones I saw rely on pushing the golems with water and since Minetest doesn't have water flow pushing entities yet, that would complicate things. I don't know if a piston would push the golem; I've barely played with redstone.

The farm I saw used 1 block of lava to kill the golems, by the way. The lava cube was held in place by signs, so the lava wouldn't flow. It had a hopper and a chest underneath it.

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 15, 2020 23:59
by leo_rockway
leo_rockway wrote:
Tue May 12, 2020 01:18
Nebbie wrote:
Sun May 10, 2020 17:23
So what about the liquid stuff? I must reiterate that was the biggest issue.
Old, old bug in the engine.
Sorry for the double post. I was in the #minetest IRC channel and after asking about this issue it seems that the problem was identified by sfan5 and he submitted a PR. Hopefully this bug can finally be closed.

https://github.com/minetest/minetest/pull/9874

Re: [Game] MineClone 2 [0.65.2]

Posted: Sat May 16, 2020 01:06
by WarHawk
leo_rockway wrote:
Fri May 15, 2020 23:49
I was actually looking at an iron golem farm video from Minecraft yesterday. The ones I saw rely on pushing the golems with water and since Minetest doesn't have water flow pushing entities yet, that would complicate things. I don't know if a piston would push the golem; I've barely played with redstone.

The farm I saw used 1 block of lava to kill the golems, by the way. The lava cube was held in place by signs, so the lava wouldn't flow. It had a hopper and a chest underneath it.
yeah water doesnt push them and lava only kills them if they are standing in it. if there is a block of space below the lava they seem to walk around fine. also with the signs they catch on fire from the lava. gates work tho

Re: [Game] MineClone 2 [0.65.2]

Posted: Sat May 16, 2020 02:52
by Nebbie
leo_rockway wrote:
Fri May 15, 2020 23:59
leo_rockway wrote:
Tue May 12, 2020 01:18
Nebbie wrote:
Sun May 10, 2020 17:23
So what about the liquid stuff? I must reiterate that was the biggest issue.
Old, old bug in the engine.
Sorry for the double post. I was in the #minetest IRC channel and after asking about this issue it seems that the problem was identified by sfan5 and he submitted a PR. Hopefully this bug can finally be closed.

https://github.com/minetest/minetest/pull/9874
Nice to see bugs fixed, but I don't think this would solve all of the issues here.
Here is the sequence of (ideal, not quite what I did, but what I should have done) actions that should result in easy casting of a Nether Portal, as they go in Minecraft (glow on held item is from a purely visual mod):
Spoiler
Place block to replace one lava, then water next to it.
Image
Remove block and let water flow.
Image
Get water source back in bucket, place up above for water that will instantly obsidian placed lava in a portal shape (do right top before left top).
Image
And here's how they go (wrong) in MineClone 2:
Spoiler
Image
Initial lava replacement works.
Image
Uh oh! The lava flowed first, so I have to quickly water up that spot instead.
Image
This is completely wrong and crippling. I believe I've seen the same issue in the Nether, where lava flows regularly end up creating utterly ridiculous curtains, rarely seen in Minecraft, from too much flowing outwards.
Separately, there is a problem where you can place and mine blocks thru flowing liquids, but not use a bucket thru them. This is pretty annoying because it means when it comes time to place lava around the water, the lava will replace water that's looked thru!
WarHawk wrote:
Sat May 16, 2020 01:06
leo_rockway wrote:
Fri May 15, 2020 23:49
I was actually looking at an iron golem farm video from Minecraft yesterday. The ones I saw rely on pushing the golems with water and since Minetest doesn't have water flow pushing entities yet, that would complicate things. I don't know if a piston would push the golem; I've barely played with redstone.

The farm I saw used 1 block of lava to kill the golems, by the way. The lava cube was held in place by signs, so the lava wouldn't flow. It had a hopper and a chest underneath it.
yeah water doesnt push them and lava only kills them if they are standing in it. if there is a block of space below the lava they seem to walk around fine. also with the signs they catch on fire from the lava. gates work tho
Proper Minecraft behavior would have actual collision checks between mobs/players and potentially damaging blocks. From what I saw looking at MineClone 2's code, it just looks at a single node that's considered to be where the mob's feet are at. In Minecraft for instance, you can take lava damage from standing too close to a lava lake's edge on Soul Sand (which has a slightly lower top than normal blocks).

Re: [Game] MineClone 2 [0.65.2]

Posted: Thu May 21, 2020 00:43
by Lone_Wolf
Not sure if this has been reported already but it looks like stone is spawning in the place of netherrack in the nether.
I'm using Minetest 5.3.0-dev-6a5c91b55, I could test on 5.2 if wanted. I downloaded the game from CDB earlier today

Re: [Game] MineClone 2 [0.65.2]

Posted: Thu May 21, 2020 00:57
by Wuzzy
Play in Minetest 5.2.0. -dev versions are not supported and never have been.

Re: [Game] MineClone 2 [0.65.2]

Posted: Thu May 21, 2020 01:13
by Lone_Wolf
Alrighty. Tested and can't reproduce in 5.2

I get this error when registering a tool that has a non-fleshy damage group:

Code: Select all

ModError: Runtime error from mod 'tt' in callback on_mods_loaded(): ...in/../games/mineclone2/mods/HELP/tt/snippets_builtin.lua:128: attempt to concatenate local 'msg' (a nil value)
stack traceback:
	...in/../games/mineclone2/mods/HELP/tt/snippets_builtin.lua:128: in function <...in/../games/mineclone2/mods/HELP/tt/snippets_builtin.lua:38>
	...f/minetest/bin/../games/mineclone2/mods/HELP/tt/init.lua:30: in function <...f/minetest/bin/../games/mineclone2/mods/HELP/tt/init.lua:22>
	/home/lone_wolf/minetest/bin/../builtin/game/register.lua:429: in function </home/lone_wolf/minetest/bin/../builtin/game/register.lua:413>
Check debug.txt for details.

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 22, 2020 14:58
by bzt
Hi Wuzzy!

Last time I offered structures to MC2, you said no good because they were converted from the Minecraft wiki pages (I agree it's better to avoid copyright lawsuits). So this time I'm offering structures that were made by my boys, entirely from scratch. Any similarity with the original MC game is just a coincidence :-) There are 3 crop fields, 7 houses (small, large, a library), and a target practice field. If you like them, I can offer more, because my boys turns out to be very creative :-D They like your subgame very very much, they play that all day long. They have tried MTG with many different mods, the LotT, Farlands and a few others, but they always return to MC2. I'd like to say thank you in their names with this little contribution!

Cheers,
bzt

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 22, 2020 17:10
by LMD
That's very kind of you and your boys. You still need to choose a license, else you are considered the copyright holder and Wuzzy might not be allowed to use it :/

Re: [Game] MineClone 2 [0.65.2]

Posted: Fri May 22, 2020 20:46
by Nebbie
Speaking of structures, I suppose everything with random expanding generation needs hardcoding, since there's nothing akin to Minecraft 1.14's jigsaw block? I had some ideas on Minecraft-alike Nether Fortresses, but they might be quite a pain to draft without being able to use schematics.

Re: [Game] MineClone 2 [0.65.2]

Posted: Sat May 23, 2020 10:54
by bzt
I hereby grant Wuzzy the right to use these structures with Mineclone2 under any license that permits that. If otherwise not mentioned, that's MIT.

Cheers,
bzt

Re: [Game] MineClone 2 [0.65.2]

Posted: Sat May 23, 2020 11:07
by bzt
Nebbie wrote:
Fri May 22, 2020 20:46
pain to draft without being able to use schematics.
You can use schematics! There's the in game Schematic Editor mod to build structures, Handle Schematics that can import some Minecraft schems too. Just browse through contents. A standalone application is MTSEdit (available for Windows, Linux, MacOSX), which can import virtually all voxel formats out there (Minecraft schematics, Sponge schematics, Magicavoxel, Goxel, Qubicle, Model3D, Tiled TMX etc. etc. etc.) and save MTS files with a certain Minetest node palette (Mineclone2 being its main focus). It is WIP, but already quite usable. Has a minimal MTSEdit mod, that (just like the other previously mentioned mods) can import schematics into the world.

Cheers,
bzt

Re: [Game] MineClone 2 [0.65.2]

Posted: Sun May 24, 2020 01:49
by Nebbie
bzt wrote:
Sat May 23, 2020 11:07
Nebbie wrote:
Fri May 22, 2020 20:46
pain to draft without being able to use schematics.
You can use schematics! ...
In a way that allows for random generation of pathways from a starting structure, so that every time it is created, it is different?

Re: [Game] MineClone 2 [0.65.2]

Posted: Sun May 24, 2020 11:17
by bzt
Nebbie wrote:
Sun May 24, 2020 01:49
In a way that allows for random generation of pathways from a starting structure, so that every time it is created, it is different?
Well, using structures for pathways is quite an unorthodox thing to do, but yes. You can assign probability values to nodes in schematics. Here's a 1 node tall structure from above:

Code: Select all

grass grass path(100%) grass
grass path(50%) path(50%) grass
grass path(50%) path(50%) grass
grass path(50%) path(50%) grass
grass path(100%) grass grass
You can also create a few smaller path parts and put them together randomly, one after another to create a larger random pathway. But as I suggested, don't use schematics for pathways, write a small lua script instead. More efficient and better looking, and you can guarantee the continuity of the path easily.

Cheers,
bzt

Re: [Game] MineClone 2 [0.65.2]

Posted: Tue May 26, 2020 00:13
by Nebbie
bzt wrote:
Sun May 24, 2020 11:17
Nebbie wrote:
Sun May 24, 2020 01:49
In a way that allows for random generation of pathways from a starting structure, so that every time it is created, it is different?
Well, using structures for pathways is quite an unorthodox thing to do, but yes. You can assign probability values to nodes in schematics. Here's a 1 node tall structure from above:

Code: Select all

grass grass path(100%) grass
grass path(50%) path(50%) grass
grass path(50%) path(50%) grass
grass path(50%) path(50%) grass
grass path(100%) grass grass
You can also create a few smaller path parts and put them together randomly, one after another to create a larger random pathway. But as I suggested, don't use schematics for pathways, write a small lua script instead. More efficient and better looking, and you can guarantee the continuity of the path easily.

Cheers,
bzt
What I mean is that a Nether Fortress is composed of many different possible large segments, each of which could be a full schematic of their own, and it is random which are included where to form a very large contiguous structure going hundreds of blocks in multiple directions.
I don't think schematics can do that. You would need a node to spawn another schematic which can then spawn another schematic on and on. This is what Minecraft 1.14 and above do for certain structures.