2019-06-21 07:18:00

So I'm trying to make a builder menu, in bgt like in sbyw, or tk, or other games like that, and I'm having trouble.

When I run my code, witch I will explain later, it allows me to enter the coordinates in the boxes, but then when it gets to the menu, it just goes back to the while loop.

In the void game while(true), I have if(SCRIPT_COMPILED==false)
{
if(key_pressed(KEY_P))
{
bmenu();
}
}
Witch takes me to the menu just fine, here is the menu.

void bmenu()
{
settupmenu();
m.add_item_tts("Tile, T","til","t");
m.add_item_tts("Wall, W","Wal","w");
int mres=m.run("Build something",true);
if (m.get_item_name(mres)=="til")
{
mix=input_box("Builder", "Minimum x of the tile?");
if (mix=="") { bmenu(); }
mix2=string_to_number(mix);
max=input_box("Builder", "Maximum x of the tile?");
if (max=="") { bmenu(); }
max2=string_to_number(max);
miy=input_box("Builder", "Minimum y of the tile?");
if (miy=="") { bmenu(); }
miy2=string_to_number(miy);
may=input_box("Builder", "Maximum y of the tile?");
if (may=="") { bmenu(); }
may2=string_to_number(may);
miz=input_box("Builder", "Minimum z of the tile?");
if (miz=="") { bmenu(); }
miz2=string_to_number(miz);
maz=input_box("Builder", "Maximum z of the tile?");
if (maz=="") {bmenu(); }
maz2=string_to_number(maz);
tmenu();
}
}
void tmenu()
{
settupmenu();
m.add_item_tts(""+tilelist+"");
int mres=m.run("Tile type?",false);
if (mres==0 or m.get_item_name(mres)=="back")
{
bmenu();
}
else
{
spawn_tile(mix2,max2,miy2,may2,miz2,maz2,""+m.get_item_name(mres)+"");
}
}

So the mix and mix2 thing might seem a little weird, but I had trouble with the spawn_tile because it wasn't originally a string based function, except in the tiletype part. So I had to make a second variable to feed the number from the first one.

Anyway, anybody have any ideas on why this isn't working, and if so, please help. I've been working on this for hours and it's quite anoying.

P.S. I'm going to do practically the same thing with the walls menu, but a bit differently, witch I might be asking about later.
----------
“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)

2019-06-21 07:19:41 (edited by redfox 2019-06-21 07:20:51)

also, here is my tilelist string, maybe I could do this a bit better, I haven't thought of a good way:

string tilelist="dirt
grass
";
string sourcelist="
";


Obviously no sources yet haha.
It's supposed to put each line as a separate menu option, but I'm not sure if that will work yet haha.

----------
“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)

2019-06-21 11:02:50

Hi.
The way I'd personally do it is through an array, like so.
Note that due to issues with the forum not liking braces, braces here are replaced with blank lines, brackets with spaces, since I couldn't think of a better way to do it.
string[] tilelist;
void main()

tilelist.insert_last("grass");
tilelist.insert_last("concrete");
Then in your tiles menu, I'd do,
for(uint i=0; i<tiles.length(); i++)

m.add_item_tts(tiles i ,tiles i );

2019-06-21 17:10:33

Why do you call the bmenu function within itself?

2019-06-21 17:17:19

I call the bmenu if the input_box's input comes out blank. So if you enter nothing in the box, it will go back to the menu. It's not fool proof but it's the best I got so that I don't do

 spawn_tile(,,,,,dirt); 

At Charlie, you can circle your  code in

 code, and /code, with brackets. 

so it will show everything as if in <pre> tags in html.

----------
“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)

2019-06-21 22:46:25

Thanks for the help.
It works!

So I have another issue.
When I'm jumping, and I hold an arrow against a wall, it plays the sound correctly, except it won't land. The reason for this is, I'm asuming, because it takes me into that tile, and then pushes me right back out, because I'm on a wall tile. But because of the way this landing code works, as soon as it sees a tile that isn't blank or nothing, it tries to land. Now I'm not quite sure why it keeps me afloat instead of just dropping me, but that's what I need your help with. I'd like to include if the gt string doesn't contain wall, it can land as well, but I'm not sure how to do that. Here's my code

:
void platcheck()
{
if(ascending==false)
{
if(gt(me.x,me.y,me.z)!="")
{
jumping=false;
atapex=false;
descending=false;
p.play_stationary(""+gt(me.x,me.y,me.z)+"land"+random(1,3)+".ogg",false);
jumptimer.restart();
scpool.destroy_all();
stimer.restart();
scuff=true;
}
}}
----------
“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)

2019-06-21 23:12:45

You need to have a reliable way of detecting if there is a wall instead of a platform.  In your platform checking function, determine if it’s a wall or a platform. If it’s a wall, make players fall. Else, cause them to land.  Oddly enough, I never got that problem. I have written code that allows you to move in 3D, I just never ran into the issue.

2019-06-22 00:27:32

See that's my issue, I'm just not possitive how I would go about 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)

2019-06-22 00:47:28

About wall versus platform? Have the wall tiles always contain something.  For example Masons detection is always wall something, like walldirt.  The platforms on the other hand never contain that sequence of letters.  This way a reliable if statement can be written to distinguish walls from platforms.