2018-11-07 14:17:15

this topic will be for bgt questions i have, as they come up. So, first question!
How would I implement a pause menu in the middle of the round, and then when I hit p again, or click the resume game, it picks up where I left off? Would this require seeing the source?
also, How would I save the music volume, cause I want to be able to change it? I think I would use something like, if(KEY_PRESSED)(KEY_Pagedown)
{
music.volume-10
}

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-07 15:02:38

Pausing really depends on how your game is set up. The simplest way would be to make a pause function with a while loop that lasts until the player unpauses.
The way I'd rather do it is with a variable that tracks what part of the system the program is in—what screen it's on, if you'd prefer. In that case, I make an enum with all the different screens, and use a switch or if-else chain in the game's input and update functions to handle each. For pausing and unpausing, I'd also pause / resume sounds (if you're using the sound_pool, just use the pause_all and resume_all methods).
Either solution runs into  problems if you're using timers. I avoid this problem with a frame-clock, so you only need one while-loop, and know that every frame is the same length, excepting heavy lag.
As for saving the music volume, my solution is to either put it in a settings dictionary that gets saved/loaded on start / exit, or to use a settings menu(s) and save/load it via for-loop and string_to_number. The dictionary is probably easiest, since you don't have to worry about converting everything to and from text yourself, and can use the serialize and deserialize functions instead.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-11-07 16:56:57

aaa, i'm not advanced enough to know what most of that ment, I sorta understood it, could you dumb it down a bit rofl?

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-09 20:24:15

I think you should learn the manual so you can understand the answers we give you. Do you even know how to use dictionaries or know what the string_to_number function does?

Ivan M. Soto.
Feel free to check out my work and services.
http://ims-productions.com

2018-11-09 21:05:33

To be fair, BGT's dictionaries are kinda cumbersome. Python, Javascript, Java, all have much more intuitive implementations of the same concept. Bonus: Python stores just about everything in the current session in a dictionary, making it easy for something like Dill to save/load.
I almost always write a function or method to make retrieving dictionary entries simpler, in BGT. I think I uploaded a zip with quickdict.bgt, where it's reduced to a handful of get functions for primitives. And there's a global dictionary (just called a), so anything that needs to be serialized can be set easily from anywhere.

There's a serialization tutorial in the manual, but this example should work if you have quickdict:

#include "quickdict.bgt"

void save_settings() {
  string data = serialize (a);
  // I'd encrypt it, just to be safe:
  text = string_encrypt(text, "I don\'t remember if this is the right order.");
  file fout;
  fout.open ("data.dat", "wb");
  fout.write (text);
}
bool load_settings () {
  // Returns true on success, false on failure.
  if(!file_exists("data.dat") return false;
  file fin;
  fin.open ("data.dat", "rb");
  string text = fin.read();
  fin.close();
  text = string_decrypt (text, same_key_as_before); // What possessed me to use such a long key while typing on my phone?
  a = deserialize (text);
  return true;
}

void initialize () {
  if (load_settings()) return; // If we already have a file saved, just do that.
  else { // Set some defaults:
   a.set ("bgm volume", -10);
    // etc.
  }
}

void change_bgm_volume (float amount) {
  bgm.volume = bgm.volume + amount;
  // I'm making it more complicated, here, because I sometimes temporarily adjust volume for cut scenes, or let music fade in/out during gameplay, so we actually want to set these separately:
  float vol = getf ("bgm volume");
  vol += amount;
  if (vol>0) vol=0;
  else if (vol<-100) vol=-100;
  a.set ("bgm volume", vol);
}

// now we let the player change volume:
void system_keys () {
  if (key_pressed(KEY_PRIOR)) change_bgm_volume (5);
  else if (key_pressed (KEY_NEXT)) change_bgm_volume (-5);
}

Generally speaking, it would be better to teach than to give usable examples, but judging by where you are in the process, an example to take apart and put back together would probably be useful.
After all, I haven't tested the above, and the bit with the encryption key has a problem as written.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-11-22 07:02:16

hi, what's the problem with this code? I'm trying to get it to do what redspot does with the weapon ping, like, if wping is off, in this case 0, it would turn on and go back to one wen i hit grave, It's only turning it on though, am I missing something, o, and obviously, this isn't the whole script, the actual script is too big and most of it doesn't have anything to do with this, so, thanks in advance?
if (key_pressed(KEY_GRAVE) and wping<=0)
{
speak("weapon ping on!");
p.play_2d("wpingon.ogg",me.x,me.y, me.x,me.y,false);
wping=1;
}
if (key_pressed(KEY_GRAVE) and wping>=1)
{
speak("weapon ping off!");
p.play_2d("wpingoff.ogg",me.x,me.y, me.x,me.y,false);
wping=0;
}

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-22 08:10:54

hi! i have more problems, but the forum doesn't like it wen I paiste bgt code into it, so i've put it into a text file, witch can be found here. thanks in advance!

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-22 13:22:04

6: Key_pressed only works once per press. What you should do is have one if for the key press, then decide what to do with the ping inside that. Also, this is where you'd want to use else, since if you only move the key_pressed, you'll always get it turning on and off at the same time.
I think there's a way you could make it work as-is, by swapping the conditions in the ifs so that key_pressed is checked after the status of the ping, but that feels like cheating.

7: the forum recognizes brackets as BB code. You can get around this by puting

[

code

]

before your code, and

[

/code

]

afterward.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-11-23 03:16:28

could you give some examples of how I would do it? I'll look at the else thingm but if I can't figure it out then hmmm

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-23 12:51:45

To abstract it a bit, what you have now is like:
if (a and b) c;
if (a and d) e;

What you want instead is:
if (a) {
  if (b) c;
  else if (d) e;
}
Since both of your ifs start with the same condition, you can just make one if for that, then do the rest inside. The else just tells it to only do if (d) in the case where if (b) failed. Since you only want one of two options, this guarantees you only get one, and never both.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-11-23 17:37:34

like if(key_pressed(KEY_`) &ping<=0)
{
code
}
else
{
code
}
that should work

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

2018-11-23 17:49:16

Here's a piece of advice fox. Don't use BGT. Python is much easier to use and there are quite a few good libraries for it. The ones you'll need are accessible_output and sound_lib, and maybe keyboard_handler and game_utils to make things easier.

Peace out.

#FreeTheCheese
"The most deadly poison of our times is indifference. And this happens, although the praise of God should know no limits. Let us strive, therefore, to praise Him to the greatest extent of our powers." - St. Maximilian Kolbe

2018-11-23 18:34:55 (edited by redfox 2018-11-23 18:35:36)

@12, I'm working on python, but I'm doing this as a side thing.
so like this?

if(key_pressed(KEY_GRAVE) and wping<=0;
{
speak("wping on!");
p.play_2d("wpingon.ogg",me.x,me.y, me.x,me.y,false");
wping==1;
}
else
{
speak("wping off!");
p.play_2d("wpingoff.ogg",me.x,me.y, me.x,me.y,false);
wping==0;
}

like that?

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-23 18:45:10

if(key_pressed(KEY_GRAVE)
{
if(wping = 0)
{
speak("wping on!");
p.play_2d("wpingon.ogg",me.x,me.y, me.x,me.y,false");
wping==1;
}
else
{
speak("wping off!");
p.play_2d("wpingoff.ogg",me.x,me.y, me.x,me.y,false);
wping==0;
}
}

2018-11-23 18:47:14 (edited by CAE_Jones 2018-11-23 18:48:54)

Not quite. As you have it now, it will turn it off again the next time your key-checking runs, which is probably like 5-20ms later.
What you want is more like:

if(key_pressed(KEY_GRAVE)) {
 if(wping<=0;
{
speak("wping on!");
p.play_2d("wpingon.ogg",me.x,me.y, me.x,me.y,false");
wping==1;
}
else
{
speak("wping off!");
p.play_2d("wpingoff.ogg",me.x,me.y, me.x,me.y,false);
wping==0;
}
}

There is another error in there that I noticed. I just copied and edited the code in your post, so that error is still in this example. It's in there twice. No matter what you set wping to initially, this will prevent it from changing. I wouldn't have noticed it if I didn't scroll too far when adding the closing brace.

[edit] Ah, Merin beat me to it. It looks like Merin did it the same way I did, though, so the error is still in that version, too.[/edit]

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-11-23 19:30:16

alright, wen pasting this in it gives a vvary peculiar error, and i'll let yall know that I'm using Mason's Zombie Arena, just to learn, for this, so maybe that'll help something:
On line: 367 (20)
Line: alert("devices list",dev);
Error: Non-terminated string literal

, any idea what this means?
in void main it calls checkcard();
and the void checkcard() is right here

void checkcard()
{
if (COMMAND_LINE!="")
{
if (COMMAND_LINE=="gl")
{
string[] devices=list_sound_devices();
string dev;
for (uint i=0; i<devices.length(); i++)
{
dev+=i+": "+devices[i]+"
";
}
alert("devices list",dev);
exit();
}
int cl=string_to_number(COMMAND_LINE);
if (cl>0)
{
open_sound_device(cl);
}
}
}

thanks in advance?

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-23 20:56:53

hi, check your key presses. they should have all the required signs.
and if i might ask, why not just use the stationary method of the sound_pool instead of using the 2d method? it just waists so much time.
p.play_stationary("pingon.ogg",false);
and the same with pingoff.ogg

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

2018-11-23 21:38:50

cause it's what's used in the source, and there's a lot of it so i'm not going threw and changing it, and also because some of the sound i don't want to play at the char's position, like bullets hitting a wall

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-24 03:07:34

Non-terminated string literals are a pain to find, because it means a mismatched quote somewhere. Without a tool to find a line with an odd number of quotes, you'd just have to ctrl + f " and check all of them manually. If you can narrow down where it might be based on what you've changed since it last compiled, that'd save some trouble.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-11-24 06:56:26

litterally the only thing i changed was the grave wping thing, plus adding int wping; somewhere near the top with the huge list of ints that the source has

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-11-24 08:01:47

as i said, check all your if statements. make sure they have all there ( ) { } "" signs.

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

2018-11-24 15:39:32

Oh, my god. This thread is becoming so confused and convoluted already, with contradicting replies and whatnot. Some of the advice you've been given shouldn't even be considered in the first place.

Why don't you just give up on the idea of learning from someone else's messy source? The way I did it, which is slower and more time-consuming but also more rewarding in the end, was to start on my own, one very small, tiny step at a time, testing every little change and first of all trying to figure out why something isn't working on my own.

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.

2018-11-28 23:20:45

get matcher.bgt from oriol gomez.com it is very useful for checking missing quotes, brackets, and parentheses