mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-07-04 14:55:15 +02:00
Replace fake player code with fakelib
(#101)
* replace fake player with fakelib * update luacheck workflow * remove depends.txt and description.txt * mention fakelib in readme
This commit is contained in:
parent
ff0d9bcbad
commit
9697db788f
17
.github/workflows/luacheck.yml
vendored
17
.github/workflows/luacheck.yml
vendored
@ -1,17 +1,10 @@
|
|||||||
name: luacheck
|
name: luacheck
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
luacheck:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- name: Checkout
|
||||||
- name: apt
|
uses: actions/checkout@main
|
||||||
run: sudo apt-get install -y luarocks
|
- name: Luacheck
|
||||||
- name: luacheck install
|
uses: lunarmodules/luacheck@master
|
||||||
run: luarocks install --local luacheck
|
|
||||||
- name: luacheck run
|
|
||||||
run: $HOME/.luarocks/bin/luacheck ./
|
|
||||||
|
20
.luacheckrc
20
.luacheckrc
@ -6,18 +6,20 @@ globals = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
-- Stdlib
|
|
||||||
string = {fields = {"split"}},
|
|
||||||
table = {fields = {"copy", "getn"}},
|
|
||||||
"VoxelManip",
|
|
||||||
|
|
||||||
-- Minetest
|
-- Minetest
|
||||||
"minetest",
|
"minetest",
|
||||||
"vector", "ItemStack",
|
"vector",
|
||||||
"dump", "VoxelArea",
|
"ItemStack",
|
||||||
|
|
||||||
-- Deps
|
-- Mods
|
||||||
"default", "awards", "pipeworks", "hopper", "technic", "doc", "intllib"
|
"default",
|
||||||
|
"awards",
|
||||||
|
"pipeworks",
|
||||||
|
"hopper",
|
||||||
|
"technic",
|
||||||
|
"doc",
|
||||||
|
"intllib",
|
||||||
|
"fakelib",
|
||||||
}
|
}
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
|
@ -29,7 +29,7 @@ Other specialized Digtron blocks include:
|
|||||||
* A light that can be mounted on a Digtron to illuminate the workspace as it moves
|
* A light that can be mounted on a Digtron to illuminate the workspace as it moves
|
||||||
* Structural components to make it look cool
|
* Structural components to make it look cool
|
||||||
|
|
||||||
The Digtron mod only depends on the default mod, but includes optional support for several other mods:
|
The Digtron mod only depends on the default mod and [fakelib](https://content.minetest.net/packages/OgelGames/fakelib/), but includes optional support for several other mods:
|
||||||
|
|
||||||
* [doc](https://forum.minetest.net/viewtopic.php?t=15912), an in-game documentation mod. Detailed documentation for all of the Digtron's individual blocks are included as well as pages of general concepts and design tips.
|
* [doc](https://forum.minetest.net/viewtopic.php?t=15912), an in-game documentation mod. Detailed documentation for all of the Digtron's individual blocks are included as well as pages of general concepts and design tips.
|
||||||
* [pipeworks](https://forum.minetest.net/viewtopic.php?id=2155), a set of pneumatic tubes that allows inventory items to be extracted from or inserted into Digtron inventories.
|
* [pipeworks](https://forum.minetest.net/viewtopic.php?id=2155), a set of pneumatic tubes that allows inventory items to be extracted from or inserted into Digtron inventories.
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
-- The purpose of this class is to have something that can be passed into callbacks that
|
|
||||||
-- demand a "Player" object as a parameter and hopefully prevent the mods that have
|
|
||||||
-- registered with those callbacks from crashing on a nil dereference or bad function
|
|
||||||
-- call. This is not supposed to be a remotely functional thing, it's just supposed
|
|
||||||
-- to provide dummy methods and return values of the correct data type for anything that
|
|
||||||
-- might ignore the false "is_player()" return and go ahead and try to use this thing
|
|
||||||
-- anyway.
|
|
||||||
|
|
||||||
-- I'm trying to patch holes in bad mod programming, essentially. If a mod is so badly
|
|
||||||
-- programmed that it crashes anyway there's not a lot else I can do on my end of things.
|
|
||||||
|
|
||||||
digtron.DigtronFakePlayer = {}
|
|
||||||
digtron.DigtronFakePlayer.__index = digtron.DigtronFakePlayer
|
|
||||||
|
|
||||||
local function return_value(x)
|
|
||||||
return (function() return x end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function return_nil()
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function return_empty_string()
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
local function return_zero()
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local function return_empty_table()
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function digtron.DigtronFakePlayer.update(self, pos, player_name)
|
|
||||||
self.is_fake_player = ":digtron " .. player_name
|
|
||||||
self.get_pos = return_value(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
function digtron.DigtronFakePlayer.create(pos, player_name)
|
|
||||||
local self = {}
|
|
||||||
setmetatable(self, digtron.DigtronFakePlayer)
|
|
||||||
|
|
||||||
self.is_fake_player = ":digtron " .. player_name
|
|
||||||
|
|
||||||
-- ObjectRef
|
|
||||||
self.get_pos = return_value(pos)
|
|
||||||
self.set_pos = return_nil
|
|
||||||
self.move_to = return_nil
|
|
||||||
self.punch = return_nil
|
|
||||||
self.right_click = return_nil
|
|
||||||
self.get_hp = return_value(10)
|
|
||||||
self.set_hp = return_nil
|
|
||||||
self.get_inventory = return_nil -- returns an `InvRef`
|
|
||||||
self.get_wield_list = return_empty_string
|
|
||||||
self.get_wield_index = return_value(1)
|
|
||||||
self.get_wielded_item = return_value(ItemStack(nil))
|
|
||||||
self.set_wielded_item = return_value(false)
|
|
||||||
self.set_armor_groups = return_nil
|
|
||||||
self.get_armor_groups = return_empty_table
|
|
||||||
self.set_animation = return_nil
|
|
||||||
self.get_animation = return_nil -- a set of values, maybe important?
|
|
||||||
self.set_attach = return_nil
|
|
||||||
self.get_attach = return_nil
|
|
||||||
self.set_detach = return_nil
|
|
||||||
self.set_bone_position = return_nil
|
|
||||||
self.get_bone_position = return_nil
|
|
||||||
self.set_properties = return_nil
|
|
||||||
self.get_properties = return_empty_table
|
|
||||||
|
|
||||||
self.is_player = return_value(false)
|
|
||||||
|
|
||||||
self.get_nametag_attributes = return_empty_table
|
|
||||||
self.set_nametag_attributes = return_nil
|
|
||||||
|
|
||||||
--LuaEntitySAO
|
|
||||||
self.set_velocity = return_nil
|
|
||||||
self.get_velocity = return_value({x=0,y=0,z=0})
|
|
||||||
self.set_acceleration = return_nil
|
|
||||||
self.get_acceleration = return_value({x=0,y=0,z=0})
|
|
||||||
self.set_yaw = return_nil
|
|
||||||
self.get_yaw = return_zero
|
|
||||||
self.set_texture_mod = return_nil
|
|
||||||
self.get_texture_mod = return_nil -- maybe important?
|
|
||||||
self.set_sprite = return_nil
|
|
||||||
--self.get_entity_name` (**Deprecated**: Will be removed in a future version)
|
|
||||||
self.get_luaentity = return_nil
|
|
||||||
|
|
||||||
-- Player object
|
|
||||||
self.get_player_name = return_empty_string
|
|
||||||
self.get_player_velocity = return_nil
|
|
||||||
self.get_look_dir = return_value({x=0,y=1,z=0})
|
|
||||||
self.get_look_horizontal = return_zero
|
|
||||||
self.set_look_horizontal = return_nil
|
|
||||||
self.get_look_vertical = return_zero
|
|
||||||
self.set_look_vertical = return_nil
|
|
||||||
|
|
||||||
--self.get_look_pitch`: pitch in radians - Deprecated as broken. Use `get_look_vertical`
|
|
||||||
--self.get_look_yaw`: yaw in radians - Deprecated as broken. Use `get_look_horizontal`
|
|
||||||
--self.set_look_pitch(radians)`: sets look pitch - Deprecated. Use `set_look_vertical`.
|
|
||||||
--self.set_look_yaw(radians)`: sets look yaw - Deprecated. Use `set_look_horizontal`.
|
|
||||||
self.get_breath = return_value(10)
|
|
||||||
self.set_breath = return_nil
|
|
||||||
self.get_attribute = return_nil
|
|
||||||
self.set_attribute = return_nil
|
|
||||||
|
|
||||||
self.set_inventory_formspec = return_nil
|
|
||||||
self.get_inventory_formspec = return_empty_string
|
|
||||||
self.get_player_control = return_value({jump=false, right=false, left=false, LMB=false, RMB=false, sneak=false, aux1=false, down=false, up=false} )
|
|
||||||
self.get_player_control_bits = return_zero
|
|
||||||
|
|
||||||
self.set_physics_override = return_nil
|
|
||||||
self.get_physics_override = return_value({speed = 1, jump = 1, gravity = 1, sneak = true, sneak_glitch = false, new_move = true,})
|
|
||||||
|
|
||||||
self.hud_add = return_nil
|
|
||||||
self.hud_remove = return_nil
|
|
||||||
self.hud_change = return_nil
|
|
||||||
self.hud_get = return_nil -- possibly important return value?
|
|
||||||
self.hud_set_flags = return_nil
|
|
||||||
self.hud_get_flags = return_value({ hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true, minimap=true })
|
|
||||||
self.hud_set_hotbar_itemcount = return_nil
|
|
||||||
self.hud_get_hotbar_itemcount = return_zero
|
|
||||||
self.hud_set_hotbar_image = return_nil
|
|
||||||
self.hud_get_hotbar_image = return_empty_string
|
|
||||||
self.hud_set_hotbar_selected_image = return_nil
|
|
||||||
self.hud_get_hotbar_selected_image = return_empty_string
|
|
||||||
self.set_sky = return_nil
|
|
||||||
self.get_sky = return_empty_table -- may need members on this table
|
|
||||||
|
|
||||||
self.set_clouds = return_nil
|
|
||||||
self.get_clouds = return_value({density = 0, color = "#fff0f0e5", ambient = "#000000", height = 120, thickness = 16, speed = {x=0, y=-2}})
|
|
||||||
|
|
||||||
self.override_day_night_ratio = return_nil
|
|
||||||
self.get_day_night_ratio = return_nil
|
|
||||||
|
|
||||||
self.set_local_animation = return_nil
|
|
||||||
self.get_local_animation = return_empty_table
|
|
||||||
|
|
||||||
self.set_eye_offset = return_nil
|
|
||||||
self.get_eye_offset = return_value({x=0,y=0,z=0},{x=0,y=0,z=0})
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
@ -490,7 +490,7 @@ function digtron.DigtronLayout.write_layout_image(self, player)
|
|||||||
|
|
||||||
-- fake_player will be passed to callbacks to prevent actual player from "taking the blame" for this action.
|
-- fake_player will be passed to callbacks to prevent actual player from "taking the blame" for this action.
|
||||||
-- For example, the hunger mod shouldn't be making the player hungry when he moves Digtron.
|
-- For example, the hunger mod shouldn't be making the player hungry when he moves Digtron.
|
||||||
digtron.fake_player:update(self.controller, player:get_player_name())
|
digtron.fake_player:set_pos(self.controller)
|
||||||
-- note that the actual player is still passed to the per-node after_place_node and after_dig_node, should they exist.
|
-- note that the actual player is still passed to the per-node after_place_node and after_dig_node, should they exist.
|
||||||
node_callbacks(player)
|
node_callbacks(player)
|
||||||
dug_nodes_count = 0
|
dug_nodes_count = 0
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
default
|
|
||||||
pipeworks?
|
|
||||||
doc?
|
|
||||||
hopper?
|
|
||||||
awards?
|
|
||||||
catacomb?
|
|
||||||
intllib?
|
|
||||||
technic?
|
|
@ -1,5 +0,0 @@
|
|||||||
digtron - a modular tunnel boring/building machine for minetest, v0.7.6 - 2017-01-22
|
|
||||||
|
|
||||||
Forum : https://forum.minetest.net/viewtopic.php?t=16295
|
|
||||||
Github: https://github.com/FaceDeer/digtron/
|
|
||||||
Wiki: http://wiki.minetest.net/Mods/digtron
|
|
4
init.lua
4
init.lua
@ -42,10 +42,8 @@ digtron.builder_on_place_prefixes = {
|
|||||||
|
|
||||||
local digtron_modpath = minetest.get_modpath( "digtron" )
|
local digtron_modpath = minetest.get_modpath( "digtron" )
|
||||||
|
|
||||||
dofile( digtron_modpath .. "/class_fakeplayer.lua")
|
|
||||||
|
|
||||||
-- since we only need one fake player at a time and it doesn't retain useful state, create a global one and just update it as needed.
|
-- since we only need one fake player at a time and it doesn't retain useful state, create a global one and just update it as needed.
|
||||||
digtron.fake_player = digtron.DigtronFakePlayer.create({x=0,y=0,z=0}, "fake_player")
|
digtron.fake_player = fakelib.create_player()
|
||||||
|
|
||||||
dofile( digtron_modpath .. "/config.lua" )
|
dofile( digtron_modpath .. "/config.lua" )
|
||||||
dofile( digtron_modpath .. "/util.lua" )
|
dofile( digtron_modpath .. "/util.lua" )
|
||||||
|
2
mod.conf
2
mod.conf
@ -2,7 +2,7 @@ name = digtron
|
|||||||
title = Digtron
|
title = Digtron
|
||||||
author = FaceDeer
|
author = FaceDeer
|
||||||
description = Adds components for building modular tunnel boring machines.
|
description = Adds components for building modular tunnel boring machines.
|
||||||
depends = default
|
depends = default, fakelib
|
||||||
optional_depends = pipeworks, doc, hopper, awards, catacomb, intllib, technic
|
optional_depends = pipeworks, doc, hopper, awards, catacomb, intllib, technic
|
||||||
license = MIT, LGPL 2.1 or later
|
license = MIT, LGPL 2.1 or later
|
||||||
forum = https://forum.minetest.net/viewtopic.php?t=16295
|
forum = https://forum.minetest.net/viewtopic.php?t=16295
|
||||||
|
Loading…
Reference in New Issue
Block a user