XenoBot Forums - Powered by vBulletin

User Tag List

View Poll Results: What's your opinion?

Voters
3. You may not vote on this poll
  • Yes, it's nice idea

    1 33.33%
  • No! It's low. Better learn programming.

    2 66.67%
Results 1 to 7 of 7

Thread: [LUA] io.read()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Moderator shadowart's Avatar
    Join Date
    Dec 2014
    Location
    Sweden
    Posts
    1,985
    Mentioned
    225 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Spectrus View Post
    When you create a custom channel in Xenobot you pass the constructor three parameters: channelName, textCallback, closeCallback.

    The first is a string and is the name given to the channel you create. The last is a function that is called when the channel is closed.

    The second, which is relevant to what you're looking for, is called any time any text is sent in the channel. It looks something like this:

    Code:
    function OnSpeak(channel, message)
       if (message == "ping") then
          channel:SendOrangeMessage("Channel", "Pong!")
       end
    end
    
    function OnClose() end --empty
    
    local newChannel = Channel.New("Channel", OnSpeak, OnClose)
    
    newChannel:SendOrangeMessage("Channel", "Hi!")
    Considering his code examples I'm pretty sure he already knows that but finds it cumbersome to use as you have to turn your callback function into a finite-state machine.
    Last edited by shadowart; 02-17-2015 at 03:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •