Skip to content

Commit

Permalink
Set texture using string.match
Browse files Browse the repository at this point in the history
  • Loading branch information
dievri committed Jan 25, 2021
1 parent d1e2cd3 commit 47af0b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/.init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ local function set_texture(entry, entity)
textures = {texture_prefix .. "-ec2.png"}
})
end

if entry.platform_string == prefix .. "/ec2/describe-instances" then
texture.download("https://www.pinclipart.com/picdir/middle/323-3231192_aws-simple-icons-compute-amazon-ec2-clipart.png", true,
texture_prefix .. "-ec2-instance.png", aws_textures_directory)
entity:set_properties({
visual = "cube",
textures = {texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png"}
})
end

if entry.platform_string:match(string.gsub(prefix .. "/ec2/describe-instances", "%-", "%%%-") .. "/[%d%a%p]+") then
texture.download("https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/AWS_Simple_Icons_AWS_Cloud.svg/1200px-AWS_Simple_Icons_AWS_Cloud.svg.png", true,
texture_prefix .. "-ec2-conf.png", aws_textures_directory)
entity:set_properties({
visual = "sprite",
textures = {texture_prefix .. "-ec2-instance.png"}
textures = {texture_prefix .. "-ec2-conf.png"}
})
end
end
Expand Down
13 changes: 11 additions & 2 deletions values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ fs: |
textures = {texture_prefix .. "-ec2.png"}
})
end
if entry.platform_string == prefix .. "/ec2/describe-instances" then
texture.download("https://www.pinclipart.com/picdir/middle/323-3231192_aws-simple-icons-compute-amazon-ec2-clipart.png", true,
texture_prefix .. "-ec2-instance.png", aws_textures_directory)
entity:set_properties({
visual = "cube",
textures = {texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png", texture_prefix .. "-ec2-instance.png"}
})
end
if entry.platform_string:match(string.gsub(prefix .. "/ec2/describe-instances", "%-", "%%%-") .. "/[%d%a%p]+") then
texture.download("https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/AWS_Simple_Icons_AWS_Cloud.svg/1200px-AWS_Simple_Icons_AWS_Cloud.svg.png", true,
texture_prefix .. "-ec2-conf.png", aws_textures_directory)
entity:set_properties({
visual = "sprite",
textures = {texture_prefix .. "-ec2-instance.png"}
textures = {texture_prefix .. "-ec2-conf.png"}
})
end
end
Expand Down

0 comments on commit 47af0b4

Please sign in to comment.