Skip to content
Tony Sparks edited this page Dec 14, 2017 · 4 revisions

Scripting

The Seventh uses Leola as its scripting engine. Maps may be scripted by creating the following files:

  • [mapname.json].client.props.leola
    • This is client side scripting to add visual/sound effects. This is non-authoritative of the server. This is always applied no matter the game type.
  • [mapname.json].client.[game type].leola
    • Same thing as the client.props.leola only that it is applied per game type.
  • [mapname.json].props.leola
    • This is server side scripting which allows the scripter to add game timers, triggers, spawn entities and listen for server side events. This is always applied no matter the game type.
  • [mapname.json].[game type].leola
    • Same thing as props.leola only that it is applied per game type.

Game Types

  • Team Death Match (tdm)
  • Objective (obj)
  • Capture the Flag (ctf)
  • Survivor (svr)

Game Events

  • BombDisarmedEvent
  • BombExplodedEvent
  • BombPlantedEvent
  • FlagCapturedEvent
  • FlagReturnedEvent
  • FlagStolenEvent
  • GameEndEvent
  • KillRollEvent
  • KillStreakEvent
  • PlayerAwardEvent
  • PlayerJoinedEvent
  • PlayerKilledEvent
  • PlayerLeftEvent
  • PlayerSpawnedEvent
  • RoundEndedEvent
  • RoundStartedEvent
  • SoundEmittedEvent
  • SurvivorEvent
  • TileRemovedEvent

Example Scripts:

// spawn a tank
var tank = game.newTank(620, 835)

// Add Doors
var door1 = game.newDoor(607,940, -1, 0)
var door2 = game.newDoor(31,716, -1, 0)

// Add a light source
var light = game.newLight(647,960)
light.setLuminacity(1)
light.setColor(1,1,1)
light.setSize(128)


// Flicker a Light, randomly trigger the function between 50msec and 60sec looping
game.addRandomGameTimer(true, 50, 60, def() {
        // change the luminacity of the light source
	var lum = light.getLuminacity()
	if lum < 1 {
		light.setLuminacity(1)				
	}
	else {
		light.setLuminacity(0.25)				
	}
})


// When a door opens, cause an explosion
class DoorBomb(door) {
	var isActive = false
	
        // the game engine checks this trigger condition; if true will call the  execute method
        // after a trigger has been fired, it is removed
	var checkCondition = def(game) {
		return !isActive && door.isOpened()
	}
	
        // executes when the trigger condition is met
	var execute = def(game) {
		isActive = true
                // spawns an explosion, probably killing whoever opened the door
		game.newBigExplosion(door1.getCenterPos(), door1, 20, 15, 5)
		
		// add this trigger back after 5 seconds
		game.addGameTimer(false, 5000, def() {
			isActive = false
			game.addTrigger(this)
		})
	}
}

// add the door bomb trigger 
game.addTrigger(new DoorBomb(door1))


// When a player dies, spawn a health pack
game.addEventListener("PlayerKilledEvent", def(event) {
	console.println(event.getPlayer().getName() + " died by " + event.getMeansOfDeath().name())
	
	game.newHealthPack( event.getPlayer().getKilledAt() )
})
Clone this wiki locally