I recently looked into how to automate the refilling of certain spaces in Feudum, and I wanted to share how I created this feature.
The goal is to have a button in the toolbar that, when pressed, retrieves pieces from a bag and places them at specific locations on the map. The bag contains various types of pieces, each of which must be sended in a designated spot.
The button on toolbar is a GKC defined like this:
Button text: replenish meGKC: replenishMePre-select by location Specific Maphere insert the map where refiller residesPre-select by properties type==refiller
Now we need some pieces(the refiller) on the map. These are pieces placed in an At-Start Stack(one for each stack) with these traits:
BasicPiece refillCheckerSalt1Marker GoodRefilled=saltpeteryou can create different refiller just change name. Must match theBasic Nameof the piece contained in the deck from which you wish to drawPrototype: refiller
Our refiller prototype is defined with these traits:
Does not stack move=neverMarker type=refillerLayer empty.png(this is an image with 10% opacity over the space on the map so you can see through)GKCkey command=replenishMeGKC=refillpre-select by location specificwrite here your deck of piecespre-select by properties BasicName==$GoodRefilled$(This is important, $..$ checks against source piece property, the one that issues this GKC instead of target piece property, more details in Comparing Properties For Global Key Commands)
within a deck apply to fixed number of pieces 1
Restrict command disable {StackSize > 1} restrict this command replenishMe(this stops refilling if you need only 1 piece in the spot)
Finally in the pieces inside the deck you need this trait:
Basic Name=saltpeterSend To Locationkey command=refilldestination any counter, selected by properties {GoodRefilled=="saltpeter" && StackSize==1}so you send only on non refilled spots.
Done!
Briefly when the button on toolbar is pressed a GKC is fired to all refiller pieces on the map. Each of this, if hasn’t pieces in stack(StackSize==1), sends a GKC to a deck (filtering for type of pieces inside the deck).
Every piece that matches, listens for this GKC(refill) and is sended to the location(not a location but on a counter).
I hope it’s clear.