[mod] Not So Simple Helicopter [nss_helicopter]

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

[mod] Not So Simple Helicopter [nss_helicopter]

by apercy » Post

Hello!

I'm relatively new here. This quarantine took me to know the minetest and then I started to enter some servers, I got to know some mods and one that really caught my attention was the Simple helicopter. But I thought something was missing, something that could even make it feasible for use on servers, within the economy of each world. So the first thing I did was to make it more expensive to produce. And as a generalist modeler in blender, changed the model, of course.
Having taken advantage of the opportunity that Gundul gave me to test it on his server, and with his suggestions, we were able to come up with a model that uses biofuel from crops. So far we have a helicopter that consumes fuel, has its consumption changed according to the level of flight and not only that. This led me to create a second mod (based on the wine mod), with a distiller that allows to transform some inputs into biofuel and fly with them. And now I'm also developing a motorboat mod to use this fuel.

After all this talk, I present the helicopter fork and the biofuel mod:

https://github.com/APercy/helicopter
https://github.com/APercy/minetest_biofuel

When creating a distiller, you can add wheat, corn, etc. to generate the biofuel. Then when entering your helicopter with the right click, you can fill it with a punch in the seat, until you fill the fuel gauge on the panel. Then just use the space bar to move up, shift to move down, mouse to rotate, directional to move


Update 2021-10-05:
Consumption, max height and control improved. To change the rotation control to the keyboard, just hit E key

Licences:
- code: GPL_v2 (inherited from original Pavel_S mod)
- `matrix.lua` file: CC0
- helicopter_motor.ogg by Robinhood76 | License: Attribution Noncommercial
- helicopter_water_driblet.png by DS | License: CC0
- helicopter model by APercy | License: CC BY-NC-SA 3.0

Depends: default, player_api, biofuel

Credits:
- Pavel_S for original code
- Desour for the updated code
- Melkor for original rotor textures
- Pavel_S for Rotor craft icon
- Gundul for the brilliant idea of biofuel

Image
Attachments
screenshot_20200425_090602.png
screenshot_20200425_090602.png (856.16 KiB) Viewed 1539 times
Last edited by apercy on Wed Oct 27, 2021 00:25, edited 6 times in total.

u18398

Re: Not So Simple Helicopter and Biofuel

by u18398 » Post

Thanks for your mod, The heli works already pretty good and it is fun flying around with it.

When you post your mods here there are some style rules, though :)
This forum is also scanned by the content database, so for easy finding of your mods you
should start naming it like in this example:

[mod] Not So Simple Helicopter [helicopter]


the post should contain or mention at least the following:

License: the license of code and media used
Depends: what mods your mod is depending on (for example default, farming, etc...)
pictures: People need pictures nowadays XD Videos even better, reading is unconvenient :D
credits: if any

And description, which you already did :)

And better only one mod per post, or you can post many and call it a modpack.
In the last case you should handle it also on github as a modpack.

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: Not So Simple Helicopter and Biofuel

by apercy » Post

Thank you!

So I need make new posts with the mods separated and following the rules, correct? If yes, I will do it when finish the motorboat mod, so I can make 3 posts following the style

u18398

Re: Not So Simple Helicopter and Biofuel

by u18398 » Post

apercy wrote:Thank you!

So I need make new posts with the mods separated and following the rules, correct? If yes, I will do it when finish the motorboat mod, so I can make 3 posts following the style
That is right, or you do a modpack with all three of them.

But I do not know how to do a modpack correctly. Never did so far.

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

If you want to save data of your helicopter after you dug it, you could use metadata.
Read out fuel and damage level when a player wants to dig it and save it in the metadata
of the craftitem.
When you place the item check if metadata is there and write it back to the newly placed
entity.

But you could also handle it like Termos did with his sailingkit.
A helicopter would not fit in somebody's pocket or bag :D So if dug,
it will break into the pieces which it was built from, minus a few percent
depending on its damage level before. Fuel is lost.

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Danke schön =)

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

I forgot:

if you want to provide more information about heli flight status you could try
to add these to the player hud. I never tried it but maybe this also works if
a player is attached to an entity.
See lua_api.txt in the minetest doc folder. search for player hud :)

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

I made a pull request on your biofuel mod.

This would add the following:

if technic mod is present, biofuel can be made with the extractor.

if basic_machines mod is present, biofuel can be made with the grinder.

In both cases the raw materials are:
corn
wheat
potato
papyrus

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Gundul wrote:If you want to save data of your helicopter after you dug it, you could use metadata.
Read out fuel and damage level when a player wants to dig it and save it in the metadata
of the craftitem.
When you place the item check if metadata is there and write it back to the newly placed
entity.
...
on craftitem I put this:

Code: Select all

        local obj = minetest.add_entity(pointed_thing.above, "helicopter:heli")
        local ent = obj:get_luaentity()
        local imeta = itemstack:get_meta()
        local owner = placer:get_player_name()
        ent.owner = owner
        ent.energy = imeta:get_int("energy")
        ent.damage = imeta:get_int("damage")
and at on_punch from register_entity

Code: Select all

            local inv = puncher:get_inventory()
            if inv then
	            for _, item in ipairs({"helicopter:heli"}) do
                    local itemstack = inv:add_item("main", item)
                    local imeta = itemstack:get_meta()
                    imeta:set_int("damage", self.damage)
                    imeta:set_int("energy", self.energy)
	            end
            end
but nothing of the itemstack is being saved :(

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Gundul wrote:I forgot:

if you want to provide more information about heli flight status you could try
to add these to the player hud. I never tried it but maybe this also works if
a player is attached to an entity.
See lua_api.txt in the minetest doc folder. search for player hud :)
it's a good idea!
I was fighting against the temptation to model an altimeter and put it to panel =)

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

apercy wrote:
Gundul wrote:If you want to save data of your helicopter after you dug it, you could use metadata.
Read out fuel and damage level when a player wants to dig it and save it in the metadata
of the craftitem.
When you place the item check if metadata is there and write it back to the newly placed
entity.
...
on craftitem I put this:

Code: Select all

        local obj = minetest.add_entity(pointed_thing.above, "helicopter:heli")
        local ent = obj:get_luaentity()
        local imeta = itemstack:get_meta()
        local owner = placer:get_player_name()
        ent.owner = owner
        ent.energy = imeta:get_int("energy")
        ent.damage = imeta:get_int("damage")
and at on_punch from register_entity

Code: Select all

            local inv = puncher:get_inventory()
            if inv then
	            for _, item in ipairs({"helicopter:heli"}) do
                    local itemstack = inv:add_item("main", item)
                    local imeta = itemstack:get_meta()
                    imeta:set_int("damage", self.damage)
                    imeta:set_int("energy", self.energy)
	            end
            end
but nothing of the itemstack is being saved :(
I am not using metadata very often. But I think I used it in my aviator mod
to save the remaining flight time. Maybe that can help you:

https://github.com/berengma/aviator

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

The problem seems to be some limitation of the entity, but I will consult your code to see if I can get any light on it
Thank you.

PS: I put some updates today, now we have some Flight information on HUD, I'll improve it later

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Hi! Updated again. Now you cannot put your heli on inventory anymore. If you does not want it, you can destroy it.

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

apercy wrote:
Tue Apr 28, 2020 16:56
The problem seems to be some limitation of the entity, but I will consult your code to see if I can get any light on it
Thank you.

PS: I put some updates today, now we have some Flight information on HUD, I'll improve it later
I took a quick look at my code of aviator and I used to serialize/deserialize the metadata.
An other very good source for using metadata is the basic_machines mod which uses this
excessively :)
As I said before I am not very experienced in metacode using.

I will update helicopter on ZombieTest now.

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Err... update again, I made more changes!!!!! Now It can be destroyed =D and painted

ps: very curious, the hud aren't updating at server...

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Updated. HUD bug slowdown corrected

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Now you can paint with dye!

Image
screenshot_20200429_154416.png
screenshot_20200429_154416.png (809.35 KiB) Viewed 1539 times

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

already online on ZombieTest :)

There is a bug, you can fill gasoline with dye instead biofuel :D

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [mod] Not So Simple Helicopter [helicopter]

by Sokomine » Post

The helicopters look very nice. Hope to see them on some server soon in order to get a better look at towns from above!
A list of my mods can be found here.

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Gundul wrote:
Thu Apr 30, 2020 16:45
already online on ZombieTest :)

There is a bug, you can fill gasoline with dye instead biofuel :D
I tried to reproduce but cannot. Maybe it was some racing condition with self.drivername value, cause to paint it must be nil. I'll think about a solution...

Code: Select all

        if self.driver_name and self.driver_name == name and touching_ground then
            --refuel
            load_fuel(self, puncher:get_player_name())
        end

        if self.driver_name == nil and self.owner == name then
        	--painting

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Done!
I changed the way the attach is check

Code: Select all

        local is_attached = false
        if puncher:get_attach() == self.object then is_attached = true end

        if is_attached == true and touching_ground then
            --refuel
            load_fuel(self, puncher:get_player_name())
        end

        if is_attached == false then

            -- deal with painting or destroying
PS: * `get_attach()`: returns parent, bone, position, rotation or nil if it isn't

u18398

Re: [mod] Not So Simple Helicopter [helicopter]

by u18398 » Post

I can still fill my helicopter with dye as fuel. :)
I place my helicopter, then I paint it with dye, then I enter and use the dye like
I would use biofuel.

Or is that happening because I am admin and have creative priv ?

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

Gundul wrote:
Fri May 01, 2020 06:12
I can still fill my helicopter with dye as fuel. :)
I place my helicopter, then I paint it with dye, then I enter and use the dye like
I would use biofuel.

Or is that happening because I am admin and have creative priv ?
Does not make sense... I'll research more ;)

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

A question: It decreases the dye count or the biofuel count when it happens?

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Not So Simple Helicopter [helicopter]

by apercy » Post

ok, commited!

Code: Select all

        local itmstck=puncher:get_wielded_item()
        local item_name = ""
        if itmstck then item_name = itmstck:get_name() end

        if is_attached == true and touching_ground and item_name == "biofuel:biofuel" then
            --refuel
            load_fuel(self, puncher:get_player_name())
        end

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests