Skip to main content

News

Topic: BindKey() (Read 4340 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
BindKey()
BindKey(KEY_F1, "DebugXY()", "");  returns player x, y
BindKey(KEY_F2, "DebugLayer()", ""); returns what layer the player is on
BindKey(KEY_F3, "DebugCharacter()", ""); returns the list of what the  game variables are currently set at

I can press F1 & F2 as many times as I'd like and the function runs. I press F3, the function runs once and only once. I don't understand why or what would be causing it to stop functioning after only one run through.

All 3 debuging functions are a message box using fademessage.js.

As you can see from the code, the only difference is the length of the strings. It is perplexing to me because F1 & F2 function repeatedly but F3 does not.
  • Last Edit: August 06, 2017, 12:06:14 am by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: BindKey()
Reply #1
Try replacing:
str = Array(32);

With

var str = "";

Not sure if that will do anything but it may do.

Re: BindKey()
Reply #2
tried that. Stopped functioning altogether.  It makes no sense to me. The other 2 functions run everytime but DebugCharacter only runs once. I've even tried binding it to other keys yet it still yields the same result. Runs once then loses functionality. It's quite a perplexing issue.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: BindKey()
Reply #3
@Miscreant Just tried your code (after making heavy modifications to get it to run outside its original context) and it works as expected in both Sphere 1.x and miniSphere, I can view all 3 menus as many times as I want.  I think you'll have to post your whole project (or a stripped-down version at least), not just the debug code, for me to try to diagnose what's wrong.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: BindKey()
Reply #4
@Fat Cerberus Here you go. I know there are alot of areas in the code for improvement. Eliminate redundencies and the such. This is by no means the final form of code. Please bear that in mind. Comments and suggestions welcomed.
  • Last Edit: August 06, 2017, 11:35:46 am by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: BindKey()
Reply #5
I'm missing all the assets so I can't run it, but I don't see anything immediately wrong from flipping through the code.  One thing to check is, are you entering a FlipScreen loop at any point?  Only the main MapEngine() loop checks for bound keys, if you're running an inner FlipScreen loop the keys won't be detected even if you call UpdateMapEngine().

That said, I do remember Sphere 1.x BindKey() being pretty glitchy which is why I stopped using it.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: BindKey()
Reply #6
@Fat Cerberus I'll add the other files in a bit. I just tried and the files size exceeds the forum limits. I need to reorganize the archive so it is smaller.

Edit: I removed the items that are not yet implemented to bring the file size down.
  • Last Edit: August 06, 2017, 01:46:42 pm by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: BindKey()
Reply #7
Huh, works for me in both Sphere 1.5 and miniSphere.  What version of Sphere are you using?  I know 1.6 is pretty buggy, which is why it never got out of beta.

I did notice there's an unrelated glitch in miniSphere where opening the textbox blacks out the screen until it goes away that I'll have to fix.  But I can press F3 to open the debug info as many times as I want.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: BindKey()
Reply #8
I have both Sphere 1.5 and miniSphere. I've primarily been using 1.5 because I've has such issues with SphereStudio crashing repeatedly. I haven't attemped to run my updated code in miniSphere though.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: BindKey()
Reply #9
Ok couple of points:
1. Use miniSphere for running you code it's just better than 1.5. (There is no need to use Sphere Studio to use miniSphere)

2. Try changing every instance (in the functions that work and the ones that don't) of str = Array(x) to var str = [];

Note: my suggested edit there is doing two things:
a) it's insuring you're explicitly defining your str variable rather than implicitly doing it.
b) new_array = Array(x) is not an officially supported feature of JS, if you wish to use the Array() constructor you're meant to use new_array = new Array(); but you can achieve the same effect with new_array = []; and avoid some ambiguities of the Array function.
  • Last Edit: August 06, 2017, 04:21:28 pm by Rhuan

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: BindKey()
Reply #10
Ok couple of points:
1. Use miniSphere for running you code it's just better than 1.5. (There is no need to use Sphere Studio to use miniSphere)
Normally I agree, but I think Miscreant said something about the engine freezing up on the error screen, Space/Esc didn't work to close it.  Not sure what's going on with his system there but yeah.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: BindKey()
Reply #11
Normally I agree, but I think Miscreant said something about the engine freezing up on the error screen, Space/Esc didn't work to close it.  Not sure what's going on with his system there but yeah.

I really have no idea why my development machine is so buggy. I don't even keep it connected to the internet, so it hasn't picked up any viruses. I'm very careful about what i do install on it also.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity