Noah Petherbridge
97e179716c
New category for the Doodad Dropper: "Technical" Technical doodads have a dashed outline and label for now, and they turn invisible on level start, and are for hidden technical effects on your level. The doodads include: * Goal Region: acts like an invisible Exit Flag (128x128), the level is won when the player character touches this region. * Fire Region: acts like a death barrier (128x128), kills the player when a generic "You have died!" message. * Power Source: on level start, acts like a switch and emits a power(true) signal to all linked doodads. Link it to your Electric Door for it to be open by default in your level! * Stall Player (250ms): The player is paused for a moment the first time it touches this region. Useful to work around timing issues, e.g. help prevent the player from winning a race against another character. There are some UI improvements to the Doodad Dropper window: * If the first page of doodads is short, extra spacers are added so the alignment and size shows correctly. * Added a 'background pattern' to the window: any unoccupied icon space has an inset rectangle slot. * "Last pages" which are short still render weirdly without reserving the correct height in the TabFrame. Doodad scripting engine updates: * Self.Hide() and Self.Show() available. * Subscribe to "broadcast:ready" to know when the level is ready, so you can safely Publish messages without deadlocks!
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package uix
|
|
|
|
import "git.kirsle.net/go/render"
|
|
|
|
// Functions relating to the Doodad JavaScript API for Canvas Actors.
|
|
|
|
// MakeSelfAPI generates the `Self` object for the scripting API in
|
|
// reference to a live Canvas actor in the level.
|
|
func (w *Canvas) MakeSelfAPI(actor *Actor) map[string]interface{} {
|
|
return map[string]interface{}{
|
|
"Filename": actor.Doodad().Filename,
|
|
"Title": actor.Doodad().Title,
|
|
|
|
// functions
|
|
"ID": actor.ID,
|
|
"Size": func() render.Rect {
|
|
var size = actor.Doodad().ChunkSize()
|
|
return render.NewRect(size, size)
|
|
},
|
|
"GetTag": actor.Doodad().Tag,
|
|
"Position": actor.Position,
|
|
"MoveTo": func(p render.Point) {
|
|
actor.MoveTo(p)
|
|
actor.SetGrounded(false)
|
|
},
|
|
"SetHitbox": actor.SetHitbox,
|
|
"Hitbox": actor.Hitbox,
|
|
"SetVelocity": actor.SetVelocity,
|
|
"SetMobile": actor.SetMobile,
|
|
"SetInventory": actor.SetInventory,
|
|
"HasInventory": actor.HasInventory,
|
|
"SetGravity": actor.SetGravity,
|
|
"AddAnimation": actor.AddAnimation,
|
|
"IsAnimating": actor.IsAnimating,
|
|
"IsPlayer": actor.IsPlayer,
|
|
"PlayAnimation": actor.PlayAnimation,
|
|
"StopAnimation": actor.StopAnimation,
|
|
"ShowLayer": actor.ShowLayer,
|
|
"ShowLayerNamed": actor.ShowLayerNamed,
|
|
"Inventory": actor.Inventory,
|
|
"AddItem": actor.AddItem,
|
|
"RemoveItem": actor.RemoveItem,
|
|
"HasItem": actor.HasItem,
|
|
"ClearInventory": actor.ClearInventory,
|
|
"Destroy": actor.Destroy,
|
|
"Hide": actor.Hide,
|
|
"Show": actor.Show,
|
|
"GetLinks": func() []map[string]interface{} {
|
|
var result = []map[string]interface{}{}
|
|
for _, linked := range w.GetLinkedActors(actor) {
|
|
result = append(result, w.MakeSelfAPI(linked))
|
|
}
|
|
return result
|
|
},
|
|
}
|
|
}
|