Add cheat code to send power to all actors
This commit is contained in:
parent
03cd1d4ca0
commit
856de848c9
|
@ -26,6 +26,9 @@ Other miscellaneous changes:
|
|||
help with touchscreen devices, where it is difficult to touch the
|
||||
properties button without accidentally dragging the actor elsewhere
|
||||
on your level as might happen with the Actor Tool!
|
||||
* New cheat code: `tesla` will send a power signal to ALL actors on the
|
||||
current level in play mode - opening all electric doors and trapdoors.
|
||||
May cause fun chaos during gameplay. Probably not very useful.
|
||||
* Start distributing AppImage releases for GNU/Linux (64-bit and 32-bit)
|
||||
|
||||
Some technical changes:
|
||||
|
|
|
@ -293,7 +293,7 @@ func showChunker(c *cli.Context, ch *level.Chunker) {
|
|||
fmt.Println("")
|
||||
}
|
||||
|
||||
func chunkTypeToName(v int) string {
|
||||
func chunkTypeToName(v uint64) string {
|
||||
switch v {
|
||||
case level.MapType:
|
||||
return "map"
|
||||
|
|
|
@ -34,6 +34,7 @@ var (
|
|||
CheatDebugWaitScreen = "test wait screen"
|
||||
CheatUnlockLevels = "master key"
|
||||
CheatSkipLevel = "warp whistle"
|
||||
CheatFreeEnergy = "tesla"
|
||||
)
|
||||
|
||||
// Global cheat boolean states.
|
||||
|
|
|
@ -7,9 +7,11 @@ import (
|
|||
"git.kirsle.net/SketchyMaze/doodle/pkg/balance"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/modal"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/modal/loadscreen"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/scripting"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/shmem"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/windows"
|
||||
"git.kirsle.net/go/ui"
|
||||
"github.com/dop251/goja"
|
||||
)
|
||||
|
||||
// IsDefaultPlayerCharacter checks whether the DefaultPlayerCharacter doodad has
|
||||
|
@ -199,6 +201,31 @@ func (c Command) cheatCommand(d *Doodle) bool {
|
|||
d.FlashError("Use this cheat in Play Mode to toggle invincibility.")
|
||||
}
|
||||
|
||||
case balance.CheatFreeEnergy:
|
||||
if isPlay {
|
||||
playScene.SetCheated()
|
||||
d.Flash("Power toggle sent to all actors in the level.")
|
||||
for _, a := range playScene.Canvas().Actors() {
|
||||
// Hacky stuff here - just a fun cheat code anyway.
|
||||
vm := playScene.ScriptSupervisor().To(a.ID())
|
||||
value := vm.Get("__tesla")
|
||||
if value == nil || !value.ToBoolean() {
|
||||
vm.Set("__tesla", true)
|
||||
value = vm.Get("__tesla")
|
||||
} else if value.ToBoolean() {
|
||||
vm.Set("__tesla", false)
|
||||
value = vm.Get("__tesla")
|
||||
}
|
||||
vm.Inbound <- scripting.Message{
|
||||
Name: "power",
|
||||
SenderID: a.ID(),
|
||||
Args: []goja.Value{value},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
d.FlashError("Use this cheat in Play Mode to send power to all actors (chaotic!).")
|
||||
}
|
||||
|
||||
case balance.CheatDebugLoadScreen:
|
||||
loadscreen.ShowWithProgress()
|
||||
loadscreen.SetSubtitle("Loading: /dev/null", "Loadscreen testing.")
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/balance"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
|
@ -281,13 +282,16 @@ func (a *MapAccessor) UnmarshalBinary(compressed []byte) error {
|
|||
sw, err3 = binary.ReadUvarint(reader)
|
||||
)
|
||||
|
||||
point := render.NewPoint(int(x), int(y))
|
||||
a.grid[point] = NewSparseSwatch(int(sw))
|
||||
|
||||
// We expect all 3 errors to be EOF together if the binary is formed correctly.
|
||||
if err1 != nil || err2 != nil || err3 != nil {
|
||||
// log.Error("Break read loop: %s; %s; %s", err1, err2, err3)
|
||||
if err1 == nil || err2 == nil || err3 == nil {
|
||||
log.Error("MapAccessor.UnmarshalBinary: found odd number of varints!")
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
point := render.NewPoint(int(x), int(y))
|
||||
a.grid[point] = NewSparseSwatch(int(sw))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -218,7 +218,7 @@ func ChunkFromZipfile(zf *zip.Reader, layer int, coord render.Point) (*Chunk, er
|
|||
|
||||
// Read from the new binary format.
|
||||
if file, err := zf.Open(binfile); err == nil {
|
||||
log.Debug("Reading binary compressed chunk from %s", binfile)
|
||||
// log.Debug("Reading binary compressed chunk from %s", binfile)
|
||||
bin, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -229,7 +229,7 @@ func ChunkFromZipfile(zf *zip.Reader, layer int, coord render.Point) (*Chunk, er
|
|||
return nil, err
|
||||
}
|
||||
} else if file, err := zf.Open(jsonfile); err == nil {
|
||||
log.Debug("Reading JSON encoded chunk from %s", jsonfile)
|
||||
// log.Debug("Reading JSON encoded chunk from %s", jsonfile)
|
||||
bin, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -353,6 +353,11 @@ func (s *PlayScene) Canvas() *uix.Canvas {
|
|||
return s.drawing
|
||||
}
|
||||
|
||||
// ScriptSupervisor returns the scripting supervisor for play mode.
|
||||
func (s *PlayScene) ScriptSupervisor() *scripting.Supervisor {
|
||||
return s.scripting
|
||||
}
|
||||
|
||||
// SetPlayerCharacter changes the doodad used for the player, by destroying the
|
||||
// current player character and making it from scratch.
|
||||
func (s *PlayScene) SetPlayerCharacter(filename string) {
|
||||
|
|
|
@ -65,6 +65,11 @@ func (vm *VM) Set(name string, v interface{}) error {
|
|||
return vm.vm.Set(name, v)
|
||||
}
|
||||
|
||||
// Get a value from the VM.
|
||||
func (vm *VM) Get(name string) goja.Value {
|
||||
return vm.vm.Get(name)
|
||||
}
|
||||
|
||||
// RegisterLevelHooks registers accessors to the level hooks
|
||||
// and Doodad API for Play Mode.
|
||||
func (vm *VM) RegisterLevelHooks() error {
|
||||
|
|
Loading…
Reference in New Issue
Block a user