Page 1 of 1

script.get_event_id("string")

Posted: Fri Apr 07, 2017 3:42 am
by Nexela
script.get_event_id("string") returns the event id associated with the custom-input name (and other possible events in .15 that are set with string)

Simple use case

Code: Select all

local run = function(event)
    if event.name = script.get_event_id("my_control_up") then
        --really why is it event.name when name is thought of as a string. event.id would be a much better choice for this.
    elseif event.name = script.get_event_id("my_control_down) then
    end
end
script.on_event({"my_control_up", "my_control_down"}, run)

Re: script.get_event_id("string")

Posted: Fri Apr 07, 2017 11:11 am
by Klonan
I don't see what much of a benefit this adds,
event.name is fine since in typical usage you refer to events by their 'name' in defines anyway:

Code: Select all

if event.name == defines.events.on_tick then...

Re: script.get_event_id("string")

Posted: Fri Apr 07, 2017 1:52 pm
by Nexela
Yes but event.name for custom controls is the "id" and not the name. And there is no way to get the id from the name (that I can see) so in my above example there is no way that would work since we cant get the id for custom control events

Re: script.get_event_id("string")

Posted: Fri Apr 07, 2017 4:32 pm
by Rseding91
Custom inputs have the field "input_name" which is what you're looking for.

Re: script.get_event_id("string")

Posted: Fri Apr 07, 2017 7:09 pm
by Nexela
And so it does! Off to use it now :)

Thanks again