Jump to content




My script doesn´t receive my keys!

lua

  • You cannot reply to this topic
21 replies to this topic

#1 UltimateLP

  • New Members
  • 9 posts

Posted 27 December 2012 - 02:04 AM

READ POST #4

Hi everybody, i´ve got a problem with my new ComputerCraft-Project: "ChatSuite"
I programmed a menu for a chat software i programmed, but theres a problem! Every when I start my programm:

string["chat_clientGUI"]:33:<eof> excepted
I don´t know, what made I wrong?

The script in the attachment!

Thanks for help!

-- UltimateLP (iRedCraft @ YouTube)

Attached Files



#2 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 27 December 2012 - 02:22 AM

where do you set the variable "m" ?

Edited by KaoS, 27 December 2012 - 02:24 AM.


#3 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 27 December 2012 - 02:39 AM

Yeah and these too:

return n
local n=menue(options)

Why are you returning n?

What function is menue?

#4 UltimateLP

  • New Members
  • 9 posts

Posted 27 December 2012 - 03:14 AM

OK my program is working now, thanks! But now theres another problem! When I select the first menupoint and type in the server id, it asks for the nickname, right so far! But when I type in anything I will be ported to the chat screen and cannot type in anything, hes not listening on my event!

Script so far: Attachment

Attached Files



#5 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 27 December 2012 - 03:31 AM

I am not going to download a file to solve your problem. Either put it on Pastebin or put it on the forums with ['CODE']['/CODE'] tags.

#6 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 27 December 2012 - 04:41 AM

I'm not sure what you're trying to do after you open your wifi but here's a fixed part of the menu, and the reading of server ID and nickname.

And why did you not use read() to read the server ID and nickname? :)

Spoiler


#7 UltimateLP

  • New Members
  • 9 posts

Posted 27 December 2012 - 06:02 AM

OK, that works fine, but I can´t type in my message under the "------------------------------------------------"

#8 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 27 December 2012 - 06:45 AM

View PostremiX, on 27 December 2012 - 04:41 AM, said:

I'm not sure what you're trying to do after you open your wifi but here's a fixed part of the menu, and the reading of server ID and nickname.

View PostUltimateLP, on 27 December 2012 - 06:02 AM, said:

OK, that works fine, but I can´t type in my message under the "------------------------------------------------"

Read what I said in my post.. I don't know what you're trying to do then so I didn't change anything there

#9 UltimateLP

  • New Members
  • 9 posts

Posted 28 December 2012 - 02:42 AM

The user should enter a message, after the entry of server id and nickname! Under the lines, the user enters a message which will sended to the server, and here it will be sendet to all clients, a working chat =)

#10 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 28 December 2012 - 03:32 AM

It's not letting you type because of this code, not sure what it's doing...

    -- Funktion "draw"
    while true do
        sleep( 0 )
        cBlinkT = cBlinkT + 1
        if cBlinkT == 5 then
            if cBlink == "" then
                cBlink = "_"
            else
                cBlink = ""
            end
            cBlinkT = 0
        end
        term.clear()
        term.setCursorPos(1, 1)
        local calch = h - 4
        for x=table.getn( tChatHistory ) - calch,table.getn( tChatHistory ) do
            if tChatHistory[x] ~= nil then
                write( tChatHistory[x] )
            end
        end
        term.setCursorPos( 1, h - 1 )
        write( "> "..cInput..cBlink )
        term.setCursorPos( 1, h - 2 )
        write( sBars )
    end


#11 UltimateLP

  • New Members
  • 9 posts

Posted 28 December 2012 - 05:54 AM

It writes the GUI for the chat surface, the lines, and the ">"! But when I take out this function, it not shows the chat...

#12 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 December 2012 - 06:45 AM

Either make your "funktion"s into actual functions and use the parallel call, or merge them into a single event-based loop and remove the parallel call. Right now, you enter the draw "funktion" but never leave it, so your code stays there the whole time. Of course it doesn't care about key presses.

#13 UltimateLP

  • New Members
  • 9 posts

Posted 29 December 2012 - 02:23 AM

Sorry, im german, thats about this "funktion"s ;) And how can I leave this function?

#14 AngelMalus

  • Members
  • 17 posts
  • LocationTokyo, Jpn

Posted 29 December 2012 - 02:43 AM

Seems like you are trying to run 2 processes at the same time. Your "FUNKTION" and the user Input. What Lua Liquidator suggests is to use the Parallel API and run 2 functions at the same time.

function1 = function()
print (rednet.receive())
end
function2 = function()
rednet.broadcast (read())
end
parallel.waitForAny (function1, function2)


#15 UltimateLP

  • New Members
  • 9 posts

Posted 29 December 2012 - 02:48 AM

OK, but Im a noob, so can you place it in the script?

#16 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 29 December 2012 - 03:40 AM

View PostAngelMalus, on 29 December 2012 - 02:43 AM, said:

Seems like you are trying to run 2 processes at the same time. Your "FUNKTION" and the user Input. What Lua Liquidator suggests is to use the Parallel API and run 2 functions at the same time.

Lua Liquidator is his title, his name is Lyqyd.

View PostUltimateLP, on 29 December 2012 - 02:48 AM, said:

OK, but Im a noob, so can you place it in the script?

I merged your key and receive 'functions' and put in the parallel:

Spoiler

A lot of errors will pop up because:

You're using 'tChatHistory as a table, you but never define it,

cBlinkT is never defined either

.. There are probably more



#17 UltimateLP

  • New Members
  • 9 posts

Posted 30 December 2012 - 03:25 AM

And how to define the table?

#18 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 30 December 2012 - 04:01 AM

If you do not know how to define a table, then you should go through the LUA manual and some tutorials in the tutorials sections and browse through and teach yourself. Then try the code again.

But anyway defining a table:
t_table = {}


#19 UltimateLP

  • New Members
  • 9 posts

Posted 09 January 2013 - 03:05 AM

Guys, can you not give my a finish script that works?

#20 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 09 January 2013 - 03:10 AM

Post the current code you have now and tell us your errors and i'll help you.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users