Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for extended tip image #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Lemonymous
Copy link
Contributor

@Lemonymous Lemonymous commented Jul 20, 2023

Adds support for additional keywords in weapons' TipImage.

e.g

MySkill = Skill:new{
	TipImage = {
		Sand = Point(1,1),
	}
}

New supported keywords:

(This PR was made very quickly, so this is not a complete list of keywords that the vanilla game don't support. Feel free to mention other missing keywords)

  • Shield
  • Sand
  • Ice
  • Frozen
  • Snow

To have multiple features with the same key, the keyword can be suffixed with numbers.

TipImage Callbacks

This feature allows the optional definiton of a TipImageCallbacks table for a weapon, which associates specific elements in the weapon's TipImage table to callback functions in TipImageCallbacks.

Example:

TipImageCallbacks = {
	BuildingSmall = function(loc)
		Board:SetTerrain(loc, TERRAIN_BUILDING)
		Board:SetHealth(loc, 2, 2)
	end,
	BuildingDamaged = function(loc)
		Board:SetTerrain(loc, TERRAIN_BUILDING)
		Board:SetHealth(loc, 1, 2)
	end,
}

This example shows a TipImageCallbacks table with two custom callbacks that can be referenced by the weapon's TipImage; either by the same name or the name with a numbered suffix.

 

Example Weapon:

MySkill = Skill:new{
	Name = "MySkill",
	Description = "MyDescription",
	TipImage = {
		Unit = Point(1,1),
		Enemy = Point(1,2),
		Target = Point(1,2),
		StructureSmall = Point(2,1),
		StructureDamaged = Point(2,2),
		StructureDamaged2 = Point(2,3),
	},
	TipImageCallbacks = {
		BuildingSmall = function(loc)
			Board:SetTerrain(loc, TERRAIN_BUILDING)
			Board:SetHealth(loc, 2, 2)
		end,
		BuildingDamaged = function(loc)
			Board:SetTerrain(loc, TERRAIN_BUILDING)
			Board:SetHealth(loc, 1, 2)
		end,
	},
}

In this example, the weapon "MySkill" has a TipImage table with a StuctureSmall at Point(2,1). When the tipimage is displayed in-game, the TipImageCallbacks.StuctureSmall function will be called for the TipImage.StuctureSmall element, causing a building with 2/2 health to be created at Point(1,3) on the game board.

It also has a pair of StructureDamaged entries. When the tipimage is displayed in-game, the TipImageCallbacks.BuildingDamaged function will be called for both TipImage.StructureDamaged and TipImage.StructureDamaged2, causing a building with 1/2 health to be created at Point(2,2) and Point(2,3) on the game board.

Adds support for additional keywords in weapons' TipImage.

e.g
```lua
MySkill = Skill:new{
	TipImage = {
		Sand = Point(1,1),
	}
}
```

### New supported keywords:
- Shield
- Sand
- Ice
- Frozen
- Snow

To have multiple features with the same key, the keyword can be suffixed with numbers.
### TipImage Callbacks
This feature allows the optional definiton of a `TipImageCallbacks` table for a weapon, which associates specific elements in the weapon's `TipImage` table to callback functions in `TipImageCallbacks`.

Example:
```lua
TipImageCallbacks = {
	ConveyorUp = function(loc)
		Board:AddAnimation(loc, "Conveyor_0")
	end,
	ConveyorDown = function(loc)
		Board:AddAnimation(loc, "Conveyor_2")
	end,
}
```
This example shows a `TipImageCallbacks` table with two custom callbacks that can be referenced by the weapon's `TipImage`; either by the same name or the name with a numbered suffix.

 

Example Weapon:
```lua
	TipImage = {
		Unit = Point(2,2),
		Enemy = Point(2,4),
		Target = Point(2,4),
		ConveyorUp = Point(1,3),
		ConveyorUp2 = Point(1,4),
	},
	TipImageCallbacks = {
		ConveyorUp = function(loc)
			Board:AddAnimation(loc, "Conveyor_0")
		end,
	},
```
In this example, the weapon "MySkill" has a `TipImage` table with a `ConveyorUp` at `Point(1,3)`. When the tipimage is displayed in-game, the `TipImageCallbacks.ConveyorUp` function will be called for the `TipImage.ConveyorUp` element, causing an animation "Conveyor_0" to be created at `Point(1,3)` on the game board.

It also has a second `ConveyorUp` entry, suffixed by `2`. The callback TipImageCallbacks.ConveyorUp will be called for this entry as well.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant