script.get_event_id("string")

Things that already exist in the current mod API
Post Reply
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

script.get_event_id("string")

Post 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)

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: script.get_event_id("string")

Post 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...

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: script.get_event_id("string")

Post 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

Rseding91
Factorio Staff
Factorio Staff
Posts: 13219
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: script.get_event_id("string")

Post by Rseding91 »

Custom inputs have the field "input_name" which is what you're looking for.
If you want to get ahold of me I'm almost always on Discord.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: script.get_event_id("string")

Post by Nexela »

And so it does! Off to use it now :)

Thanks again

Post Reply

Return to “Already exists”