[Mod] Flyingships

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

[Mod] Flyingships

by neko259 » Sat Mar 21, 2015 21:08

This mod allows you to connect nodes into a structure that can fly as a whole. The code was originally taken from technic' frames but changed a lot.

You connect a node by placing a motor, connecting any blocks to it (no frames!) and punching it with a configurator. If there are no too many blocks in the structure (e.g. if you forgot to disconnect it from the ground), all blocks will be saved in the motor. Then if you craft a beautiful pink key, you punch the motor with it and the structure flies in the punch direction.

Image
Image
Image

The recipes can be found at the crafting guide. Briefly, they are:
Code: Select all
minetest.register_craft({
    output = "flyingships:frame_motor",
    recipe = {
        {"mesecons:mesecon", "mesecons_materials:glue", "mesecons:mesecon"},
        {"mesecons:mesecon", "default:copperblock", "mesecons:mesecon"},
        {"mesecons:mesecon", "mesecons_materials:glue", "mesecons:mesecon"}
    }
})

minetest.register_craft({
    output = "flyingships:frame_motor_directed",
    recipe = {
        {"mesecons:mesecon", "mesecons_materials:glue", "mesecons:mesecon"},
        {"mesecons:mesecon", "default:goldblock", "mesecons:mesecon"},
        {"mesecons:mesecon", "mesecons_materials:glue", "mesecons:mesecon"}
    }
})

minetest.register_craft({
    output = "flyingships:key",
    recipe = {
        {"", "default:diamond", ""},
        {"", "default:stick", ""},
        {"", "mesecons_materials:glue", ""}
    }
})

minetest.register_craft({
    output = "flyingships:configurator",
    recipe = {
        {"default:diamond", "default:diamond", "default:diamond"},
        {"", "default:stick", ""},
        {"", "mesecons_materials:glue", ""}
    }
})


Depends on:
default
mesecons
mesecons_materials

The directed motor is a motor that works similar to the one in technic: you connect mesecon to it and make a signal. It can be used as a simple one with the key too,

Repo and download
: https://bitbucket.org/neko259/flyingships
Last edited by neko259 on Wed Jan 02, 2019 20:41, edited 3 times in total.
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Sat Mar 21, 2015 21:09

Version 1.0 seems to be stable but I've tested it only for several minutes. So feel free to write about any bugs.
 

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

Re: [Mod] Flyingships

by Krock » Sun Mar 22, 2015 11:02

Code: Select all
12:00:09: ACTION[ServerThread]: singleplayer uses flyingships:key, pointing at [node under=-429,21,-
213 above=-429,22,-213]
12:00:09: ERROR[main]: ServerError: E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:140:
 bad argument #1 to 'ipairs' (table expected, got nil)
12:00:09: ERROR[main]: stack traceback:
12:00:09: ERROR[main]:  [C]: in function 'ipairs'
12:00:09: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:140: in function
 'move_nodes_vect'
12:00:09: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:207: in function
 'move_by_motor'
12:00:09: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:247: in function
 <E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:241>
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Sun Mar 22, 2015 11:05

Krock wrote:
Code: Select all
12:00:09: ACTION[ServerThread]: singleplayer uses flyingships:key, pointing at [node under=-429,21,-
213 above=-429,22,-213]
12:00:09: ERROR[main]: ServerError: E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:140:
 bad argument #1 to 'ipairs' (table expected, got nil)
12:00:09: ERROR[main]: stack traceback:
12:00:09: ERROR[main]:  [C]: in function 'ipairs'
12:00:09: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:140: in function
 'move_nodes_vect'
12:00:09: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:207: in function
 'move_by_motor'
12:00:09: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:247: in function
 <E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:241>

I don't really understand why this happens, but added a condition. Try to update and check now.
 

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

Re: [Mod] Flyingships

by Krock » Sun Mar 22, 2015 11:41

Okay, it works now but it ould be better to use VManip instead of removing/placing each node on another place.

EDIT: After punching a mesecons button, connected to the motor:
Code: Select all
12:48:22: WARNING: Undeclared global variable "move_by_motor" accessed at E:\Programme\minetest\bin\
..\mods\flyingships/functions.lua:194
12:48:22: ERROR[main]: ServerError: E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:194:
 attempt to call global 'move_by_motor' (a nil value)
12:48:22: ERROR[main]: stack traceback:
12:48:22: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:194: in function
 'action_on'
12:48:22: ERROR[main]:  ...amme\minetest\bin\..\mods\mesecons\mesecons/internal.lua:189: in function
 <...amme\minetest\bin\..\mods\mesecons\mesecons/internal.lua:184>
12:48:22: ERROR[main]:  ...e\minetest\bin\..\mods\mesecons\mesecons/actionqueue.lua:90: in function
'execute'
12:48:22: ERROR[main]:  ...e\minetest\bin\..\mods\mesecons\mesecons/actionqueue.lua:84: in function
<...e\minetest\bin\..\mods\mesecons\mesecons/actionqueue.lua:61>
12:48:22: ERROR[main]:  E:\Programme\minetest\bin\..\builtin\game\register.lua:341: in function <E:\
Programme\minetest\bin\..\builtin\game\register.lua:329>

EDIT2: Fixed after moving the function move_by_motor() above frame_motor_on()
EDIT3:
Code: Select all
13:01:23: ERROR[main]: ServerError: E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:98:
attempt to call field 'is_mvps_unmov' (a nil value)
13:01:23: ERROR[main]: stack traceback:
13:01:23: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:98: in function
'move_nodes_vect'
13:01:23: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:201: in function
 'move_by_motor'
13:01:23: ERROR[main]:  E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:249: in function
 <E:\Programme\minetest\bin\..\mods\flyingships/functions.lua:243>
Last edited by Krock on Sun Mar 22, 2015 12:04, edited 4 times in total.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Sun Mar 22, 2015 11:46

Krock wrote:Okay, it works now but it ould be better to use VManip instead of removing/placing each node on another place.

I could not understand the wiki page about voxel manipulation, and don't see any other tutorial. If anyone can work with it, pull requests are welcome. There is not so many code :)
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Sun Mar 22, 2015 16:41

Added voxel manip. Now I'll test it on a live server and then commit and push to the repo.
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Sun Mar 22, 2015 16:51

neko259 wrote:Added voxel manip. Now I'll test it on a live server and then commit and push to the repo.

Nope, it does not work. Lighting breaks, node facedirs break too.
 

User avatar
Hybrid Dog
Member
 
Posts: 2719
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Flyingships

by Hybrid Dog » Wed Mar 25, 2015 14:09

some time ago l tried to make moving flying ships possible, too
http://paste.ubuntu.com/10678054/
Code: Select all
local load_time_start = os.clock()

-- the function to get the hull
local function get_tab(pos, func, max)
   local tab = {pos}
   local tab_avoid = {[pos.x.." "..pos.y.." "..pos.z] = true}
   local tab_done,num = {pos},2
   while tab[1] do
      for n,p in pairs(tab) do
         --[[
         for i = -1,1,2 do
            for _,p2 in pairs({
               {x=p.x+i, y=p.y, z=p.z},
               {x=p.x, y=p.y+i, z=p.z},
               {x=p.x, y=p.y, z=p.z+i},
            }) do]]
         for i = -1,1 do
            for j = -1,1 do
               for k = -1,1 do
                  local p2 = {x=p.x+i, y=p.y+j, z=p.z+k}
                  local pstr = p2.x.." "..p2.y.." "..p2.z
                  if not tab_avoid[pstr]
                  and func(p2) then
                     tab_avoid[pstr] = true
                     tab_done[num] = p2
                     num = num+1
                     table.insert(tab, p2)
                     if max
                     and num > max then
                        return false
                     end
                  end
               end
            end
         end
         tab[n] = nil
      end
   end
   return tab_done
end

-- everything not air belongs to the hull
local function is_solid(pos)
   return minetest.get_node(pos).name ~= "air"
end

-- gets the ship with e.g. floating stuff inside
local function get_ship(pos)
   local hull = get_tab(pos, is_solid, 3000)
   if not hull then
      return
   end
   local min = vector.new(pos)
   local max = vector.new(pos)
   local ps = {}
   for _,pos in pairs(hull) do
      local pstr = pos.x.." "..pos.z
      local mm = ps[pstr]
      if not mm then
         ps[pstr] = {pos.y, pos.y}
      else
         ps[pstr][1] = math.min(mm[1], pos.y)
         ps[pstr][2] = math.max(mm[2], pos.y)
      end
      for _,i in pairs({"x", "y", "z"}) do
         min[i] = math.min(min[i], pos[i])
         max[i] = math.max(max[i], pos[i])
      end
   end
   return ps, min, max
end

local log = minetest.chat_send_all   --minetest.log

-- moves it
local c_air = minetest.get_content_id("air")
local function move_ship(dif, ps, min, max)
   local manip = minetest.get_voxel_manip()
   local emerged_pos1, emerged_pos2 = manip:read_from_map(min, max)
   local area = VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
   local nodes = manip:get_data()
   local param2s = manip:get_param2_data()

   local nmin = vector.add(min, dif)
   local nmax = vector.add(max, dif)

   local manip2 = minetest.get_voxel_manip()
   local emerged_pos1, emerged_pos2 = manip2:read_from_map(nmin, nmax)
   local area2 = VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
   local nodes2 = manip2:get_data()
   local param2s2 = manip:get_param2_data()

   for xz,y in pairs(ps) do
      local x,z = unpack(string.split(xz, " "))
      for y = y[1], y[2] do
         local index = area:index(x,y,z)
         local index2 = area2:index(x+dif.x,y+dif.y,z+dif.z)
         if nodes2[index2] ~= c_air then
            log("[as_transport] error: "..minetest.get_name_from_content_id(nodes2[index2]).." was blocking.")
            return
         end
         nodes2[index2] = nodes[index]
         param2s2[index2] = param2s[index]
         nodes[index] = c_air
      end
   end

   manip:set_data(nodes)
   manip:write_to_map()
   manip:update_map()

   manip2:set_data(nodes2)
   manip:set_param2_data(param2s2)
   manip2:write_to_map()
   manip2:update_map()
   return true
end

-- moves a ship
local function transport_ship(pos, dif)
   local ps, min, max = get_ship(pos)
   if not ps then
      log("[as_transport] error: hull couldn't become detected, maybe the as is too big or connected to sth")
      return
   end
   local worked = move_ship(dif, ps, min, max)
   if not worked then
      log("[as_transport] error: as couldn't become teleported, maybe you tried to move it into not air nodes")
      return
   end
   log("[as_transport] as succesfully teleported")
   return true
end

minetest.register_node("as_transport:teleport", {
   description = "asirs telwer",
   tiles = {"as_transport.png"},
   groups = {snappy=2},
   on_place = function(_, puncher, pos)
      local t1 = os.clock()
      if not pos
      or not puncher then
         return
      end
      local pos = pos.under
      transport_ship(pos, {x=0, y=20, z=0})
      log(string.format("[as_transport] ended after ca. %.2fs", os.clock() - t1))
   end
})

minetest.log("info", string.format("[as_transport] loaded after ca. %.2fs", os.clock() - load_time_start))

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Wed Mar 25, 2015 21:21

Done&pushed VoxelManip. Can't say they are faster because I have a constant 3-10 second lag on the server (not sure why though, minetest was always super-slow for me since 0.4 was introduced).
 

amadin
Member
 
Posts: 544
Joined: Tue Jun 16, 2015 16:23

Re: [Mod] Flyingships

by amadin » Sat Jan 02, 2016 10:52

I think the good way if player will stay in flying ship and will control it moving.
 

User avatar
DS-minetest
Member
 
Posts: 1117
Joined: Thu Jun 19, 2014 19:49
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
GitHub: DS-Minetest
In-game: DS

Re: [Mod] Flyingships

by DS-minetest » Sun Jan 03, 2016 12:31

I like the mod.
it works very well with u-boats:
Image

but its annoying when you drive with a door, which makes sound on using
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.
 

Minetest4Life
Member
 
Posts: 14
Joined: Fri Oct 24, 2014 23:42

Re: [Mod] Flyingships

by Minetest4Life » Fri Oct 19, 2018 20:42

This mod appears to only move me one block at a time. This means I have to have the key equipped, and right click the motor for each block of movement. I tried hooking up a mesecons switch to the directed motor, and even with the switch turned on, the ship will only move one block. I would then need to flip the switch off an on again for each individual movement.

is this how it was designed to operate? If not, I can load up different versions of Minetest and play around more to try to see what's causing it (i.e. maybe a conflicting Minetest version or mod).

Thank you
 

User avatar
Lone_Wolf
Member
 
Posts: 2215
Joined: Sun Apr 09, 2017 05:50
Location: Hopefully very far from yours, snoop :P
GitHub: LoneWolfHT
IRC: Lone_Wolf
In-game: Lone_Wolf

Re: [Mod] Flyingships

by Lone_Wolf » Sat Oct 20, 2018 04:09

Minetest4Life wrote:This mod appears to only move me one block at a time. This means I have to have the key equipped, and right click the motor for each block of movement. I tried hooking up a mesecons switch to the directed motor, and even with the switch turned on, the ship will only move one block. I would then need to flip the switch off an on again for each individual movement.

is this how it was designed to operate? If not, I can load up different versions of Minetest and play around more to try to see what's causing it (i.e. maybe a conflicting Minetest version or mod).

Thank you

Try hooking up a modified version of this to it
Image
Once you have that set up press the button once to start it. You can increase the blinking speed by lessening the delayer time (Punch it)
Content DB -|- Working on Voxel Knights
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Sat Oct 20, 2018 18:19

Minetest4Life wrote:This mod appears to only move me one block at a time. This means I have to have the key equipped, and right click the motor for each block of movement. I tried hooking up a mesecons switch to the directed motor, and even with the switch turned on, the ship will only move one block. I would then need to flip the switch off an on again for each individual movement.

is this how it was designed to operate? If not, I can load up different versions of Minetest and play around more to try to see what's causing it (i.e. maybe a conflicting Minetest version or mod).

Thank you

It's very slow for me so I did not try to make it go several blocks at a time yet. I have an idea to make it save/load the ship inside some item instead of moving it, but haven't started on that yet.
 

Minetest4Life
Member
 
Posts: 14
Joined: Fri Oct 24, 2014 23:42

Re: [Mod] Flyingships

by Minetest4Life » Mon Oct 29, 2018 18:11

Hey, thanks for the responses. When I have some time, I will play around with it some more, as I had some other ideas I wanted to try.
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Wed Jan 02, 2019 20:29

The get/set versions prooved to be much faster than the voxelmanip one. Ship with 300 nodes moves for 4 seconds, and with get/set -- less than a second. Also cleaned up code a bit, added more messages to clarify when it cannot move, etc.
Here's an example of a tactical ship used to run from monsters or dive into lava/water.
Image
Image
Image
 

User avatar
neko259
Member
 
Posts: 804
Joined: Sun Jun 19, 2011 06:51

Re: [Mod] Flyingships

by neko259 » Wed Jan 02, 2019 20:38

TODO:
* Make it go over liquid
* Continious movement
* Consume fuel
* Lock the configured engine to its key
 


Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 7 guests