Hello there!
I hope I'm botering nobody with this. But I tried myself out in coding a game. Now am I coding the chat input box.
I think I'm finished with this, though there are a lot of errors sadly. I have looked at the settings example send, and at another code, and combined it basically.
I would like to ask for help in that matter. I have been coding yesterday so much that my head did hurt - and that literally -
I'll paste the code below, and I hope anyone could give me some tips. It's really difficult for me to understand the subforms and panels right now.
void chat_dialog()
{
audio_form message;
message.create_window("message",false,false,true);
int message2=message.create_input_box("&Enter your message","","",5000,false,true,true);
int send=message.create_button("&Send message",true,false,true);
audio_form buffers;
buffers.create_window("Reading through your buffers (every list showing the latest 10000 items)",false,false,false);
int all=buffers.create_list("All &buffers",10000,false,false);
int chats=buffers.create_list("&Chats",10000,false,false);
for(uint i = 0; i < all.length(); i++) buffers.add_list_item(all,all[i]+" "+(i+1)+" of "+(all.length()-1),-1,false,true);
for(uint i = 0; i < chats.length(); i++) buffers.add_list_item(all,chats[i]+" "+(i+1)+" of "+(chats.length()-1),-1,false,true);
// These are suposed to run async, though I have no idea how to aproach such right now, as async must return a type such as an int or string if I remember right.
f.create_window("chat",false,true,false);
int categories=f.create_tab_panel("&actions",2,false,false);
int s1=f.create_subform("Chat message", @message);
int s2=f.create_subform("Buffer", @buffers);
int cancel=f.create_button("cancel",false,true,false);
f.add_list_item(categories,"chat message", -1, false, true);
f.add_item(categories, "buffers", -1, false, true);
f.focus(categories);
while(true)
{
wait(5);
f.monitor();
int current=f.get_list_position(categories);
int old=0; // Just now noticed this, probably would end up being every time at tab 0 when the int is declaed all the time new in the loop.
if(old!=categories)
{
if(current=0)
{
f.set_state(s1,true,true);
f.set_state(s2, false, false);
f.set_subform(s1,messages);
}
else if(current=1)
{
f.set_state(s1, false, false);
f.set_state(s2, true, true);
f.set_subform(s2,buffers);
}
else
{
alert("Error","Critical form error.");
exit();
}
}
if(f.is_pressed(cancel))
{
speak("Canceled");
break;
}
if(chat.is_pressed(send))
{
speak("This works.");
}
}
}
// I'm also not sure if I should monitor the other forms here as well.
Now the errors:
line: 1 (1)
INFO: Compiling void chat_dialog()
line: 11 (25)
ERROR: Illegal operation on 'int'
line: 1 (1)
INFO: Compiling void chat_dialog()
line: 11 (70)
ERROR: Type 'int' doesn't support the indexing operator
line: 1 (1)
INFO: Compiling void chat_dialog()
line: 12 (27)
ERROR: Illegal operation on 'int'
line: 1 (1)
INFO: Compiling void chat_dialog()
line: 12 (74)
ERROR: Type 'int' doesn't support the indexing operator
line: 1 (1)
INFO: Compiling void chat_dialog()
line: 14 (19)
ERROR: No matching signatures to 'audio_form::create_tab_panel(const string, const int, const bool, const bool)'
line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)
line: 19 (4)
ERROR: No matching symbol 'add_item'
line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)
line: 29 (7)
ERROR: Expression must be of boolean type, instead found 'int'
line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)
line: 33 (22)
ERROR: No matching symbol 'messages'
line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)
line: 35 (12)
ERROR: Expression must be of boolean type, instead found 'int'
line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)
line: 52 (6)
ERROR: No matching symbol 'chat'
I marked these as code just in case it breaks up stuff.
Concluding, I hope anyone can help me with this.
Greetings