PDA

View Full Version : [Update] XenoBot v3.3.0 [Lua IPC & Message Handling]



DarkstaR
07-14-2013, 09:13 PM
This update brings some major updates to the Lua system. You can now share data between Lua scripts using the Signal class, and handle text messages and creature speech messages using the new Lua proxies. A big thanks to Syntax for helping with the Signal examples and class structures!

Changelog:

v3.3.0
Improved the Injector to now preserve the window titles of logged in clients and display them by character name in the list.
Added the Signal class to the Scripter, allowing scripts to talk to each other.
Signal.New(key, callback)
Creates a new signal handler for a signal with the specified key.
Parameters:
key: the key which identifies the signal.
callback: a callback to execute when a signal with the specified key is received
Signal:Send(value) or Signal.Send(key, value)
Sends a signal to all scripts for the specified key
Parameters:
value: the value of the signal. Supports integers, boolean, strings, and tables (max size 2047).
Signal:Close() or Signal.Close(key)
Stops the signal from receiving events.
Signal:Key()
Returns the key of the signal object.
Added the Proxy interface to the Scripter, allowing scripts to handle text and status messages.
The Proxy interface is implemented by different network events and is used to handle their execution.
Current Implementations:
LocalSpeechProxy : (mtype, speaker, level, text)
ErrorMessageProxy : (message)
BattleMessageProxy : (message)
LootMessageProxy : (message)
LookMessageProxy : (message)
ProxyImplementation.New(key, callback)
Creates a new proxy.
Parameters:
key: a key that serves no purpose but to identify the proxy
callback: a callback to execute when the event happens
ProxyImplementation:Close() or ProxyImplementation.Close(key)
Stops the specified proxy from receiving events.
ProxyImplementation:Key()
Returns the key of the proxy object.

Signal Class Example
The following scripts will use Lua signals to talk to eachother. Together, they display the two different usage models for Signals.

bluescript.lua
------------------------------------------------
-- This is "Blue Script", it uses static classes
------------------------------------------------
wait(10000)

-- Check for any message for blue script.
Signal.OnReceive('blue-script', function(signal, data)
-- print red script's message
print('Red: ' .. data)
-- Send a message to red script, depending on the message received
if(data == 'Hello')then
Signal.Send('red-script', 'Hi red script!!!')
elseif(data == 'Bye')then
Signal.Send('red-script', 'See ya later.')
-- We said our farewells, lets kill this listener
signal:Close()
end
end)

redscript.lua
--------------------------------------------------------
-- This is "Red Script", it uses object-oriented classes
--------------------------------------------------------
wait(10000)

local blue = Signal.New('blue-script')
local red = Signal.New('red-script')

-- Start the conversation, send a message to blue script
blue:Send('Hello')

-- Check for any message for red script.
red:OnReceive(function(signal, data)
-- print blue script's message
print('Blue: ' .. data)
-- Send a message to blue script, then kill the signal.
blue:Send('Bye.')
signal:Close()
end)



LocalSpeechProxy Example

This example handles local (say, yell, whisper, and spell cast) messages.

LocalSpeechProxy.OnReceive("myproxy", function(proxy, mtype, speaker, level, text)
print(string.format("{%s} %s [%d]: %s", mtype, speaker, level, text))
end)


11:39 {yell} DarkstaR [666]: I'M AWESOME

*MessageProxy Example

This example handles error, battle, loot, and look messages.

function messageProxyCallback(proxy, message)
print(proxy:Key() .. ": " .. message)
end

ErrorMessageProxy.OnReceive("ErrorMessageProxy", messageProxyCallback)
BattleMessageProxy.OnReceive("BattleMessageProxy", messageProxyCallback)
LootMessageProxy.OnReceive("LootMessageProxy", messageProxyCallback)
LookMessageProxy.OnReceive("LookMessageProxy", messageProxyCallback)


11:39 ErrorMessageProxy: You cannot use this object.

11:39 A spider loses 20 hitpoints due to your attack.
11:39 BattleMessageProxy: A spider loses 20 hitpoints due to your attack.

11:39 Loot of a spider: 2 gold coins
11:39 LootMessageProxy: Loot of a spider: 2 gold coins

11:40 You see dirt floor.
11:40 LookMessageProxy: You see dirt floor.

For download and operation instructions, refer back to this thread:
http://forums.xenobot.net/showthread.php?19

Syntax
07-14-2013, 09:15 PM
Hell yes :D

XtrmJosh
07-14-2013, 09:15 PM
Awesome :)

xiaospike
07-14-2013, 09:18 PM
Just what we needed :D

Thx u.

Abuse
07-14-2013, 09:19 PM
Thanks!

Nakuu
07-14-2013, 09:19 PM
Nice :)

Raziol
07-14-2013, 09:33 PM
Long expected feature AWESOME!!!!!!!
Thank you
<3 <3 <3

Infernal Bolt
07-14-2013, 09:37 PM
Good job! :D

Adky
07-14-2013, 09:55 PM
Awesome update, will be fun to play around with it :D

Eion
07-14-2013, 10:01 PM
Yes. :cool:

Blanz420
07-14-2013, 10:03 PM
Epic Update!!!
Great job Nick n Syntax!!
Amaazzinn!

Sspanky
07-14-2013, 10:11 PM
Much Appreciated :) Thanks Dude

auto
07-14-2013, 10:34 PM
This update brings some major updates to the Lua system. You can now share data between Lua scripts using the Signal class, and handle text messages and creature speech messages using the new Lua proxies. A big thanks to Syntax for helping with the Signal examples and class structures!

Changelog:

v3.3.0
Improved the Injector to now preserve the window titles of logged in clients and display them by character name in the list.
Added the Signal class to the Scripter, allowing scripts to talk to each other.
Signal.New(key, callback)
Creates a new signal handler for a signal with the specified key.
Parameters:
key: the key which identifies the signal.
callback: a callback to execute when a signal with the specified key is received
Signal:Send(value) or Signal.Send(key, value)
Sends a signal to all scripts for the specified key
Parameters:
value: the value of the signal. Supports integers, boolean, strings, and tables (max size 2047).
Signal:Close() or Signal.Close(key)
Stops the signal from receiving events.
Signal:Key()
Returns the key of the signal object.
Added the Proxy interface to the Scripter, allowing scripts to handle text and status messages.
The Proxy interface is implemented by different network events and is used to handle their execution.
Current Implementations:
LocalSpeechProxy : (mtype, speaker, level, text)
ErrorMessageProxy : (message)
BattleMessageProxy : (message)
LootMessageProxy : (message)
LookMessageProxy : (message)
ProxyImplementation.New(key, callback)
Creates a new proxy.
Parameters:
key: a key that serves no purpose but to identify the proxy
callback: a callback to execute when the event happens
ProxyImplementation:Close() or ProxyImplementation.Close(key)
Stops the specified proxy from receiving events.
ProxyImplementation:Key()
Returns the key of the proxy object.

Signal Class Example
The following scripts will use Lua signals to talk to eachother. Together, they display the two different usage models for Signals.

bluescript.lua
------------------------------------------------
-- This is "Blue Script", it uses static classes
------------------------------------------------
wait(10000)

-- Check for any message for blue script.
Signal.OnReceive('blue-script', function(signal, data)
-- print red script's message
print('Red: ' .. data)
-- Send a message to red script, depending on the message received
if(data == 'Hello')then
Signal.Send('red-script', 'Hi red script!!!')
elseif(data == 'Bye')then
Signal.Send('red-script', 'See ya later.')
-- We said our farewells, lets kill this listener
signal:Close()
end
end)

redscript.lua
--------------------------------------------------------
-- This is "Red Script", it uses object-oriented classes
--------------------------------------------------------
wait(10000)

local blue = Signal.New('blue-script')
local red = Signal.New('red-script')

-- Start the conversation, send a message to blue script
blue:Send('Hello')

-- Check for any message for red script.
red:OnReceive(function(signal, data)
-- print blue script's message
print('Blue: ' .. data)
-- Send a message to blue script, then kill the signal.
blue:Send('Bye.')
signal:Close()
end)



LocalSpeechProxy Example

This example handles local (say, yell, whisper, and spell cast) messages.

LocalSpeechProxy.OnReceive("myproxy", function(proxy, mtype, speaker, level, text)
print(string.format("{%s} %s [%d]: %s", mtype, speaker, level, text))
end)


11:39 {yell} DarkstaR [666]: I'M AWESOME

*MessageProxy Example

This example handles error, battle, loot, and look messages.

function messageProxyCallback(proxy, message)
print(proxy:Key() .. ": " .. message)
end

ErrorMessageProxy.OnReceive("ErrorMessageProxy", messageProxyCallback)
BattleMessageProxy.OnReceive("BattleMessageProxy", messageProxyCallback)
LootMessageProxy.OnReceive("LootMessageProxy", messageProxyCallback)
LookMessageProxy.OnReceive("LookMessageProxy", messageProxyCallback)


11:39 ErrorMessageProxy: You cannot use this object.

11:39 A spider loses 20 hitpoints due to your attack.
11:39 BattleMessageProxy: A spider loses 20 hitpoints due to your attack.

11:39 Loot of a spider: 2 gold coins
11:39 LootMessageProxy: Loot of a spider: 2 gold coins

11:40 You see dirt floor.
11:40 LookMessageProxy: You see dirt floor.

For download and operation instructions, refer back to this thread:
http://forums.xenobot.net/showthread.php?19


Say it in English doc

Hendy
07-14-2013, 10:37 PM
Beast.

Xeromex
07-14-2013, 10:43 PM
Already have some ideas for this. Awesomeeeeee

Syntax
07-15-2013, 12:10 AM
Say it in English doc

If you can't understand it, it's not for you <3

soul4soul
07-15-2013, 12:15 AM
this is now my favorite update of xenobot. nice work. now its time to get to writing scripts.

dinmamma
07-15-2013, 12:28 AM
Almost jizzed my pants omg!

Awesome Mr.D!

Nakuu
07-15-2013, 12:37 AM
-- EDIT
Oopsie, wrong thread xD
-- /EDIT

Daemon
07-15-2013, 12:45 AM
DarkstaR was this due to my highly annoying requests in your last live update? <3 just kidding dont ban hammer me

Stusse
07-15-2013, 01:07 AM
Yes, yes, YES! Thanks for this update! Long time been willing to communicate between scripts!

alpha90
07-15-2013, 02:33 AM
Great! Thank you!

xux
07-15-2013, 09:53 AM
Oehh interesting update with a lot of new features i like it!!

Nakuu
07-15-2013, 09:58 AM
Time for dice script? ;d

Ropiderz
07-15-2013, 12:10 PM
The coolest update ever.

thorekz
07-15-2013, 12:38 PM
server messages fuck yea! nice update

Avani
07-15-2013, 02:02 PM
Any way to also read "Quest Messages"? Like when you use a Gnomish Repair Crystal on some random spot you get the message: 16:01 This is no damaged crystal!

DarkstaR
07-15-2013, 02:05 PM
Any way to also read "Quest Messages"? Like when you use a Gnomish Repair Crystal on some random spot you get the message: 16:01 This is no damaged crystal!

I'll look into that, there's many different message types natively. I'm only doing 4 of the 6 or 7 I know of atm.

Avani
07-15-2013, 03:13 PM
Annother suggestion, please add a "Are you sure you want to clear your waypoints list?" box after clicking "Clear Waypoints". I click that button quite alot when i want to move a waypoints up a few rows.

Ropiderz
07-15-2013, 04:39 PM
How can I differ a private message received and a local chat message received both as "say" class ?

DarkstaR
07-15-2013, 05:14 PM
How can I differ a private message received and a local chat message received both as "say" class ?

Private messages shouldn't come through as they are not "local" messages. I still need to add a handler for them. I've kept it limited so I can work out any kinks before fully featuring the proxy system. Are private messages coming through?

Eion
07-15-2013, 05:17 PM
I have a few questions.

Do you plan on also making a NPC message proxy? < edit just read above post, nevermind
Is there a function that makes you "look" at something? Otherwise the look proxy seems pointless.
Does the local class cover private messages? < edit just read above post, nevermind

Anyone have a list of all the error messages? There are quite a few of them.

Koksik22
07-15-2013, 06:04 PM
thanks for nice update

Ropiderz
07-15-2013, 06:19 PM
Private messages shouldn't come through as they are not "local" messages. I still need to add a handler for them. I've kept it limited so I can work out any kinks before fully featuring the proxy system. Are private messages coming through?

I didn't tested it, just wanted to know how it works, I thought it'll return all messages in local chat, including the privates.

Daemon
07-16-2013, 12:28 AM
Avani ~ Work on a dice script that integrates with your HUD :) that would awesome

Daemon
07-16-2013, 01:42 AM
21:41 {say} Benjamin [0]: Hey, send a letter to your friend now and then. Keep in touch, you know.
21:42 {say} Towncryer [0]: Hear me! Hear me! Ankrahmun's desert is the nomads' land. Find their camp in the golden sand, and a treasure may be close at hand!
EDIT:
21:41 {say} Kalaughaos Atinus [21]: oie
21:41 {say} Mistikva [15]: AU
21:41 {say} Benjamin [0]: Hey, send a letter to your friend now and then. Keep in touch, you know.
21:42 {say} Towncryer [0]: Hear me! Hear me! Ankrahmun's desert is the nomads' land. Find their camp in the golden sand, and a treasure may be close at hand!

It is including NPC's and players as a whole if thats intended or not im not sure :P. Thats for the big ones to figure out

Daemon
07-16-2013, 02:03 AM
It doesnt return any of the private messages only npc/player messages (I tested it). Ropiderz DarkstaR

Spectrus
07-16-2013, 05:22 AM
--[[
1. Create a function to trigger when the speech proxy returns a message.
2. Call the OnReceive function for the LocalSpeechProxy class.
3. Handle input from messages inside your function.
]]

function onReceiveMessage(proxy, mType, mSpeaker, mLevel, mText)
mText = mText:lower() -- standardize input
if (mText:find('bot')) then -- search for keywords
Self.Say('Noob!') -- respond
end
end

LocalSpeechProxy.OnReceive('speechProxy', onReceiveMessage)

Nakuu
07-16-2013, 08:36 AM
Avani ~ Work on a dice script that integrates with your HUD :) that would awesome
I got dice script pretty much ready xD Need lots of testing tho.

Alastorsz
07-16-2013, 05:07 PM
Any news about the client update?

DarkstaR
07-16-2013, 05:10 PM
It'll be done tonight.

PunktG
07-16-2013, 05:37 PM
It'll be done tonight.
simply the best :)

Daemon
07-16-2013, 06:03 PM
I got dice script pretty much ready xD Need lots of testing tho.

I have plenty of gold to test it with if you would not mind some feed back.

Send me a pm~

Raul
07-17-2013, 02:54 PM
it's work