tobyteh's Recent Forum Activity

  • Hi,

    I am working on an in game CMD. I want to implement autocomplete for commands, however, pressing tab shifts the focus from the game to my different tabs in chrome.

    Is it possible to use the preventDefault() method in C3?

    Like:

    	input.keydown(function(event){
     		if (event.keyCode === 9) {
    		 event.preventDefault();
    		}
    	});
    

    Since the isKeyDown(keyStringOrWhich) does not provide an event but only a boolean.

    Thanks in advance,

    Toby

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Ashley,

    thanks for getting back to me so quickly! You're right, I should have provided more information.

    I am trying myself at an ingame terminal and started with a rough implementation:

    function Terminal(runtime) {
     this.commandList;
     this.terminalInput = runtime.objects.tTerminalInput.getFirstInstance();
     this.terminalText = runtime.objects.tTerminalText.getFirstInstance();
     this.selectedObject;
     this.typeTime = 0.5;
    }
    
    Terminal.prototype.openTerminal = function (runtime, object) {
    	// save the selected object
    	this.selectedObject = object[0];
    	// save the available commands of the selected object
    	this.commandList = this.selectedObject.instVars.commandList.split(',');
    	this.terminalText.typewriterText("Hacking " + this.selectedObject.objectType.name, this.typeTime);
    	// show terminal UI
    	runtime.layout.getLayer("Terminal").isVisible = 1;
     	player.behaviors.Platform.isEnabled = 0;
    	player.instVars.terminalIsOpen = 1;
    	
    	
    };
    
    Terminal.prototype.closeTerminal = function (runtime) {
    	// hide terminal UI
    	runtime.layout.getLayer("Terminal").isVisible = 0;
     	player.behaviors.Platform.isEnabled = 1;
    	player.instVars.terminalIsOpen = 0;
    	
    };
    
    // get the cmd input of the player
    Terminal.prototype.getTextInput = function(runtime){
    	terminal.runCommanIfExists(this.terminalInput.text, runtime);
    	console.log("input: " + this.terminalInput.text);
    	this.terminalInput.text = "";
    }
    
    // check if entered command exists for the selected object
    Terminal.prototype.runCommanIfExists = function(input, runtime){
    	this.commandList.forEach(function(command) {
    		if(command == input){
    			terminal.runFunction(input, runtime);
    		};
    	}); 
    }
    
    Terminal.prototype.runFunction = function(command, runtime){
    	console.log("command: " + command);
    	switch (command) {
    		case "help":
    			this.fHelp();
    			break;	
    		case "exit":
    			this.fExit(runtime);
    			break;
    	 	case "exit -h":
    			this.fExitH();
    			break;
    	 	case "sleep":
    			this.fSleep();
    			break;	
    	 	default:
    	 	console.log("default");
    			//this.fUnknownCommand();
    	}
    }
    
    //
    //	TERMINAL FUNCTIONS
    //
    
    Terminal.prototype.fHelp = function(){
    	var string = "This object supports the following functions. Enter <command> -h to get more information.";
    	this.commandList.forEach(function(command) {
    		string += "\n- " + command;
    	});
    	this.terminalText.typewriterText(string, this.typeTime);
    }
    
    Terminal.prototype.fExit = function(runtime){
    	this.closeTerminal(runtime);
    }
    
    Terminal.prototype.fExitH = function(){
    	this.terminalText.typewriterText("exit - close the terminal", this.typeTime);
    }
    
    Terminal.prototype.fUnknownCommand = function(){
    	this.terminalText.typewriterText("Not a valid command, try help.", this.typeTime);
    }
    
    Terminal.prototype.fSleep = function(){
    	console.log("sleeping nowwww");
    }
    

    The player can enter commands in a text input field and when they hit enter their command is parsed.

    While writing this text I am realizing that only commands provided by the selected object will work. And my test object does not provide other commands than help and exit in its commandList.

    Wow.. so much for code blindness. But writing this post helped me find it, so thank you very much! Especially for the fast response. I will mark this as solved.

  • Hey everyone,

    I have the following piece of code

    Terminal.prototype.runFunction = function(command, runtime){
    	switch (command) {
    	 case "help":
    		this.fHelp();
    		break;	
    	 case "exit":
    		this.fExit(runtime);
    		break;	
    	 default:
    	 console.log("default");
    	 this.fUnknownCommand();
    	}
    }
    

    The switch statement works for the cases help and exit. However, if I handover a string that is not in one of the cases the default case will not run.

    I tested the code in the browser console and was able to run the default state.

    Is this a problem of C3?

    Cheers,

    Toby

    EDIT:

    Adding more cases show's that it is not a default case problem.

    	switch (command) {
    	 case "help":
    		this.fHelp();
    		break;	
    	 case "exit":
    		this.fExit(runtime);
    		break;
    	 case "exit -h":
    		this.fExitH();
    		break;
    	 case "sleep":
    		this.fSleep();
    		break;	
    	 default:
    	 	console.log("default");
    		//this.fUnknownCommand();
    }
    

    Every case after "exit" will not run.

    Tagged:

  • You do not have permission to view this post

  • Yes, thank you I completely forgot about that.

    Yet, the problem with the restarting audio still persisted. I didn't mention that my prototype is an audio-only game. Since the player won't see the objects anyway, I ended up rotating the whole world around the player, this way the audio doesn't restart.

    This might not be a solution if you are working with visuals, though.

  • Hey folks,

    I am working on a top down game with positional audio.

    Let's say the player (the listener object) is facing north and a sound emitting object is left of it. The player then rotates 90 degrees clockwise so logically the sound would be behind the player, from their listening perspective. Any idea if that is possible with construct?

    So far nothing happens when I rotate the player.

    Cheers,

    Toby

  • Does exactly what it says

    Only wish for improvement: be able to set the volume

    Cheers,

    Toby

  • Hi everyone,

    I am working on a small prototype that sends log information to a nodeJS server via the websocket protocol. Everything works fine in preview, however, if I export my prototype and built it for Android via Phonegap, the apk cannot connect to my server.

    I did not find any network specific permissions when exporting in Construct.

    I really hope someone has an idea.

    Cheers,

    Toby

    EDIT: Little update from my side. I checked for websocket support both in chrome under Android and my exported APK and both return true. So the support itself seems to be there, however, nothing is sent to my server. Trying the same thing on chrome for Mac/Windows does sent information to my server.

    EDIT2: I solved it. Android is requiring a secure websocket connection. It will not connect to a non-secure websocket. Hope this will help someone.

  • Hi,

    I'm working on a prototype with TTS. Running it inChrome gives me a wide selection of TTS voices. However, NWJS builds just leave me with the default system one.

    This is a problem if the system running the game does not have English as it's main language, as TTS text sounds very funny and unusable.

    Is it possible to access more voices with NWJS exports?

    Thanks,

    spinz89

  • I second that!

  • You got a point there. But unfortunately I'm not allowed to publish the capx.

    I'm afraid that one can't change anything about it anyway..

    The more objects that have to be loaded, when changing a layout, the longer the engine freezes. I guess it's just how it is.

  • Push

tobyteh's avatar

tobyteh

Member since 27 Jan, 2012

None one is following tobyteh yet!

Connect with tobyteh

Trophy Case

  • 12-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies