summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.luacheckrc10
-rw-r--r--LICENSE24
-rw-r--r--init.lua128
-rw-r--r--mod.conf4
4 files changed, 166 insertions, 0 deletions
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..d57e796
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,10 @@
+max_line_length = 160
+
+globals = {
+ "core",
+}
+
+read_globals = {
+ "vector",
+ "carts",
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..088f66d
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,128 @@
+local markers = {
+ "streets:mark_white_parking",
+ "streets:mark_yellow_parking",
+ "streets:mark_white_parking_on_asphalt",
+ "streets:mark_yellow_parking_on_asphalt",
+ "streets:micro_white_parking_1",
+ "streets:panel_white_parking_1",
+ "streets:micro_white_parking_2",
+ "streets:panel_white_parking_2",
+ "streets:micro_white_parking_4",
+ "streets:panel_white_parking_4",
+ "streets:micro_white_parking",
+ "streets:panel_white_parking",
+ "streets:micro_white_parking_12",
+ "streets:panel_white_parking_12",
+ "streets:micro_white_parking_14",
+ "streets:panel_white_parking_14",
+ "streets:micro_white_parking_15",
+ "streets:panel_white_parking_15",
+ "streets:stair_white_parking_outer",
+ "streets:stair_white_parking",
+ "streets:stair_white_parking_inner",
+ "streets:slab_white_parking_1",
+ "streets:slab_white_parking_2",
+ "streets:slab_white_parking_quarter",
+ "streets:slab_white_parking",
+ "streets:slab_white_parking_three_quarter",
+ "streets:slab_white_parking_14",
+ "streets:slab_white_parking_15",
+ "streets:slab_white_parking_two_sides",
+ "streets:slab_white_parking_three_sides",
+ "streets:slab_white_parking_three_sides_u",
+ "streets:stair_white_parking_half",
+ "streets:stair_white_parking_alt_1",
+ "streets:stair_white_parking_alt_2",
+ "streets:stair_white_parking_alt_4",
+ "streets:stair_white_parking_alt",
+ "streets:slope_white_parking",
+ "streets:slope_white_parking_half",
+ "streets:slope_white_parking_half_raised",
+ "streets:slope_white_parking_inner",
+ "streets:slope_white_parking_inner_half",
+ "streets:slope_white_parking_inner_half_raised",
+ "streets:slope_white_parking_inner_cut",
+ "streets:slope_white_parking_inner_cut_half",
+ "streets:slope_white_parking_inner_cut_half_raised",
+ "streets:slope_white_parking_outer",
+ "streets:slope_white_parking_outer_half",
+ "streets:slope_white_parking_outer_half_raised",
+ "streets:slope_white_parking_outer_cut",
+ "streets:slope_white_parking_outer_cut_half",
+ "streets:slope_white_parking_outer_cut_half_raised",
+ "streets:slope_white_parking_cut",
+ "streets:micro_yellow_parking_1",
+ "streets:panel_yellow_parking_1",
+ "streets:micro_yellow_parking_2",
+ "streets:panel_yellow_parking_2",
+ "streets:micro_yellow_parking_4",
+ "streets:panel_yellow_parking_4",
+ "streets:micro_yellow_parking",
+ "streets:panel_yellow_parking",
+ "streets:micro_yellow_parking_12",
+ "streets:panel_yellow_parking_12",
+ "streets:micro_yellow_parking_14",
+ "streets:panel_yellow_parking_14",
+ "streets:micro_yellow_parking_15",
+ "streets:panel_yellow_parking_15",
+ "streets:stair_yellow_parking_outer",
+ "streets:stair_yellow_parking",
+ "streets:stair_yellow_parking_inner",
+ "streets:slab_yellow_parking_1",
+ "streets:slab_yellow_parking_2",
+ "streets:slab_yellow_parking_quarter",
+ "streets:slab_yellow_parking",
+ "streets:slab_yellow_parking_three_quarter",
+ "streets:slab_yellow_parking_14",
+ "streets:slab_yellow_parking_15",
+ "streets:slab_yellow_parking_two_sides",
+ "streets:slab_yellow_parking_three_sides",
+ "streets:slab_yellow_parking_three_sides_u",
+ "streets:stair_yellow_parking_half",
+ "streets:stair_yellow_parking_alt_1",
+ "streets:stair_yellow_parking_alt_2",
+ "streets:stair_yellow_parking_alt_4",
+ "streets:stair_yellow_parking_alt",
+ "streets:slope_yellow_parking",
+ "streets:slope_yellow_parking_half",
+ "streets:slope_yellow_parking_half_raised",
+ "streets:slope_yellow_parking_inner",
+ "streets:slope_yellow_parking_inner_half",
+ "streets:slope_yellow_parking_inner_half_raised",
+ "streets:slope_yellow_parking_inner_cut",
+ "streets:slope_yellow_parking_inner_cut_half",
+ "streets:slope_yellow_parking_inner_cut_half_raised",
+ "streets:slope_yellow_parking_outer",
+ "streets:slope_yellow_parking_outer_half",
+ "streets:slope_yellow_parking_outer_half_raised",
+ "streets:slope_yellow_parking_outer_cut",
+ "streets:slope_yellow_parking_outer_cut_half",
+ "streets:slope_yellow_parking_outer_cut_half_raised",
+ "streets:slope_yellow_parking_cut",
+ "extra_street_signs:sign_eu_parking_site",
+}
+
+for _,v in ipairs(markers) do
+ if core.registered_nodes[v] then
+ local groups = core.registered_nodes[v].groups or {}
+ groups.parking = 1
+ core.override_item(v,{groups=groups})
+ end
+end
+
+for _,mod in ipairs({"vehicle_mash","motorbike","bike","ufos"}) do
+ for k,v in pairs(core.registered_entities) do
+ if string.sub(k,1,string.len(mod)) == mod then
+ local oldactivate = v.on_activate or function() end
+ v.on_activate = function(self,staticdata,dtime,...)
+ oldactivate(self,staticdata,dtime,...)
+ if dtime < 10 then return end
+ local obj = self.object
+ local pos = vector.round(obj:get_pos())
+ local maxradius = tonumber(core.settings:get("cars_despawn.search_radius") or 8) or 8
+ local parked = core.find_node_near(pos,maxradius,"group:parking",true)
+ if not parked then obj:remove() end
+ end
+ end
+ end
+end
diff --git a/mod.conf b/mod.conf
new file mode 100644
index 0000000..aca9b80
--- /dev/null
+++ b/mod.conf
@@ -0,0 +1,4 @@
+name = cars_despawn
+description = Automatically despawns vehicles when unattended and not in a parking space
+optional_depends = vehicle_mash,motorbike,bike,labels,ufos
+author = cheapie