mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
testing with texture modifiers
This commit is contained in:
parent
fd724f5b9e
commit
3f84d1d11c
11 changed files with 123 additions and 6 deletions
|
@ -418,8 +418,7 @@ function airutils.logic(self)
|
||||||
|
|
||||||
local indicated_speed = longit_speed * 0.9
|
local indicated_speed = longit_speed * 0.9
|
||||||
if indicated_speed < 0 then indicated_speed = 0 end
|
if indicated_speed < 0 then indicated_speed = 0 end
|
||||||
local speed_angle = airutils.get_gauge_angle(indicated_speed, -45)
|
self._indicated_speed = indicated_speed
|
||||||
--self.speed_gauge:set_attach(self.object,'',ALBATROS_D5_GAUGE_SPEED_POSITION,{x=0,y=0,z=speed_angle})
|
|
||||||
|
|
||||||
--adjust power indicator
|
--adjust power indicator
|
||||||
local power_indicator_angle = airutils.get_gauge_angle(self._power_lever/10)
|
local power_indicator_angle = airutils.get_gauge_angle(self._power_lever/10)
|
||||||
|
@ -454,6 +453,11 @@ function airutils.logic(self)
|
||||||
self.object:set_bone_position("aileron.r", self._aileron_r_pos, {x=-self._rudder_angle - 90,y=0,z=0})
|
self.object:set_bone_position("aileron.r", self._aileron_r_pos, {x=-self._rudder_angle - 90,y=0,z=0})
|
||||||
self.object:set_bone_position("aileron.l", self._aileron_l_pos, {x=self._rudder_angle - 90,y=0,z=0})
|
self.object:set_bone_position("aileron.l", self._aileron_l_pos, {x=self._rudder_angle - 90,y=0,z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self._custom_step_additional_function then
|
||||||
|
self._custom_step_additional_function(self)
|
||||||
|
end
|
||||||
|
|
||||||
--set stick position
|
--set stick position
|
||||||
if self.stick then
|
if self.stick then
|
||||||
self.stick:set_attach(self.object,'',self._stick_pos,{x=self._elevator_angle/2,y=0,z=self._rudder_angle})
|
self.stick:set_attach(self.object,'',self._stick_pos,{x=self._elevator_angle/2,y=0,z=self._rudder_angle})
|
||||||
|
@ -563,7 +567,7 @@ function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
||||||
if itmstck then
|
if itmstck then
|
||||||
if airutils.set_param_paint(self, puncher, itmstck, 1) == false then
|
if airutils.set_param_paint(self, puncher, itmstck, 1) == false then
|
||||||
if not self.driver and toolcaps and toolcaps.damage_groups
|
if not self.driver and toolcaps and toolcaps.damage_groups
|
||||||
and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then
|
and toolcaps.groupcaps and toolcaps.groupcaps.choppy and item_name ~= airutils.fuel then
|
||||||
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
||||||
--airutils.make_sound(self,'hit')
|
--airutils.make_sound(self,'hit')
|
||||||
damage_vehicle(self, toolcaps, ttime, damage)
|
damage_vehicle(self, toolcaps, ttime, damage)
|
||||||
|
|
|
@ -19,10 +19,10 @@ function airutils.loadFuel(self, player_name)
|
||||||
if fuel then
|
if fuel then
|
||||||
local stack = ItemStack(item_name .. " 1")
|
local stack = ItemStack(item_name .. " 1")
|
||||||
|
|
||||||
if self._energy < 10 then
|
if self._energy < self._max_fuel then
|
||||||
inv:remove_item("main", stack)
|
inv:remove_item("main", stack)
|
||||||
self._energy = self._energy + fuel
|
self._energy = self._energy + fuel
|
||||||
if self._energy > 10 then self._energy = 10 end
|
if self._energy > self._max_fuel then self._energy = self._max_fuel end
|
||||||
|
|
||||||
local energy_indicator_angle = airutils.get_gauge_angle(self._energy)
|
local energy_indicator_angle = airutils.get_gauge_angle(self._energy)
|
||||||
--self.fuel_gauge:set_attach(self.object,'',self._gauge_fuel_position,{x=0,y=0,z=energy_indicator_angle})
|
--self.fuel_gauge:set_attach(self.object,'',self._gauge_fuel_position,{x=0,y=0,z=energy_indicator_angle})
|
||||||
|
|
113
lib_planes/gauges.lua
Normal file
113
lib_planes/gauges.lua
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
local function get_pointer(pointer_angle, gauge_center_x, gauge_center_y, full_pointer)
|
||||||
|
full_pointer = full_pointer or 1
|
||||||
|
local retval = ""
|
||||||
|
local ind_pixel = "airutils_ind_box_2.png"
|
||||||
|
|
||||||
|
pointer_img_size = 8
|
||||||
|
local pointer_rad = math.rad(pointer_angle)
|
||||||
|
local dim = 2*(pointer_img_size/2)
|
||||||
|
local pos_x = math.sin(pointer_rad) * dim
|
||||||
|
local pos_y = math.cos(pointer_rad) * dim
|
||||||
|
retval = retval..(gauge_center_x+pos_x)..","..(gauge_center_y+pos_y).."="..ind_pixel..":"
|
||||||
|
|
||||||
|
dim = 4*(pointer_img_size/2)
|
||||||
|
pos_x = math.sin(pointer_rad) * dim
|
||||||
|
pos_y = math.cos(pointer_rad) * dim
|
||||||
|
retval = retval..(gauge_center_x+pos_x)..","..(gauge_center_y+pos_y).."="..ind_pixel..":"
|
||||||
|
|
||||||
|
dim = 6*(pointer_img_size/2)
|
||||||
|
pos_x = math.sin(pointer_rad) * dim
|
||||||
|
pos_y = math.cos(pointer_rad) * dim
|
||||||
|
retval = retval..(gauge_center_x+pos_x)..","..(gauge_center_y+pos_y).."="..ind_pixel..":"
|
||||||
|
|
||||||
|
if full_pointer == 1 then
|
||||||
|
dim = 8*(pointer_img_size/2)
|
||||||
|
pos_x = math.sin(pointer_rad) * dim
|
||||||
|
pos_y = math.cos(pointer_rad) * dim
|
||||||
|
retval = retval..(gauge_center_x+pos_x)..","..(gauge_center_y+pos_y).."="..ind_pixel..":"
|
||||||
|
|
||||||
|
dim = 10*(pointer_img_size/2)
|
||||||
|
pos_x = math.sin(pointer_rad) * dim
|
||||||
|
pos_y = math.cos(pointer_rad) * dim
|
||||||
|
retval = retval..(gauge_center_x+pos_x)..","..(gauge_center_y+pos_y).."="..ind_pixel..":"
|
||||||
|
end
|
||||||
|
return retval
|
||||||
|
end
|
||||||
|
|
||||||
|
function airutils.plot_altimeter_gauge(self, scale, height, place_x, place_y)
|
||||||
|
local bg_width_height = 100
|
||||||
|
local pointer_img = 8
|
||||||
|
local gauge_center = (bg_width_height / 2) - (pointer_img/2)
|
||||||
|
local gauge_center_x = place_x + gauge_center
|
||||||
|
local gauge_center_y = place_y + gauge_center
|
||||||
|
|
||||||
|
|
||||||
|
--altimeter
|
||||||
|
local altitude = (height / 0.32) / 100
|
||||||
|
local hour, minutes = math.modf( altitude )
|
||||||
|
hour = math.fmod (hour, 10)
|
||||||
|
minutes = minutes * 100
|
||||||
|
minutes = (minutes * 100) / 100
|
||||||
|
local minute_angle = (minutes*-360)/100
|
||||||
|
local hour_angle = (hour*-360)/10 + ((minute_angle*36)/360)
|
||||||
|
|
||||||
|
--[[
|
||||||
|
#### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
|
||||||
|
|
||||||
|
* `<w>`: width
|
||||||
|
* `<h>`: height
|
||||||
|
* `<x>`: x position
|
||||||
|
* `<y>`: y position
|
||||||
|
* `<file>`: texture to combine
|
||||||
|
|
||||||
|
Creates a texture of size `<w>` times `<h>` and blits the listed files to their
|
||||||
|
specified coordinates.
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
local altimeter = "^[resize:"..scale.."x"..scale.."^[combine:"..bg_width_height.."x"..bg_width_height..":"
|
||||||
|
..place_x..","..place_y.."=airutils_altimeter_gauge.png:"
|
||||||
|
|
||||||
|
altimeter = altimeter..get_pointer(minute_angle+180, gauge_center_x, gauge_center_y, 1)
|
||||||
|
altimeter = altimeter..get_pointer(hour_angle+180, gauge_center_x, gauge_center_y, 0)
|
||||||
|
|
||||||
|
return altimeter
|
||||||
|
end
|
||||||
|
|
||||||
|
function airutils.plot_fuel_gauge(self, scale, curr_level, max_level, place_x, place_y)
|
||||||
|
local bg_width_height = 100
|
||||||
|
local pointer_img = 8
|
||||||
|
local gauge_center = (bg_width_height / 2) - (pointer_img/2)
|
||||||
|
local gauge_center_x = place_x + gauge_center
|
||||||
|
local gauge_center_y = place_y + gauge_center
|
||||||
|
|
||||||
|
local fuel_percentage = (curr_level*100)/max_level
|
||||||
|
local fuel_angle = -(fuel_percentage*180)/100
|
||||||
|
--minetest.chat_send_all(dump(fuel_angle))
|
||||||
|
|
||||||
|
local fuel = "^[resize:"..scale.."x"..scale.."^[combine:"..bg_width_height.."x"..bg_width_height..":"
|
||||||
|
..place_x..","..place_y.."=airutils_fuel_gauge.png:"
|
||||||
|
|
||||||
|
fuel = fuel..get_pointer(fuel_angle-90, gauge_center_x, gauge_center_y, 1)
|
||||||
|
|
||||||
|
return fuel
|
||||||
|
end
|
||||||
|
|
||||||
|
function airutils.plot_speed_gauge(self, scale, curr_level, max_level, place_x, place_y)
|
||||||
|
local bg_width_height = 100
|
||||||
|
local pointer_img = 8
|
||||||
|
local gauge_center = (bg_width_height / 2) - (pointer_img/2)
|
||||||
|
local gauge_center_x = place_x + gauge_center
|
||||||
|
local gauge_center_y = place_y + gauge_center
|
||||||
|
|
||||||
|
local speed_percentage = (curr_level*100)/max_level
|
||||||
|
local speed_angle = -(speed_percentage*350)/100
|
||||||
|
--minetest.chat_send_all(dump(fuel_angle))
|
||||||
|
|
||||||
|
local fuel = "^[resize:"..scale.."x"..scale.."^[combine:"..bg_width_height.."x"..bg_width_height..":"
|
||||||
|
..place_x..","..place_y.."=airutils_speed_gauge.png:"
|
||||||
|
|
||||||
|
fuel = fuel..get_pointer(speed_angle-180, gauge_center_x, gauge_center_y, 1)
|
||||||
|
|
||||||
|
return fuel
|
||||||
|
end
|
|
@ -7,6 +7,7 @@ dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELI
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "utilities.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "utilities.lua")
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "entities.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "entities.lua")
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "forms.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "forms.lua")
|
||||||
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "gauges.lua")
|
||||||
|
|
||||||
--
|
--
|
||||||
-- helpers and co.
|
-- helpers and co.
|
||||||
|
|
|
@ -146,7 +146,6 @@ function airutils.checkAttach(self, player)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- destroy the boat
|
|
||||||
function airutils.destroy(self, effects)
|
function airutils.destroy(self, effects)
|
||||||
effects = effects or false
|
effects = effects or false
|
||||||
if self.sound_handle then
|
if self.sound_handle then
|
||||||
|
|
BIN
textures/airutils_altimeter_gauge.png
Normal file
BIN
textures/airutils_altimeter_gauge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
textures/airutils_fuel_gauge.png
Normal file
BIN
textures/airutils_fuel_gauge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
textures/airutils_gauge_bg.png
Normal file
BIN
textures/airutils_gauge_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
textures/airutils_ind_box_2.png
Normal file
BIN
textures/airutils_ind_box_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
textures/airutils_speed_gauge.png
Normal file
BIN
textures/airutils_speed_gauge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
BIN
textures/gauge_bg.xcf
Normal file
BIN
textures/gauge_bg.xcf
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue