2017-03-30 20:31:49

Hi!

Someone could give me a calculator script, which is written in bgt, or you could help that I could write one of these?
Add, subtract, multiply, divide, and I would like to know about it.

Best regarts,
Bryan

2017-03-30 20:46:42

Just out of curiosity, why do you need to write a calculator in BGT? If you are looking for a better usable and more advanced actual working software to use instead of the default Windows crap, just try googling for Speq Mathematics. If you just want to use this idea as a way to learn to improve your coding skills in string parsing, etc, then yeah, I should be able to come up with something relatively easily. The problem with BGT, though, is that you would kind of have to reinvent the wheel and reimplement all the supported math operations from scratch in your script, rather than just being able to pass the user input string directly as an expression to calculate.

Lukas

I won't be using this account any more or participating in the forum activity through other childish means like creating an alternate account. I've asked for the account to be removed but I'm not sure if that's actually technically possible here. Just writing this for people to know that I won't be replying, posting new topics or checking private messages until the account is potentially removed.

2017-03-31 08:58:13

Because the BGT can do things that a simple google calculator.
Among other things, the sound of my own - when I want it, you can tell the program and much more.

Best regarts,
Bryan

2017-03-31 13:53:43

Why do you need to make a calculator when almost every opperating system has a built in calculator?
You can even use the comand prompt as a calculator if you reely are in need of a calculator.
bgt can also be used as a calculator, if you think about it that way, but it will not be something that you can execute and share with other people
Well only as post 2 says, you will have to kind of change the sintax or something in that direction.

best regards
never give up on what ever you are doing.

2017-03-31 15:16:57

Hello. Here is an almost simple one, But i can't upload it. I paste the codes here.
Note: The both [ or ] is replaced by left braket or right braket because forum does not allow them to be used I think.
main script:
#include"virtualizer.bgt"
#include"sound_pool.bgt"
#include"m_pro.bgt"
sound_pool pool(100000);
sound capbeep;
virtualizer v;
int p=-1;
double answer;
string left braket right braketwhates;
void main()
{
show_game_window("math test");
pool.play_stationary("up.ogg",false);
whates.insert_last("+");
whates.insert_last("substract");
whates.insert_last("molta ply");
whates.insert_last("devide");
while(true)
{
if(key_pressed(KEY_DOWN))
{
p++;
pool.play_stationary("click.ogg",false);
if(p>=whates.length())
{
p=(whates.length-1);
pool.play_stationary("edge.ogg",false);
}
speak(whates left braket pright braket+". "+p+"of"+(whates.length-1));
}
if(key_pressed(KEY_ESCAPE))
{
pool.play_stationary("exit.ogg",false);
wait(900);
exit();
}
if(key_pressed(KEY_UP))
{
p--;
pool.play_stationary("click.ogg",false);
if(p<0)
{
p=0;
pool.play_stationary("edge.ogg",false);
}
speak(whates left braket pright braket+". "+p+"of"+(whates.length-1));
}
if(p==0 and key_pressed(KEY_RETURN))
{
pool.play_stationary("enter.ogg",false);
string plus=v.input("type the number one?");
pool.play_stationary("enter.ogg",false);
string plus2=v.input("type the number two?");
answer=string_to_number(plus)+string_to_number(plus2);
speak("the answer is"+answer+".");
pool.play_stationary("up.ogg",false);
}
if(p==1 and key_pressed(KEY_RETURN))
{
pool.play_stationary("enter.ogg",false);
string plus=v.input("type the number one?");
pool.play_stationary("enter.ogg",false);
string plus2=v.input("type the number two?");
answer=string_to_number(plus)-string_to_number(plus2);
speak("the answer is"+answer+".");
pool.play_stationary("up.ogg",false);
}
if(p==2 and key_pressed(KEY_RETURN))
{
pool.play_stationary("enter.ogg",false);
string plus=v.input("type the number one?");
pool.play_stationary("enter.ogg",false);
string plus2=v.input("type the number two?");
answer=string_to_number(plus)*string_to_number(plus2);
speak("the answer is"+answer+".");
pool.play_stationary("up.ogg",false);
}
if(p==3 and key_pressed(KEY_RETURN))
{
pool.play_stationary("enter.ogg",false);
string plus=v.input("type the number one?");
if(plus=="")
{
pool.play_stationary("exit.ogg",false);
wait(900);
return;
}
pool.play_stationary("enter.ogg",false);
string plus2=v.input("type the number two?");
if(plus2=="")
{
pool.play_stationary("exit.ogg",false);
wait(900);
return;
}
answer=string_to_number(plus)/string_to_number(plus2);
speak("the answer is"+answer+".");
pool.play_stationary("up.ogg",false);
}

/*if(key_pressed(KEY_D))
{
for(int i=0; i<=whates.length(); i++)
{
speak(i+" is plus"+i+" is substracked");
}

}
*/
}
}

virtualiser:
class virtualizer
{
int charrepeat=1;
int capmode=1;
string input(string text, bool stuff=false)
{
int cursor;
string message;
speak(text);
cursor=0;
string left braket right braket ms;
get_characters();
while(true)
{
wait(5);
string char=string_left(get_characters(), 1);
if (key_down(KEY_LCONTROL) or key_down(KEY_RCONTROL))
{
if (key_pressed(KEY_V))
{
speak("text pasted");
string cl=clipboard_read_text();
for (uint i=0; i<cl.length(); i++)
{
ms.insert_at(cursor,cl left braket iright braket);
cursor+=1;
}
}
if (key_pressed(KEY_C))
{
string a;
for (uint i=0; i<ms.length(); i++)
{
a+=ms left braket iright braket;
}
speak("text copied");
clipboard_copy_text(a);
}
}
if (key_pressed(KEY_F2)) {
if (capmode==0) {
capmode=1;
speak("Beep for capital letters");
}
else if (capmode==1) {
capmode=2;
speak("Say “cap” in front of the capital letters");
}
else {
capmode=0;
speak("Treat capital letters no different.");
}
}
if (key_pressed(KEY_F1))
{
if (charrepeat==1)
{
speak("character repeat off");
charrepeat=0;
}
else
{
speak("character repeat on");
charrepeat=1;
}
}
if(char!="")
{
if (charrepeat==1 and char!=" ")
{
if (string_is_upper_case(char)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(char);
}
else if (capmode==2)
speak("Cap "+char);
else
speak(char);
}
else
speak(char);
}
ms.insert_at(cursor,char);
cursor+=1;
}
if(key_pressed(KEY_BACK) and ms.length() > 0 and cursor>=1)
{
string char=ms left braket cursor-1right braket;
if (char==" ")
speak("space");
else {
if (string_is_upper_case(char)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(char);
}
else if (capmode==2)
speak("Cap "+char);
else
speak(char);
}
else
speak(char);
}
ms.remove_at(cursor-1);
cursor-=1;
}
if(key_pressed(KEY_DELETE) and ms.length() > 0 and cursor>0 and cursor<ms.length())
{
string char=ms left braket cursor+1right braket;
if (char==" ")
speak("space");
else {
if (string_is_upper_case(char)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(char);
}
else if (capmode==2)
speak("Cap "+char);
else
speak(char);
}
else
speak(char);
}
ms.remove_at(cursor+1);
}
if(key_pressed(KEY_DOWN) or key_pressed(KEY_UP))
{
string a;
for (uint i=0; i<ms.length(); i++)
{
a+=ms left braket iright braket;
}
speak(a);
}
if(key_pressed(KEY_LEFT) and cursor>0)
{
if(ms.length()>0)
{
cursor-=1;
if (cursor>=ms.length())
{
speak("Blank");
}
else if (ms left braket cursorright braket==" ")
speak("space");
else
{
if (string_is_upper_case(ms left braket cursorright braket)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(ms left braket cursorright braket);
}
else if (capmode==2)
speak("Cap "+ms left braket cursorright braket);
else
speak(ms left braket cursorright braket);
}
else
speak(ms left braket cursorright braket);
}
}
else
speak("blank");
}
if(key_pressed(KEY_RIGHT) and cursor<ms.length())
{
if(ms.length() > 0)
{
cursor+=1;
if (cursor>=ms.length())
speak("Blank");
else if (ms left braket cursorright braket==" ")
speak("space");
else
{
if (string_is_upper_case(ms left braket cursorright braket)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(ms left braket cursorright braket);
}
else if (capmode==2)
speak("Cap "+ms left braket cursorright braket);
else
speak(ms left braket cursorright braket);
}
else
speak(ms left braket cursorright braket);
}
}
else
speak("blank");
}
if(key_pressed(KEY_HOME))
{
if(ms.length() > 0)
{
cursor=0;
if (cursor>=ms.length())
speak("Blank");
else if (ms left braket cursorright braket==" ")
speak("space");
else
{
if (string_is_upper_case(ms left braket cursorright braket)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(ms left braket cursorright braket);
}
else if (capmode==2)
speak("Cap "+ms left braket cursorright braket);
else
speak(ms left braket cursorright braket);
}
else
speak(ms left braket cursorright braket);
}
}
else
speak("blank");
}
if(key_pressed(KEY_END))
{
if(ms.length() > 0)
{
cursor=ms.length();
if (cursor>=ms.length())
speak("Blank");
else if (ms left braket cursorright braket==" ")
speak("space");
else
{
if (string_is_upper_case(ms left braket cursorright braket)) {
if (capmode==1) {
capbeep.stop(); capbeep.play();
speak(ms left braket cursorright braket);
}
else if (capmode==2)
speak("Cap "+ms left braket cursorright braket);
else
speak(ms left braket cursorright braket);
}
else
speak(ms left braket cursorright braket);
}
}
else
speak("blank");
}
if(key_pressed(KEY_ESCAPE))
{
speak("Cancel.");
return "";
}
else if(key_pressed(KEY_RETURN))
{
if (ms.length() > 0)
{
for (uint i=0; i<ms.length(); i++)
{
message+=ms left braket iright braket;
}
return message;
}
else if (ms.length()==0)
{
speak("Cancel.");
return "";
}
}
}
return "";
}
}

And the m_pro:
uint wine=0;
#include"key_hold.bgt"
key_hold left(KEY_LEFT,500,50);
key_hold right(KEY_RIGHT,500,50);
key_hold up(KEY_UP,500,50);
key_hold down(KEY_DOWN,500,50);
tts_voice tts;
int found_reader=0;
sound_pool spool;
settings menuset;
void fade (sound@ handle, double final_volume=-50, double delay=25)
{
if (handle.volume == final_volume)
{
return;
}
while (handle.volume != final_volume)
{
if (handle.volume > final_volume)
{
handle.volume=handle.volume-1;
}
else if (handle.volume < final_volume)
{
handle.volume=handle.volume+1;
}
wait (delay);
}
}
bool speak(string text, int interrupt=1)
{
if(found_reader==0 and wine==0)
found_reader=auto_select_screen_reader();
if(found_reader==0)
{
if(interrupt==1)
tts.speak_interrupt(text);
else
tts.speak(text);
}
if(interrupt==1)
screen_reader_speak_interrupt(found_reader, text);
else
screen_reader_speak(found_reader, text);
return true;
}
void stopspeech()
{
for (uint i=1; i<=1; i++)
{
if (screen_reader_is_running(i))
{
screen_reader_stop_speech(i);
}
}
}
int auto_select_screen_reader()
{
if (screen_reader_is_running(1))
{
return 1;
}
if (screen_reader_is_running(3))
{
return 3;
}
if (screen_reader_is_running(4))
{
return 4;
}
else
{
return 0;
}
}
class dynamic_menu_item
{
string option;
bool is_filename;
bool activate;
string name;
string letter;
dynamic_menu_item()
{
option="";
is_filename=true;
name="";
activate=false;
}
}

class dynamic_menu_pro
{
bool letters_autospeak=true;
bool letters_autoactivate;
bool speak_letter;
bool enable_first_letter_navigation;
bool click_at_edge;
bool repeat_items_at_edges;
bool music_added=false;
int voltime=50;
timer voltimer;
sound music;
int volkeyup=KEY_PRIOR;
int volkeydown=KEY_NEXT;
int volkeycheck=KEY_V;
string open_sound;
string click_sound;
string edge_sound;
string wrap_sound;
string enter_sound;
bool enable_numbers;
bool enable_space;
bool enable_enter;
bool speak_position_information;
bool enable_side_scrolling;
bool wrap;
bool allow_escape;
bool force_sapi;
bool enable_home_and_end;
bool enable_up_and_down;
bool enable_left_and_right;
void set_volume_keys(int key1, int key2, int key3)
{
volkeyup=key1;
volkeydown=key2;
volkeycheck=key3;
}
void fade_music(int value1)
{
fade(music,-50,value1);
music.stop();
}
void stop_music()
{
music.stop();
}
void play_music()
{
if (music.playing==false)
music.play_looped();
}
void add_music(string musicpath)
{
if (music.playing==false)
{
music.load(musicpath);
music_added=true;
}
}
void play_click_sound() {
if (click_sound!="" or !file_exists(click_sound))
{
if (enable_side_scrolling==true)
spool.play_stationary_extended(click_sound, false, 0, (menu_position*100/get_item_count())-50, 0, 100, false);
else
spool.play_stationary(click_sound, false, false);
}
}
void play_edge_sound() {
if (edge_sound!="" or !file_exists(edge_sound))
{
if (enable_side_scrolling==true)
spool.play_stationary_extended(edge_sound, false, 0, (menu_position*100/get_item_count())-50, 0, 100, false);
else
spool.play_stationary(edge_sound, false, false);
}
}
void play_enter_sound() {
if (enter_sound!="" or !file_exists(enter_sound))
{
if (enable_side_scrolling==true)
spool.play_stationary_extended(enter_sound, false, 0, (menu_position*100/get_item_count())-50, 0, 100, false);
else
spool.play_stationary(enter_sound, false, false);
}
}
dynamic_menu_pro()
{
running=false;
reset(true);
}

int add_item(string filename, string name="", string key="", bool act=true)
{
return add_item_extended(filename, true, name,key, act);
}

int add_item_tts(string text, string name="", string key="", bool act=true)
{
return add_item_extended(text, false, name,key,act);
}

bool set_speech_mode(int speech_output)
{
if((speech_output<0)||(speech_output>4))
{
return false;
}
this.speech_output=speech_output;
return true;
}

int get_item_count()
{
return item_list.length();
}

int get_position()
{
if(running==false)
{
return -1;
}
return menu_position;
}

bool is_running()
{
return running;
}

bool set_tts_object(tts_voice@ handle)
{
if(running==true)
{
return false;
}
@tts_handle=@handle;
return true;
}

bool set_sound_object(sound@ handle)
{
if(running==true)
{
return false;
}
@sound_handle=@handle;
return true;
}

bool set_callback(menu_callback@ callback, string user_data)
{
if(running==true)
{
return false;
}
@callback_handle=@callback;
callback_data=user_data;
return true;
}

string get_item_name(int item)
{
if(item<1 or item>item_list.length())
{
return "";
}
return item_list left braket item-1right braket.name;
}

int run(string intro, bool is_intro_tts)
{
return run_extended(intro, is_intro_tts, 0, false);
}

int run_extended(string intro, bool is_intro_tts, int start_position, bool auto_speak_first)
{
if(running==true)
{
return -1;
}
int item_count=item_list.length();
if(item_count==0)
{
return -1;
}
if(start_position>item_count)
{
return -1;
}
menu_position=start_position;
bool speak_item=false;
if(start_position<1 && auto_speak_first==true)
{
return -1;
}
bool initial=auto_speak_first;
sound@ internal_sound;
tts_voice@ internal_tts;
if(@sound_handle==null)
{
sound temp_sound;
@internal_sound=temp_sound;
}
else
{
@internal_sound=sound_handle;
}
bool has_tts_items=is_intro_tts;
if(has_tts_items==false)
{
for(int i=0;i<item_count;i++)
{
if(item_list left braket iright braket.is_filename==false)
{
has_tts_items=true;
break;
}
}
}
if(speech_output==0 and has_tts_items==true)
{
if(@tts_handle==null)
{
tts_voice temp_voice;
@internal_tts=temp_voice;
}
else
{
@internal_tts=tts_handle;
}
}
if(intro!="")
{
if(is_intro_tts==true)
{
if(speech_output>0 and speech_output<5)
{
if(screen_reader_speak_interrupt(speech_output, intro)==false)
{
return -1;
}
}
else if (force_sapi==false)
{
if(speak(intro, 0)==false)
{
return -1;
}
}
else
{
if(internal_tts.speak_interrupt(intro)==false)
{
return -1;
}
}
}
else
{
if(internal_sound.stream(intro)==false)
{
return -1;
}
internal_sound.play();
}
}
/*bool success=menuset.setup("mtg studios", "menu", true);
if (success==false)
{
alert("error", "menu music volume could not be set");
}
if (menuset.exists("volume"))
{
double volume=menuset.read_number("volume");
music.volume=volume;
}*/
spool.play_stationary(open_sound, false);
music.play_looped();
running=true;
if (enable_first_letter_navigation==true)
get_characters();
string char;
string test;
while(true)
{

// Invoke the user callback.
if (enable_first_letter_navigation==true)
{
char=get_characters();
if(char!="" and !string_is_digits(char))
{
int f=0;
int counter=menu_position;
for (uint i=counter; i<item_list.length(); i++)
{
if(menu_position+1==i) continue;
test=item_list left braket iright braket.letter;
if (test==char)
{
counter=i+1;
f=1;
break;
}
}
if(f==0)
{
for (uint i=0; i<item_list.length(); i++)
{
if(menu_position+1==i) continue;
test=item_list left braket iright braket.letter;
if (test==char)
{
counter=i+1;
f=1;
break;
}
}
}
if(f==1)
{
menu_position=counter;
play_click_sound();
if (letters_autospeak==true)
speak_item=true;
if (letters_autoactivate==true)
{
play_enter_sound();
running=false;
return menu_position;
}
}
}
}
if(@callback_handle!=null)
{
int callback_result=callback_handle(this, callback_data);
if(callback_result!=0)
{
running=false;
return callback_result;
}
}

// Check to see if there's an item that needs to be spoken.
if(speak_item==true)
{
string secondary;
if (speak_letter==true)
{
secondary=" "+item_list left braket menu_position-1right braket.letter;
}
if(item_list left braket menu_position-1right braket.is_filename==true)
{
if(@internal_tts!=null)
{
internal_tts.stop();
}
if(internal_sound.stream(item_list left braket menu_position-1right braket.option)==false)
{
running=false;
return -1;
}
internal_sound.play();
}
else
{
if(internal_sound.active==true)
{
internal_sound.close();
}
if(speech_output>0 and speech_output<5)
{
if (speak_position_information==true)
{
if(screen_reader_speak_interrupt(speech_output, item_list left braket menu_position-1right braket.option+secondary+". "+menu_position+" of "+get_item_count())==false)
{
running=false;
return -1;
}
}
else
{
if(screen_reader_speak_interrupt(speech_output, item_list left braket menu_position-1right braket.option+secondary+". "+menu_position+" of "+get_item_count())==false)
{
running=false;
return -1;
}
}
}
else if (force_sapi==false)
{
if (speak_position_information==true)
{
if(speak(item_list left braket menu_position-1right braket.option+secondary+". "+menu_position+" of "+get_item_count())==false)
{
running=false;
return -1;
}
}
else
{
if(speak(item_list left braket menu_position-1right braket.option+secondary)==false)
{
running=false;
return -1;
}
}
}
else
{
if (speak_position_information==true)
{
if(internal_tts.speak_interrupt(item_list left braket menu_position-1right braket.option+secondary+". "+menu_position+" of "+get_item_count())==false)
{
running=false;
return -1;
}
}
else
{
if(internal_tts.speak_interrupt(item_list left braket menu_position-1right braket.option+secondary)==false)
{
running=false;
return -1;
}
}
}
}
speak_item=false;
}
if(initial==true)
{
bool finished_intro=false;
if(is_intro_tts==false)
{
if(internal_sound.playing==false)
finished_intro=true;
}
else
{
if(speech_output>0 and speech_output<5)
{
finished_intro=true;
}
else
{
if(internal_tts.speaking==false)
finished_intro=true;
}
}

if(finished_intro==true)
{
initial=false;
if(item_list left braket menu_position-1right braket.is_filename==true)
{
speak_item=true;
continue;
}
else
{
if(speech_output>0 and speech_output<5)
{
if(screen_reader_speak(speech_output, item_list left braket menu_position-1right braket.option)==false)
{
running=false;
return -1;
}
}
else
{
speak_item=true;
continue;
}
}
}
}
if (enable_numbers==true) {
if (key_up(KEY_RSHIFT) and key_pressed(KEY_1) and get_item_count()>=1) {
menu_position=1;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_2) and get_item_count()>=2) {
menu_position=2;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_3) and get_item_count()>=3) {
menu_position=3;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_4) and get_item_count()>=4) {
menu_position=4;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_5) and get_item_count()>=5) {
menu_position=5;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_6) and get_item_count()>=6) {
menu_position=6;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_7) and get_item_count()>=7) {
menu_position=7;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_8) and get_item_count()>=8) {
menu_position=8;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_9) and get_item_count()>=9) {
menu_position=9;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_0) and get_item_count()>=10) {
menu_position=10;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_MINUS) and get_item_count()>=11) {
menu_position=11;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_EQUALS) and get_item_count()>=12) {
menu_position=12;
play_click_sound();
speak_item=true;
continue;
}
else if (key_up(KEY_RSHIFT) and key_pressed(KEY_BACK) and get_item_count()>=13) {
menu_position=13;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_1) and get_item_count()>=14) {
menu_position=14;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_2) and get_item_count()>=15) {
menu_position=15;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_3) and get_item_count()>=16) {
menu_position=16;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_4) and get_item_count()>=17) {
menu_position=17;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_5) and get_item_count()>=18) {
menu_position=18;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_6) and get_item_count()>=19) {
menu_position=19;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_7) and get_item_count()>=20) {
menu_position=20;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_8) and get_item_count()>=21) {
menu_position=21;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_9) and get_item_count()>=22) {
menu_position=22;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_0) and get_item_count()>=23) {
menu_position=23;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_MINUS) and get_item_count()>=24) {
menu_position=24;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_EQUALS) and get_item_count()>=25) {
menu_position=25;
play_click_sound();
speak_item=true;
continue;
}
else if (key_down(KEY_RSHIFT) and key_pressed(KEY_BACK) and get_item_count()>=26) {
menu_position=26;
play_click_sound();
speak_item=true;
continue;
}
}
if(enable_enter==true and key_pressed(KEY_RETURN) or enable_space==true and key_pressed(KEY_SPACE))
{
if(menu_position!=0)
{
play_enter_sound();
if (item_list left braket menu_position-1right braket.activate==true)
{
running=false;
return menu_position;
}
}
}
if(allow_escape==true)
{
if(key_pressed(KEY_ESCAPE))
{
running=false;
return 0;
}
}
if (key_pressed(volkeycheck) and music_added==true)
{
if(speech_output>0 and speech_output<5)
{
screen_reader_speak_interrupt(speech_output, "music volume: "+music.volume);
}
else if (force_sapi==false)
{
speak("music volume: "+music.volume);
}
else
{
internal_tts.speak_interrupt("music volume: "+music.volume);
}
}
if (key_down(volkeydown) and voltimer.elapsed>=voltime)
{
music.volume=music.volume-2;
menuset.write_number("volume", music.volume);
voltimer.restart();
}
if (key_down(volkeyup) and voltimer.elapsed>=voltime)
{
music.volume=music.volume+2;
menuset.write_number("volume", music.volume);
voltimer.restart();
}
if(enable_up_and_down==true and key_pressed(KEY_UP)==false and up.pressing() or enable_left_and_right==true and key_pressed(KEY_LEFT)==false and left.pressing())
{
initial=false;
if(menu_position==0)
{
menu_position=item_count;
play_click_sound();
speak_item=true;
continue;
}
if(menu_position==1)
{
if(wrap==true)
{
menu_position=item_count;
spool.play_stationary(wrap_sound, false);
play_click_sound();
speak_item=true;
continue;
}
else
{
if (click_at_edge==true)
{
play_click_sound();
}
if (repeat_items_at_edges==true)
{
speak_item=true;
}
play_edge_sound();
continue;
}
}
menu_position-=1;
play_click_sound();
speak_item=true;
continue;
}
if(enable_up_and_down==true and key_pressed(KEY_DOWN)==false and down.pressing() or enable_left_and_right==true and key_pressed(KEY_RIGHT)==false and right.pressing())
{
initial=false;
if(menu_position==item_count)
{
if(wrap==true)
{
menu_position=1;
spool.play_stationary(wrap_sound, false);
play_click_sound();
speak_item=true;
continue;
}
else
{
if (click_at_edge==true)
{
play_click_sound();
}
if (repeat_items_at_edges==true)
{
speak_item=true;
}
play_edge_sound();
continue;
}
}
menu_position+=1;
play_click_sound();
speak_item=true;
continue;
}
if(enable_home_and_end==true)
{
if(key_pressed(KEY_HOME))
{
initial=false;
menu_position=1;
play_click_sound();
speak_item=true;
continue;
}
if(key_pressed(KEY_END))
{
initial=false;
menu_position=item_count;
play_click_sound();
speak_item=true;
continue;
}
}
wait(5);
}
running=false;
return -1;
}

bool reset(bool completely)
{
if(running==true)
{
return false;
}
item_list.resize(0);
if(completely==true)
{
letters_autospeak=true;
letters_autoactivate=false;
speak_letter=false;
enable_first_letter_navigation=false;
click_at_edge=false;
repeat_items_at_edges=false;
music_added=false;
volkeyup=KEY_PRIOR;
volkeydown=KEY_NEXT;
enable_space=false;
enable_enter=true;
speak_position_information=false;
open_sound="";
edge_sound="";
music.close();
click_sound="";
force_sapi=false;
enable_up_and_down=false;
enable_left_and_right=false;
wrap=true;
allow_escape=true;
enable_home_and_end=false;
speech_output=0;
@tts_handle=null;
@sound_handle=null;
@callback_handle=null;
}
return true;
}

// The following is private content and should not be modified from the outside.

tts_voice@ tts_handle;
sound@ sound_handle;
int speech_output;
menu_callback@ callback_handle;
string callback_data;
bool running;
int menu_position;
dynamic_menu_item left braket right braket item_list;

int add_item_extended(string filename, bool is_filename, string name="", string key="", bool act=true)
{
if(running==true)
{
return -1;
}
int new_index=item_list.length();
item_list.resize(new_index+1);
item_list left braket new_indexright braket.option=filename;
item_list left braket new_indexright braket.is_filename=is_filename;
item_list left braket new_indexright braket.name=name;
item_list left braket new_indexright braket.activate=act;
if (key=="")
{
key=filename left braket 0right braket;
key=string_to_lower_case(key);
}
item_list left braket new_indexright braket.letter=key;
return new_index+1;
}

}

funcdef int menu_callback(dynamic_menu_pro@, string);

keep in mind that I didn't write the m_pro or virtualiser. Just the main script is myne that used this includes.
Have fun!

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2023-09-28 10:14:17

is bgt for games?
why not using like python for calculating

but who said that i know anything about dark mattr.
wy i am not a hero caller yet?
oh it seems that i passed it, so what about.
no wait, what about.

2023-09-28 10:46:25 (edited by prince18 2023-09-28 10:57:46)

Almost 6.5 years old post
Well, a simple answer is that every language has basic math expressions that's why  Is it possible to write a calculator
Yes,  here we do have  a few esoteric programming languages
They don't have math expressions; they have their own ways to calculate
@op might want to familiar with BGT's math so he doesn't have issues when working with sound positioning  or maps

2023-09-28 11:48:09

@5
The forum allows displaying brackets, you just need to mark where the source code begins and ends.
To learn more, find the BB code link located just before the edit field where you can post a reply, click it and then read the section displaying source code.

Hth.

2023-09-28 12:49:10

Use Python for calculating.

2023-09-28 14:54:27

You do realize this topic is almost aincient no? It's almost 7 years old, Probably the user that posted doesn't need anything like this anymore.

2023-09-28 17:42:52

At first I was going to question the  sanity out of whoever decided it was a good idea to post in this thread, but I  admit that I was the one who was fully responsible for the revival of this topic.
I originally found this topic in a lengthy forum search about why BGT  got discontinued, only to discover that someone tried making a Calculator script that had extraneous functions already found in the m_pro And virtualizer class.
I decided to take a look at this, and took the time to fix the garbled mess that was put into it.
For anyone who is still interested despite The ancient presents of this topic, here is my improved version of that script.
https://www.dropbox.com/scl/fi/xlnmclim … o&dl=1

The people who love you the most,   are the people who matter most in your life.

2023-09-28 17:45:22

You can use Brainf*ck for calculating too, I think.

2023-09-28 18:17:14

@12
yes, you can

2023-09-29 10:16:41

So, that's a common chain of events, I guess.
The search feature directly helps achieve threat necromancies like this.
Thus, I think it's impossible to prohibit threat necromancy, since if someone finds what they're looking for and have new ideas or questions, they will most certainly post a reply, regardless of how old the topic is.
For exactly the same reasons, a topic talking about prohibiting threat necromancy created by Nuno on the Elten Polish Community group has been closed, so I don't think it's so bad to revive ancient topics like this any more.

2023-09-29 14:04:57

Oh?
it's ancient topic