Page 1 of 1

[Rseding91] Major faulty remote interface

Posted: Tue Apr 12, 2016 11:34 pm
by y.petremann
I was trying to create a permission mod that use custom events and remote interfaces and then ... it didn't works, so here what I've found :
If you call a remote inteface from a script, arguments are wrong :

Code: Select all

require("defines")
function print_all(message)
  for _, player in pairs(game.players) do
    player.print(message)
  end
end
local event = script.generate_event_name()

remote.add_interface("test", {
  function1 = function(a,b,c)
    print_all(serpent.line({a,b,c}))
    game.raise_event(event, {player=player, permission=permission})
  end,
  function2 = function(a,b,c)
    print_all(serpent.line({a,b,c}))
  end
})
script.on_event(event, function(event)
  remote.call("test", "function2", "a","b","c")
end)
script.on_event(defines.events.on_player_created, function(event)
  remote.call("test", "function1", "a","b","c")
end)
Then when ingame, type:

Code: Select all

/c remote.call("test", "function1", "a","b","c")
The result is that you get interface name and interface function name as parameter when call from script, and not via chat, and so this break all script interaction

Re: Major faulty remote interface

Posted: Wed Apr 13, 2016 3:42 am
by Rseding91
Which version of the game are you running?

Re: Major faulty remote interface

Posted: Wed Apr 13, 2016 3:59 am
by y.petremann
Rseding91 wrote:Which version of the game are you running?
linux 64bit 0.12.30

Re: Major faulty remote interface

Posted: Wed Apr 13, 2016 4:27 am
by Rseding91
Have you tested it between mods instead of in the same mod?

Re: Major faulty remote interface

Posted: Wed Apr 13, 2016 12:10 pm
by y.petremann
Rseding91 wrote:Have you tested it between mods instead of in the same mod?
no

For me that not a problem, the idea I got is that if no permission mod is present, then diplomacy would provide a simplier one, but did remote calls should be different between mods or inside a mod ?

Re: Major faulty remote interface

Posted: Wed Apr 13, 2016 2:01 pm
by Rseding91
y.petremann wrote:
Rseding91 wrote:Have you tested it between mods instead of in the same mod?
no

For me that not a problem, the idea I got is that if no permission mod is present, then diplomacy would provide a simplier one, but did remote calls should be different between mods or inside a mod ?
Inner mod remote calls are simply function calls compared to mod <> mod calls which have to stack copy between the mods.

Re: Major faulty remote interface

Posted: Mon Apr 25, 2016 1:06 pm
by Klonan
Thansk for the report

Im not 100% in the technical knowledge,
But you're saying remote.calls don't work within a single mod,
Which you shouldn't need to do, as a remote.call is only for other mod interactions...

If this isnt the case let me know,
But for now im moving it to 'not a bug'

Re: Major faulty remote interface

Posted: Mon Apr 25, 2016 11:02 pm
by y.petremann
Klonan wrote:Thansk for the report

Im not 100% in the technical knowledge,
But you're saying remote.calls don't work within a single mod,
Which you shouldn't need to do, as a remote.call is only for other mod interactions...

If this isnt the case let me know,
But for now im moving it to 'not a bug'
The thing is we have two way :
  1. Remote call works and return something diferent whereas it is used. Like now, harder to use, need hacking to work fine
  2. Remote call works the same way whereas it is used. Like needed, easier to use, no need to hack
If that simply function calls, then simply process the argument to be in the correct place when used inside the same mod.

For me the idea is like this :
Imagine somebody create a "permission" api via remote interface. So to work a mod need to have a mod that implement that api, if the api is not present it could use a self registered version that could be replaced later if a true one is loaded.

Scripts are executed in some order, and in that case you always need that permission api to be loaded before all script that need it, but what to do if there is no permission api : use that fallback api, what to do if that another mod that is the permission api : you need to register all permission api mods as dependent mods (even thoses you don't know), what to do if it's still not loaded : use the fallback api and when the true api is loaded, it reads previous fallback api data to register in itself.

The problem is that if you need to do that you must ship a separate permission api fallback mod with the mod that need it ...

Re: [Rseding91] Major faulty remote interface

Posted: Tue Apr 26, 2016 6:00 am
by Rseding91
Fixed for the next version:

Image