diff --git a/control.lua b/control.lua index 50b6e53..5b26dcd 100755 --- a/control.lua +++ b/control.lua @@ -52,15 +52,19 @@ function steampunk_blimp.control(self, dtime, hull_direction, longit_speed, acce if self.anchored == false then local factor = 1 if ctrl.up then - steampunk_blimp.powerAdjust(self, dtime, factor, 1) - --self.object:set_animation_frame_speed(40) + local can_acc = true + if self._power_lever >= 82 then can_acc = false end + if ctrl.aux1 then can_acc = true end + if can_acc then + steampunk_blimp.powerAdjust(self, dtime, factor, 1) + end elseif ctrl.down then steampunk_blimp.powerAdjust(self, dtime, factor, -1) - --self.object:set_animation_frame_speed(-40) else --self.object:set_animation_frame_speed(steampunk_blimp.iddle_rotation) end end + if not ctrl.aux1 and self._power_lever < 0 then self._power_lever = 0 end self._is_going_up = false if ctrl.jump then @@ -91,18 +95,6 @@ function steampunk_blimp.control(self, dtime, hull_direction, longit_speed, acce if longit_speed > max_speed then engineacc = engineacc - (longit_speed-max_speed) end - if engineacc < 0 then - local is_reversed = false - if ctrl then - if ctrl.aux1 then - is_reversed = true - end - end - if is_reversed == false then - engineacc = 0 - self._power_lever = 0 - end - end if engineacc ~= nil then retval_accel=vector.add(accel,vector.multiply(hull_direction,engineacc)) diff --git a/engine_management.lua b/engine_management.lua index af5c159..8c5175a 100644 --- a/engine_management.lua +++ b/engine_management.lua @@ -85,7 +85,8 @@ function steampunk_blimp.engine_step(self, accel) local pressure = steampunk_blimp.get_pointer_angle(self._boiler_pressure, 200 ) local water = steampunk_blimp.get_pointer_angle(self._water_level, steampunk_blimp.MAX_WATER) local coal = self._energy - steampunk_blimp.update_hud(player, coal, 180-water, -pressure) + --minetest.chat_send_all(self._power_lever) + steampunk_blimp.update_hud(player, coal, 180-water, -pressure, self._power_lever) end end diff --git a/hud.lua b/hud.lua index 8399f58..ff3d668 100755 --- a/hud.lua +++ b/hud.lua @@ -35,7 +35,7 @@ function steampunk_blimp.animate_gauge(player, ids, prefix, x, y, angle) player:hud_change(ids[prefix .. "7"], "offset", {x = pos_x + x, y = pos_y + y}) end -function steampunk_blimp.update_hud(player, coal, water, pressure) +function steampunk_blimp.update_hud(player, coal, water, pressure, power_lever) local player_name = player:get_player_name() local screen_pos_y = -100 @@ -49,6 +49,8 @@ function steampunk_blimp.update_hud(player, coal, water, pressure) local coal_1_y = screen_pos_y local coal_2_x = coal_1_x + 60 local coal_2_y = screen_pos_y + local throttle_x = screen_pos_x + 395 + local throttle_y = screen_pos_y + 45 local ids = steampunk_blimp.hud_list[player_name] if ids then @@ -57,6 +59,9 @@ function steampunk_blimp.update_hud(player, coal, water, pressure) if coal_value < 0 then coal_value = 0 end player:hud_change(ids["coal_1"], "text", "steampunk_blimp_"..(math.floor(coal_value/10))..".png") player:hud_change(ids["coal_2"], "text", "steampunk_blimp_"..(math.floor(coal_value%10))..".png") + + player:hud_change(ids["throttle"], "offset", {x = throttle_x, y = throttle_y - power_lever}) + steampunk_blimp.animate_gauge(player, ids, "water_pt_", water_gauge_x, water_gauge_y, water) steampunk_blimp.animate_gauge(player, ids, "press_pt_", press_gauge_x, press_gauge_y, pressure) else @@ -99,6 +104,15 @@ function steampunk_blimp.update_hud(player, coal, water, pressure) alignment = { x = 1, y = 0 }, }) + ids["throttle"] = player:hud_add({ + hud_elem_type = "image", + position = {x = 0, y = 1}, + offset = {x = throttle_x, y = throttle_y}, + text = "steampunk_blimp_throttle.png", + scale = { x = 0.5, y = 0.5}, + alignment = { x = 1, y = 0 }, + }) + ids["water_pt_1"] = player:hud_add({ hud_elem_type = "image", position = {x = 0, y = 1}, @@ -231,6 +245,7 @@ function steampunk_blimp.remove_hud(player) player:hud_remove(ids["bg"]) player:hud_remove(ids["coal_1"]) player:hud_remove(ids["coal_2"]) + player:hud_remove(ids["throttle"]) player:hud_remove(ids["water_pt_7"]) player:hud_remove(ids["water_pt_6"]) player:hud_remove(ids["water_pt_5"]) diff --git a/textures/steampunk_blimp_hud_panel.png b/textures/steampunk_blimp_hud_panel.png index ae969ad..a36a6db 100755 Binary files a/textures/steampunk_blimp_hud_panel.png and b/textures/steampunk_blimp_hud_panel.png differ diff --git a/textures/steampunk_blimp_hud_panel.xcf b/textures/steampunk_blimp_hud_panel.xcf index 243204c..f29c076 100644 Binary files a/textures/steampunk_blimp_hud_panel.xcf and b/textures/steampunk_blimp_hud_panel.xcf differ diff --git a/textures/steampunk_blimp_throttle.png b/textures/steampunk_blimp_throttle.png new file mode 100644 index 0000000..b40c33d Binary files /dev/null and b/textures/steampunk_blimp_throttle.png differ