Skip to content

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
FatalistError committed Jan 4, 2025
1 parent 14905c4 commit 9043713
Show file tree
Hide file tree
Showing 19 changed files with 543 additions and 148 deletions.
30 changes: 30 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@


# changelog 1.3.0
* #### Established Versioning system
* #### moved the following fields
* `inventory_image_magless` -> `inventory.inventory_image_magless`
* `inventory_image_magless` -> `inventory.inventory_image_magless`
* `firemode_inventory_overlays` - > `inventory.firemode_inventory_overlays`
* `ammo_handler` -> `subclasses.ammo_handler`
* `sprite_scope` -> `subclasses.sprite_scope`
* `crosshair` -> `subclasses.crosshair`
* #### create the following classes
* `Part_handler`
* completed (expansion later)
* facilitates attachments
* `Physics_system`
* inactive
* future implementation for automatic translation
* `Reflector_sight`
* work in progress
* simulates a reflector sight with an entity
* #### added the following changes to the gun class
* made `consts` and `properties` proxy tables for protection of data (and reworked the LEEF class lib for this)
* created a system for property modification
* added `subclasses` property to replace hardcoded subclasses with modular system
* added `subclass_instances` field (see above). These will be automatically updated if their index is in the subclasses list.
* added `visuals.attached_objects` property to define attached entities
* added `attached_objects` field
* made `get_pos` capable of accounting for animation translations

37 changes: 22 additions & 15 deletions classes/Gun-construct.lua
Original file line number Diff line number Diff line change
Expand Up @@ -296,25 +296,32 @@ local function reregister_item(self, props)
end
--accept a chain of indices where the value from old_index overrides new_index
local function warn_deprecation(gun, field, new_field)
minetest.log("warning", "Guns4d: `"..gun.."` deprecated use of field `"..field.."` use `"..new_field.."` instead.")
minetest.log("warning", "Guns4d: `"..gun.."` deprecated use of field `"..field.."` in properties. Use `"..new_field.."` instead.")
end
local function patch_old_gun(self, minor_version)
local function patch_deprecated(self, minor_version)
local props = self.properties
--minor version 2 changes...
if minor_version==2 then
if props.firemode_inventory_overlays then
warn_deprecation(self.name, "firemode_inventory_overlays", "inventory.firemode_inventory_overlays")
for i, _ in pairs(props.firemode_inventory_overlays) do
props.inventory.firemode_inventory_overlays[i] = props.firemode_inventory_overlays[i]
end
--1.2->1.3 (probably missing some.)
if props.firemode_inventory_overlays then
warn_deprecation(self.name, "firemode_inventory_overlays", "inventory.firemode_inventory_overlays")
for i, _ in pairs(props.firemode_inventory_overlays) do
props.inventory.firemode_inventory_overlays[i] = props.firemode_inventory_overlays[i]
end
for _, i in pairs {"ammo_handler", "part_handler", "crosshair", "sprite_scope"} do
if props[i] then
warn_deprecation(self.name, i, "subclasses."..i)
props.subclasses[i] = props[i]
end
end
for _, i in pairs {"ammo_handler", "part_handler", "crosshair", "sprite_scope"} do
if props[i] then
warn_deprecation(self.name, i, "subclasses."..i)
props.subclasses[i] = props[i]
end
end
if self.properties.inventory_image then
self.properties.inventory.inventory_image = self.properties.inventory_image
warn_deprecation(self.name, "inventory_image", "inventory.inventory_image")
end
if self.properties.inventory_image_magless then
self.properties.inventory.inventory_image_magless = self.properties.inventory_image_magless
warn_deprecation(self.name, "inventory_image_magless", "inventory.inventory_image_magless")
end

end
--========================== MAIN CLASS CONSTRUCTOR ===============================

Expand Down Expand Up @@ -352,7 +359,7 @@ function gun_default:construct_base_class()
end
if self.consts.VERSION[2] < 3 then
minetest.log("error", "Guns4d: `"..self.name.."` had minor version before `1.3.0` indicating that this gun likely has no versioning. Attempting patches for `1.2.0`...")
patch_old_gun(self, 2)
patch_deprecated(self, 2)
end

self.properties = leef.class.proxy_table.new(self.properties)
Expand Down
12 changes: 6 additions & 6 deletions classes/Gun-methods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ function gun_default:update_image_and_text_meta(meta)
end
end
--pick the image
local image = self.properties.inventory_image
local image = self.properties.inventory.inventory_image
if (ammo.total_bullets > 0) and not ammo.magazine_psuedo_empty then
image = self.properties.inventory_image
elseif self.properties.inventory_image_magless and ( (ammo.loaded_mag == "empty") or (ammo.loaded_mag == "") or ammo.magazine_psuedo_empty) then
image = self.properties.inventory_image_magless
elseif self.properties.inventory_image_empty then
image = self.properties.inventory_image_empty
image = self.properties.inventory.inventory_image
elseif self.properties.inventory.inventory_image_magless and ( (ammo.loaded_mag == "empty") or (ammo.loaded_mag == "") or ammo.magazine_psuedo_empty) then
image = self.properties.inventory.inventory_image_magless
elseif self.properties.inventory.inventory_image_empty then
image = self.properties.inventory.inventory_image_empty
end
--add the firemode overlay to the image
local firemodes = 0
Expand Down
59 changes: 36 additions & 23 deletions classes/Gun.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
--- Gun class

local Vec = vector

--- Gun class fields
--- class fields
--
-- ## Defining a gun:
--
Expand Down Expand Up @@ -82,27 +80,24 @@ local gun_default = {
-- @field hip `table` @{gun.properties.hip|hipfire properties}
-- @field ads `table` @{gun.properties.ads|aiming ("aiming down sights") properties}
-- @field firemodes `table` @{gun.properties.firemodes|list of firemodes}
-- @field firemode_inventory_overlays `table` @{gun.properties.firemode_inventory_overlays|list of corresponding images for firemodes}
-- @field recoil `table` @{gun.properties.recoil|defines the guns recoil}
-- @field sway `table` @{gun.properties.sway|defines the guns idle sway}
-- @field wag `table` @{gun.properties.wag|defines the movement of the gun while walking}
-- @field charging `table` @{gun.properties.charging|defines how rounds are chambered into the gun}
-- @field ammo `table` @{gun.properties.ammo|defines what ammo the gun uses}
-- @field visuals `table` @{gun.properties.visuals|defines visual attributes of the gun}
-- @field sounds `table` @{gun.properties.sounds|defines sounds to be used by functions of the gun}
-- @field inventory `table` @{gun.properties.inventory|inventory related attributes}
-- @compact
properties = {
--- starting vertical rotation of the gun
--- `float` starting vertical rotation of the gun
initial_vertical_rotation = -60,
--- `float`=.5 max angular deviation (vertical) from breathing
breathing_scale = .5,
--- `vector` the offset from the center of the muzzle flash. Used by fire()
flash_offset = Vec.new(),
--- `int`=600 The number of rounds (cartidges) this gun can throw per minute. Used by update(), fire() and default controls
firerateRPM = 600,
--- `string` inventory image for when the gun has no magazine
inventory_image_magless = nil,
--- `string` inventory image for when the gun is loaded. This is added automatically during construction.
inventory_image = nil,
--- an ordered list of reloading states used by @{default_controls}.
--
-- the default reload states for a magazine operated weapon, copied from the m4.
Expand All @@ -113,7 +108,7 @@ local gun_default = {
-- {action="load", time=.5, anim="load", sounds = {sound="ar_mag_load", delay = .25}},
-- {action="charge", time=.5, anim="charge", sounds={sound="ar_charge", delay = .2}}
reload = {},
--- a table {x1,y1,z1,x2,y2,z2} specifying the bounding box of the model. The first 3 (x1,y1,z1) are the lower of their counterparts. This is autogenerated if not present.
--- `table` (optional) a table `{x1,y1,z1, x2,y2,z2}` specifying the bounding box of the model. The first 3 (x1,y1,z1) are the lower of their counterparts. This is autogenerated from the model when not present, reccomended that you leave nil.
model_bounding_box = nil,
--- `string` overlay on the item to use when infinite ammo is on
infinite_inventory_overlay = "inventory_overlay_inf_ammo.png",
Expand All @@ -137,19 +132,15 @@ local gun_default = {
firemode = Guns4d.default_touch_controls.firemode,
jump_cancel_ads = Guns4d.default_touch_controls.jump_cancel_ads
},
--- properties.inventory
--
-- @table gun.properties.inventory
-- @see lvl1_fields.properties|properties
-- @compact
inventory = {
--[[part_slots = {
underbarrel = {
formspec_inventory_location = {x=0, y=1}
slots = 2,
rail = "picatinny" --only attachments fit for this type will be usable.
allowed = {
"group:guns4d_underbarrel"
},
bone = "" --the bone both to attach to and to display at on the menu.
}
},]]
--- the size in meters to render the gun in it's inventory opened with /guns4d_inv
render_size = 2, --length (in meters) which is visible accross the z/forward axis at y/up=0, x=0. For orthographic this will be the scale of the orthographic camera. Default 2
--- the image of the gun in it's inventory opened with /guns4d_inv
render_image = "m4_ortho.png", --expects an image of the right side of the gun, where the gun is facing the right. Default "m4_ortho.png"
--- table of firemodes and their overlays in the player's inventory when the gun is on that firemode
firemode_inventory_overlays = { --#4
Expand All @@ -162,8 +153,23 @@ local gun_default = {
--safe default: "inventory_overlay_safe.png" (unimplemented firemode)
safe = "inventory_overlay_safe.png"
},
--- `string` (optional) inventory image for when the gun has no magazine
inventory_image_magless = nil,
--- `string` inventory image for when the gun is loaded. This is added automatically during construction.
inventory_image = nil,
--[[part_slots = {
underbarrel = {
formspec_inventory_location = {x=0, y=1}
slots = 2,
rail = "picatinny" --only attachments fit for this type will be usable.
allowed = {
"group:guns4d_underbarrel"
},
bone = "" --the bone both to attach to and to display at on the menu.
}
},]]
},
--- `table` a list of subclasses to create on construct and update. Note special fields `ammo_handler` and `part_handler`.
--- properties.subclasses
--
-- @table gun.properties.subclsses
-- @see lvl1_fields.properties|properties
Expand Down Expand Up @@ -394,8 +400,15 @@ local gun_default = {
fire = {x=0,y=0},
},
},
--- a table of @{guns4d_soundspec|soundspecs} to be referenced by other functions
--- properties.sounds
--
-- other fields are defined by other properties such as @{gun.properties.charging.draw_sound|properties.charging.draw_sound} and @{lvl1_fields.properties.reload|properties.reload}
-- @table gun.properties.sounds
-- @see lvl1_fields.properties|properties
-- @see guns4d_soundspec|soundspec
-- @compact
sounds = { --this does not contain reload sound effects.
--- sound player when firing the weapon
fire = {
{
__replace_old_table=true,
Expand Down
Loading

0 comments on commit 9043713

Please sign in to comment.