0 votes

I have recently built an in-console debugger which allows me to collect items when pressed. I've implemented a rich text label with an in-line edit node, which allows me to enter a command to be executed in run time, and collect my object. The problem is that I would also like to output a message that says, "You have successfully collected a banana". I know how to do this, so that the message is outputted. However, both of these functions require the same button to be pressed, i.e, Enter.

The problem here is that when I press Enter only the message is output and my object does not disappear. However, when I take away the code for the output of my message, then the banana disappears. Therefore, both functions cannot simultaneously be executed, because they both use the same button.

I'd like a suggestion of how I can get both a command to appear in the console box, and for my item to disappear upon entering collect_item banana, for example.

Much appreciated,


Godot version 3.4
in Engine by (72 points)

Hi juan you can assign a variable to your input and pass this variable to other nodes via by global script or by onready var.
Like if Input.isactionpressed("uiaccept"):

Hey there, could you elaborate a bit on what the onready var would be, i.e. would it be,

onready var pressedenter

like that, and if I used the global script what exactly would be the variable I am declaring.

i don't understand your the problem, why you can't commit different acts with one single input? could you please share you code or explain what is causing the problem ?

This is the code for the 2D node called Main:
onready var codedebugger = $CodeDebugger
onready var input
box = getnode("CodeDebugger/TextEditor")
onready var output
box = get_node("CodeDebugger/output")

func ready():
debugger.connect("commandsubmitted", self, "onCodeDebuggercommandsubmitted")

func outputtext(text):
box.text = str(output_box.text, "\n", text)

func processcommand(text):
var words = text.split(" ")
words = Array(words)
text(str("number of words:", words.size()))
for w in words:

func onTextEditortextentered(newtext):

func onCodeDebuggercommandsubmitted(command):
# you could split the command here because it's a string into
# functionname arg1 arg2 arg3 etc
var args = command.split(" ")
# first substring is the function name
# rest are the arguments of the function
var function
name = args[0]
callv(function_name, args)

func collectitem(item):
var items = get
var first
item = items[0]
first_item.visible = false

And I have a canvas Layer node, called CodeDebugger:

extends CanvasLayer

signal command_submitted(command)

var command = ""

onready var text_editor = $TextEditor

func _ready():

func process(delta):
if Input.isactionjustpressed("enter"):
signal("commandsubmitted", texteditor.text.stripedges())
editor.text = ""

Can't you just call output_text(text) on the function you're calling here callv(function_name, args)?

func collect_banana():
    output_text("You have successfully collected a banana")

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.