Module: LibSL::DSL

Defined in:
lib/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clientObject

Client getter



5
6
7
# File 'lib/dsl.rb', line 5

def client
	@client ||= Client.new
end

Instance Method Details

#handle(type, cb = nil, &block) ⇒ Object

Handle the event type given a Proc cb or a block

Parameters:

  • type (Symbol)

    The event type



39
40
41
42
# File 'lib/dsl.rb', line 39

def handle(type, cb=nil, &block)
	cb ||= Proc.new
	EventManager::register_handler EventHandler.new(Proc.new, type)
end

#send_packet(packet, reliable = false) ⇒ Object

Send packet

Parameters:



46
47
48
# File 'lib/dsl.rb', line 46

def send_packet(packet, reliable=false)
	client.network_manager.send_packet(packet, reliable)
end

#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object

Setup the client is given

Parameters:

  • firstname (String)

    Avatar firstname or account username

  • lastname (String)

    (optional) Account lastname. Or ‘Resident’ if a username

  • password (String)

    Password

  • start (String) (defaults to: 'last')

    (optional) The starting location to connect to. ‘last’ or ‘home’ or [REGION NAME]&&[Y]

  • grid (Symbol) (defaults to: :agni)

    (optional) The grid to connect to (:agni for Main grid or :aditi for beta grid)



17
18
19
# File 'lib/dsl.rb', line 17

def setup(firstname, lastname, password, start='last', grid=:agni)
	client.setup firstname, lastname, password, start, grid
end

#shutdownObject



50
51
52
# File 'lib/dsl.rb', line 50

def shutdown
	client.stop
end

#when_ready(cb = nil) {|Symbol| ... } ⇒ Object

Handle the :ready event (syntactic sugar)

Parameters:

  • cb (Proc) (defaults to: nil)

    (optional) An optional Proc that is called when the event is fired

Yields:

  • (Symbol)

    Event type

  • (*args)

    Event specific arguments



25
26
27
# File 'lib/dsl.rb', line 25

def when_ready(cb=nil, &block)
	handle(:ready, cb, &block)
end

#when_stopped(cb = nil, &block) ⇒ Object



33
34
35
# File 'lib/dsl.rb', line 33

def when_stopped(cb=nil, &block)
	handle(:stopped, cb, &block)
end

#when_stopping(cb = nil, &block) ⇒ Object



29
30
31
# File 'lib/dsl.rb', line 29

def when_stopping(cb=nil, &block)
	handle(:stopping, cb, &block)
end