[1.0.0] LuaRCON and events: rcon does not persist after call

Bugs that are actually features.
Post Reply
User avatar
smartguy1196
Inserter
Inserter
Posts: 23
Joined: Tue Nov 10, 2020 6:09 am
Contact:

[1.0.0] LuaRCON and events: rcon does not persist after call

Post by smartguy1196 »

If I send any of these to the server (headless) via RCON:

Code: Select all


/c local remote = rcon
script.on_event( defines.events.on_console_chat, function ( event )
	remote.print( "this does not work. reeeeee" )
end)
rcon.print( "this works" )

or

Code: Select all


/c script.on_event( defines.events.on_console_chat, function ( event )
	rcon.print( "this does not work. reeeeee" )
end)
rcon.print( "this works" )

or

Code: Select all


/c local remote = rcon
script.on_event( defines.events.on_console_command, function ( event )
	remote.print( "this does not work. reeeeee" )
end)
rcon.print( "this works" )

or

Code: Select all


/c script.on_event( defines.events.on_console_command, function ( event )
	rcon.print( "this does not work. reeeeee" )
end)
rcon.print( "this works" )

I get the response: this works,
Then if I send another request, such as: "hello there! this is a test message" - this causes a problem
"hello there! this is a test message" appears in the server chat, but there is no response from rcon regardless of what rcon application I use ( expected response: "this does not work. reeeeee" from on_console_chat event )

I even tried sniffing the TCP socket that my rcon application was using for any packets and again the only packet I got back was the "this works" packet

( I get the same problem if I send any command to the server. for example if I sent "/time" I would expect "[game uptime here]" and "this does not work. reeeeee", but I only get the time aside from the "this works" response )

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] LuaRCON and events: rcon does not persist after call

Post by boskid »

Not a bug.

rcon is valid only during command called by rcon and cannot be used outside of it.

User avatar
smartguy1196
Inserter
Inserter
Posts: 23
Joined: Tue Nov 10, 2020 6:09 am
Contact:

Re: [1.0.0] LuaRCON and events: rcon does not persist after call

Post by smartguy1196 »

boskid wrote:
Fri Dec 25, 2020 7:06 am
Not a bug.

rcon is valid only during command called by rcon and cannot be used outside of it.
Alright moved it to a feature request then:

viewtopic.php?f=28&t=93548

Can you explain why it was implemented like this? I understand why disabling the `rcon` variable would be necessary, but why all instances of LuaRCON?

Like if 2 RCON clients are connected, calling rcon would have to change depending on the connected client to prevent the 2 from accidentally sending messages to each other. That makes sense, but I would expect that to work by setting rcon -> nil after call, not disabling the LuaRCON object.

Post Reply

Return to “Not a bug”