mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Add startable legacy code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
local Color = require 'utils.color_presets' --- @dep utils.color_presets
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
local Game = {}
|
||||
|
||||
--[[ Note to readers
|
||||
@@ -38,72 +38,4 @@ function Game.get_player_from_any(obj)
|
||||
end
|
||||
end
|
||||
|
||||
--- Prints to player or console.
|
||||
-- @param str <string|table> table if locale is used
|
||||
-- @param color <table> defaults to white
|
||||
function Game.player_print(str, color)
|
||||
color = color or Color.white
|
||||
if game.player then
|
||||
game.player.print(str, color)
|
||||
else
|
||||
print(str)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Creates a floating text entity at a location with the specified color.
|
||||
Example: "+10 iron" or "-10 coins"
|
||||
|
||||
@param surface LuaSurface
|
||||
@param position String to display at
|
||||
@param text String to display
|
||||
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
||||
|
||||
@return the created entity
|
||||
]]
|
||||
function Game.print_floating_text(surface, position, text, color)
|
||||
color = color or Color.white
|
||||
|
||||
return surface.create_entity {
|
||||
name = 'tutorial-flying-text',
|
||||
color = color,
|
||||
text = text,
|
||||
position = position
|
||||
}
|
||||
end
|
||||
|
||||
--[[
|
||||
Creates a floating text entity at the player location with the specified color and offset.
|
||||
Example: "+10 iron" or "-10 coins"
|
||||
|
||||
@param text String to display
|
||||
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
||||
@param x_offset number the x offset for the floating text
|
||||
@param y_offset number the y offset for the floating text
|
||||
|
||||
@return the created entity
|
||||
]]
|
||||
function Game.print_player_floating_text_position(player, text, color, x_offset, y_offset)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
return Game.print_floating_text(player.surface, {x = position.x + x_offset, y = position.y + y_offset}, text, color)
|
||||
end
|
||||
|
||||
--[[
|
||||
Creates a floating text entity at the player location with the specified color in {r, g, b} format.
|
||||
Example: "+10 iron" or "-10 coins"
|
||||
|
||||
@param text String to display
|
||||
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
||||
|
||||
@return the created entity
|
||||
]]
|
||||
function Game.print_player_floating_text(player, text, color)
|
||||
Game.print_player_floating_text_position(player, text, color, 0, -1.5)
|
||||
end
|
||||
|
||||
return Game
|
||||
Reference in New Issue
Block a user