Class: LibSL::AgentManager

Inherits:
Object
  • Object
show all
Defined in:
lib/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AgentManager

New AgentManager

Parameters:

  • client (Client)

    The client



10
11
12
13
14
15
16
17
# File 'lib/agent.rb', line 10

def initialize(client)
	@client = client
	@position = LLVector3.new(0, 0, 0)
	@look_at = LLVector3.new(0, 0, 0)
	@region_handle = LLU64.new(0)
	@region_name = ""
	init_handlers
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#look_atObject (readonly)

Returns the value of attribute look_at.



6
7
8
# File 'lib/agent.rb', line 6

def look_at
  @look_at
end

#positionObject (readonly)

Returns the value of attribute position.



6
7
8
# File 'lib/agent.rb', line 6

def position
  @position
end

#region_handleObject (readonly)

Returns the value of attribute region_handle.



6
7
8
# File 'lib/agent.rb', line 6

def region_handle
  @region_handle
end

#region_nameObject (readonly)

Returns the value of attribute region_name.



6
7
8
# File 'lib/agent.rb', line 6

def region_name
  @region_name
end

Instance Method Details

#chat(message, type = :normal, channel = 0) ⇒ Object

Send a chat message to the simulator or >0 (for scripts listening on that channel)

Parameters:

  • type (Symbol) (defaults to: :normal)

    The chat type (:normal, :whisper or :shout)

  • channel (Integer) (defaults to: 0)

    (optional) should be 0 (public)



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/agent.rb', line 60

def chat(message, type=:normal, channel=0)
	type = case type
		   when :whisper then 0
		   when :shout then 2
		   else 1
		   end
	throw "Channel has to be >=0, #{channel} given!" if channel < 0
	packet = ChatFromViewerPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id
		},
		:ChatData => {
			:Message => message,
			:Type => type,
			:Channel => channel
		}
	})
	@client.network_manager.send_packet packet
end

#im(message, to) ⇒ Object

Send an instant message to another agent

Parameters:

  • message (String)

    the message to send

  • to (LLUUID)

    The recepients id



84
85
# File 'lib/agent.rb', line 84

def im(message, to)
end

#move_to_sim(simulator) ⇒ Object

Complete a transfer to a sim (e.g. after login or teleport)

Parameters:

  • sim (Simulator)

    The sim you have been transfered to



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/agent.rb', line 22

def move_to_sim(simulator)

#	EventManager.register_handler(EventHandler.new(Proc.new do |type|
#		EventMachine::add_periodic_timer(2) do
#			packet = AgentUpdatePacket.new({
#				:AgentData => {
#					:AgentID => @client.network_manager.agent_id,
#					:SessionID => @client.network_manager.session_id,
#					:BodyRotation => LLQuaternion.new(1, 1, 1),
#					:HeadRotation => LLQuaternion.new(1, 1, 1),
#					:State => LLU8.new(0),
#					:CameraCenter => @position,
#					:CameraAtAxis => LLVector3.new(),
#					:CameraLeftAxis => LLVector3.new(),
#					:CameraUpAxis => LLVector3.new(),
#					:Far => LLF32.new(64),
#					:ControlFlags => LLU32.new(0),
#					:Flags => LLU8.new(0)
#				}
#			})
#			@client.network_manager.send_packet packet, true
#		end
#	end, :movement_complete))

	packet = CompleteAgentMovementPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id,
			:CircuitCode => @client.network_manager.circuit_code
		}
	})
	simulator.send_packet(packet)
end

#send_money(amount, to) ⇒ Object

Send Linden$ to another agent

Parameters:

  • amount (Integer)

    The amount of L$ to send

  • to (LLUUID)

    The recepient



90
91
# File 'lib/agent.rb', line 90

def send_money(amount, to)
end