[SOLVED'ish]Lost in Logic, PLEASE HELP!

User avatar
Steamed_Punk
Member
 
Posts: 88
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

[SOLVED'ish]Lost in Logic, PLEASE HELP!

by Steamed_Punk » Sat Oct 12, 2019 17:31

As an addition to my mod i am trying to build a tanning rack, but i am getting a little confused.

I have four nodes for the tanning rack, an empty one, second with hair and fatty side of the hide in place, third with hair side and tanned side and the fourth with both sides tanned.

The idea is that the user clicks the empty tanning rack with a fresh hide and it shows tied to the rack, with the crafted scraper, the user can then tan the fatty side. As you would destroy a block, you can see the animated overlay. I have created new animations to show the stages of fatty to tanned and for hairy to tanned (may need redoing).
From there once the animated scraping effect has finished it drops the half tanned hide, reverting back to an empty rack. The user can then use the half tanned hide for something or place it onto an empty rack and tan the hairy side as well. (Let's say hairy tanned for blankets and full tanned for clothes, not sure yet)

1) Do i actually need four nodes for all stages or can i just have one node with replacement textures. Either way, how do i get the empty one to be replaced when fresh hide is placed onto it.

2) How can i make the empty rack accept both a fresh and a half tanned hide

3) Will i need to have the full rack texture animated to give the impression that the skin is scraped or can i just animate the part that needs to look like it's being scraped. How do i go about this.

The attached file gives a visual explanation of what i am trying to say. Like i said i have the four nodes and all other items an textures ready, but i am lost in the logic.

Image

If code is needed i can post it but it's basically four nodes and a couple of items. I can also zip stuff up and send?

Thanks in advance for any interest in helping me get this to work.
Last edited by Steamed_Punk on Wed Oct 23, 2019 20:15, edited 1 time in total.
The sky is not the limit - It's my playground
 

ShadMOrdre
Member
 
Posts: 534
Joined: Mon Dec 29, 2014 08:07
Location: USA
GitHub: ShadMOrdre
In-game: shadmordre

Re: Lost in Logic, PLEASE HELP!

by ShadMOrdre » Mon Oct 14, 2019 08:11

What I am attempting, for a very similar tanning rack, is to use a node for the rack, and an entity for the skin. When the user clicks the rack while wielding a skin, the skin is removed from the wielded stack, and added to the rack node internal inventory stack. Whatever processing on the skin is done by the tanning rack, on a timer, and the finished product, a tanned skin, is then made available in the node inventory item stack. The player then punches / places the skin. I prefer right click place over left click punch.

There is an anvil mod available somewhere, that uses similar logic. The anvil is based on the cottages mod anvil, but removes the formspec, allowing a user to right click place the tool on the anvil.

I'm also working on a spinning wheel, using the same base code.

Here is a non-working copy of my code. By non-working, I simply mean, it's from a mod, not a standalone mod, and internally, nothing is done to the skin. The code allows you to put and take the skin from the rack. The rack is a node, the skin is an entity. The bulk of this code was originally the aforementioned anvil mod.

+ Spoiler


Another option you might try, since you are using a mesh, is to use an animated mesh. Frame 1 is empty, frame two is raw skin, frame 3 is finished product. Just set the animation frame to the desired state.

Another option is to use two meshes, one for the rack, one for the skin, and then plug those in to the code from above.

Hope some of this helps. Looking forward to what you deliver. :)

Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.
 

User avatar
Steamed_Punk
Member
 
Posts: 88
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: Lost in Logic, PLEASE HELP!

by Steamed_Punk » Tue Oct 15, 2019 12:49

ShadMOrdre wrote:What I am attempting, for a very similar tanning rack, is to use a node for the rack, and an entity for the skin. When the user clicks the rack while wielding a skin, the skin is removed from the wielded stack, and added to the rack node internal inventory stack. Whatever processing on the skin is done by the tanning rack, on a timer, and the finished product, a tanned skin, is then made available in the node inventory item stack. The player then punches / places the skin. I prefer right click place over left click punch.

There is an anvil mod available somewhere, that uses similar logic. The anvil is based on the cottages mod anvil, but removes the formspec, allowing a user to right click place the tool on the anvil.

I'm also working on a spinning wheel, using the same base code.

Here is a non-working copy of my code. By non-working, I simply mean, it's from a mod, not a standalone mod, and internally, nothing is done to the skin. The code allows you to put and take the skin from the rack. The rack is a node, the skin is an entity. The bulk of this code was originally the aforementioned anvil mod.

+ Spoiler


Another option you might try, since you are using a mesh, is to use an animated mesh. Frame 1 is empty, frame two is raw skin, frame 3 is finished product. Just set the animation frame to the desired state.

Another option is to use two meshes, one for the rack, one for the skin, and then plug those in to the code from above.

Hope some of this helps. Looking forward to what you deliver. :)

Shad


Hi Shad,

Knowing you are working on something similar and that your coding skills are obviously more advanced than mine, i am wondering if it wouldn't be easier if i wait (instead of having your mod and my half baked attempt out there) and then credit you, how far are you into this? I would have PM'ed you but no option to do so.

I will take a look at the anvil mod though!

I like the idea of the spinning wheel, i had thoughts of a water mill wheel. In MC i just used paintings to create the effect, it didn't actually move and was complicated as the water needed to be correctly guided as it broke the paintings. looked ok but was useless. :D

I will play with your code and if i can get a result i like/need i will credit you.

I hadn't thought about using an animated mesh, that could be one way to go.

You said another option is two meshes, rack and skin. This was my initial starting point but i couldn't work out how to get the skin to sit within the rack (code wise), from there i built the 4 nodes of all the different stages thinking click and replace. Then i couldn't work out how i should get the animated scraping effect to work and posted here.

My replies may look all over the place, but that's the way i am, i will have a look and try everything, but like the animated mesh idea the most.

regards.
The sky is not the limit - It's my playground
 

User avatar
Steamed_Punk
Member
 
Posts: 88
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: Lost in Logic, PLEASE HELP!

by Steamed_Punk » Thu Oct 17, 2019 21:46

I am still a little lost but getting closer.

so far i have managed to get the empty rack to accept both rawhide and half Hairy/tanned hide. Depending on which one is set into the rack. Both can be tanned with the scraper leaving you with a hairy/tanned hide or a tanned both sides hide. This in itself works to a point and with a bit of refinement could be finished in a couple of hours.

Except it feels off without the animated scraping effect and this is now where i am stuck and looking for more help.

In the code enclosed you will see i am trying to animate the scraping effect using an entity and calling it into the node below. (Following Shads advice).
The entity is a single faced plane/face mesh.obj which when called into the node does appear and that's it. The texture is squashed onto the object showing all five animation frames and isn't animated. I managed to get it to work using a particle but obviously that rotated and just looked bad.

I have tried animating when the entity is called on but couldn't get any result, the code below is as far as i can get (so far).

WTHeck am i doing wrong, how do i get the animation to work and the entity to disappear when the animation has ended. (Sorry about the sloppy code, feel free to show me what is wrong and not needed).

Code: Select all
minetest.register_entity("nativeamericanvillage:aniblock01", {
   hp_max = 1,
    physical = true,
    weight = 5,
    collisionbox = {-1, 1.5, -0.1, 0.9, -0.1, 0.1},
    visual = "mesh",
    visual_size = {x=10, y=10},
    mesh = "aniblock01.obj",
    textures = {"nativeamericanvillage_tanrack_inner_ani.png"},
    animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 1.5,},
    expirationtime = 2,
    size = 16,
    spritediv = {x=1, y=1},
    initial_sprite_basepos = {x=0, y=0},
    is_visible = true,
    makes_footstep_sound = false,
    automatic_rotate = false,
})

minetest.register_node('nativeamericanvillage:tanner01', {
    description = ("Tanning Rack"),
    drawtype = 'mesh',
    mesh = 'indianvillage_tanner_01.obj',
    tiles = {name='nativeamericanvillage_tanrack_01.png'},
    walkable = false,
    buildable_to = false,
    sunlight_propagates = true,
    groups = {dig_immediate=3, flammable=0},
    paramtype = 'light',

    collisiondetection = true,
    selection_box = {
        type = 'fixed',
        fixed = { -1, 1.5, -0.1, 0.9, -0.1, 0.1 },
    },

    on_construct = function(pos)
        local meta = minetest.get_meta(pos)
        meta:set_string('infotext', ("Tanning Rack"));
    end,
    on_rightclick = function(pos, node, player, itemstack, pointed_thing)
        if itemstack:get_name() == "nativeamericanvillage:scraper" then
            minetest.set_node(pos, {name = 'nativeamericanvillage:tanner02'})

minetest.add_entity(pos, "nativeamericanvillage:aniblock01", nil)
        end
      end,
})


So close yet so far.
Thanks in advance.
The sky is not the limit - It's my playground
 

User avatar
Steamed_Punk
Member
 
Posts: 88
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: Lost in Logic, PLEASE HELP!

by Steamed_Punk » Wed Oct 23, 2019 20:15

It's working'ish and online. I didn't manage to get the animation working, so settled for something simple for the time being.

You can see it in the Native American Village mod.
The sky is not the limit - It's my playground
 


Return to Modding Discussion



Who is online

Users browsing this forum: Google [Bot] and 6 guests