#Issues with "invalid access to 0" in an Array InputEvent

1 messages · Page 1 of 1 (latest)

wanton granite
frail roost
#

It just means the array is empty. Perhaps "advance_text" is the incorrect name for your input map? Or perhaps you don't have any keys set up for it right now?

You can add a breakpoint to the code to see the values for yourself by clicking on the line number right after assigning "action_events" (screenshot attached).

Depending on how you are setting things up, you may want to check if the array is empty and return a default button text anyways (in case there is no key assigned)

wanton granite
#

trying

#

by breakpoint, do you mean indention?

#

Ok, set the breakpoint, how would I go about finding the value

#

action_name should assign a string value as indicated by the match number function. I don't know why it isn't displaying any values

#

https://www.youtube.com/watch?v=vNQBFn0faws

This is the tutorial I'm following, and 16:52 is when this specific line of code is typed

In this video we'll be adding to the options menu we previously created by adding a scrolling controls settings menu that let's us add as many controls or key binds as we need to and rebind them if we choose to in-game.

In future videos I'll be adding much more to the options menu, stylizing it and finally showing off how to create settings spe...

▶ Play video
frail roost
wanton granite
#

What I'm seeing

fickle salmon
#

Also, are you 100% sure there is an action with the exact same name in Project>Settings>Input Map?

wanton granite
#

Will respond after work

wanton granite
wanton granite
twilit badge
#

Unless im missing something the tutorial doesn't seem to explicitly state you need to make the input action first. It expected you to already make one.

Did you have the action added yet

wanton granite
#

Trying now

#

Nothing on advance_text

wanton granite
#

And I’ve been doing his tutorials in order

twilit badge
#

You need to make the input action first. Name it advance_text. And then configure what key to trigger that input.

wanton granite
#

Ok

#

Considering that I’m setting keybinds, is there a particular key I should consider for triggers?

twilit badge
#

Usually for triggers, a commonly used keybind is E F or Enter

wanton granite
#

Ok

#

So would I add the trigger in my code?

#

He doesn’t go over specifically how to bind specific keys, moreso just how to have the code register the keycode associated with the key pressed

twilit badge
#

You need to add at least one keybind as the default, it can be whatever as long as theres at least one. e.g. for Attack action you have Z as the default keybind.

wanton granite
#

Okay, well…

#

How do I do that?

#

Yeah, big n00b here

twilit badge
#

Just add it on the input map, think of it from the player prespective

#

When you play a game for the first time there will always be a default keybind.

#

W for Up S for Down A for Left D for right. And then the player can change that keybind to anything elses.

wanton granite
#

Ahh I see it

#

Trying now

#

No dice. Error persists

#

Added z as the default key

twilit badge
#

First of all check if your event is actually exist in the InputMap. Second check if you actually added an event into the action. Third please give more info other than "it doesn't work" because it could be anything when we don't have more info on why it doesn't work.

#

You could give us a screenshot of what the InputMap looks like and what your action looks like. You could give us a screenshot of a code that checks if the Input actually exist. Anything that gives more insight on your situation

wanton granite
#

My bad

#

I didn't know how else to say the error still existed?

twilit badge
#

Did you use a breakpoint to see what Input is being checked yet.

wanton granite
#

It appears the array jumpeed to 1

#

It now has two stack frames vs 1

twilit badge
wanton granite
#

Whats weird is that I followed the tutorial step-by-step and it worked fine for him

#

So either this is a thing with the new version of Godot, or I somehow missed something despite watching it three times

twilit badge
#

You're only adding 1 action. That error could be caused by another action you haven't added yet.

#

Because in this code you have 3 action. advance_text skip_dialogue and access_menu you need to add all of them

wanton granite
#

Yeah, the assertion just failed for that reason

#

Let mee try adding them now

#

It works

#

Gonna leave a comment regarding this on the video. Maybe I'll get some feedback

#

So, what's the string for in the assert line?

twilit badge
#

Hm? Which string

#

If you refer to the second parameter "There is no action called %s" % [action_name]) it will print what action that are missing, if you dont put that comment it just gonna says assertion failed without telling you what failed.

wanton granite
#

ok

#

Thanks for the help

#

Left a comment on his page. Wonder if he'll see it

twilit badge
#

Even if he doesn't, at least it will help others who will came into the same situation.

wanton granite
#

I wonder if this is an issue of Godot being updated. Will keep an eye out

twilit badge