Code: Select all
require "util"
require "defines"
function gimmeCar()
game.player.character.insert{name="car", count=1}
end
Code: Select all
require "util"
require "defines"
function gimmeCar()
game.player.character.insert{name="car", count=1}
end
That is not a desired behavior Could you give me a specific example ?rk84 wrote: I'm not sure about last option though. My tries to remote.call freeplay's funtions in console has failed so far and tries to discover what is inside remote.interfaces has lead to crashes without error.
I tried function call in consoleslpwnd wrote:That is not a desired behavior Could you give me a specific example ?rk84 wrote: I'm not sure about last option though. My tries to remote.call freeplay's funtions in console has failed so far and tries to discover what is inside remote.interfaces has lead to crashes without error.
Code: Select all
game.player.print(tostring(remote.call("freeplay", "getattackdata")))
-> function:xxxxxxxxxxxxxxxx
Code: Select all
f = remote.call("freeplay", "getattackdata")
game.player.print(tostring(f()))
-> Bad argument #0 to f (Wrong number of arguments)
Code: Select all
if remote.interfaces.freeplay and remote.interfaces.freeplay.getattackdata then game.player.print("Safe to use.") end
->I hear the message beep and windows tells factorio has stop working. I guess it was not safe after all.
Code: Select all
game.player.print(tostring(remote.interfaces.freeplay))
-> Error invalid key to next
I'm fairly sure you can not print a function (unless maybe if you created your own function that used return to put the data into a string, ierk84 wrote: I tried function call in consoleI expected table.Code: Select all
game.player.print(tostring(remote.call("freeplay", "getattackdata"))) -> function:xxxxxxxxxxxxxxxx
Code: Select all
function whatever() remote.call("freeplay", "getattackdata") return tostring(getattackdata) end
IMHO this is the "real" problem hererk84 wrote:This control.lua is in mods, right? I think console works in same level as core control.lua
This is an issue but you can not simply tell the game to load the console up where the mod is (many people may have more than one). SO there are the remote interfaces, I just tried this (since it's one of the things I want to be able to cover in the 3.x modding guide):drs9999 wrote:IMHO this is the "real" problem hererk84 wrote:This control.lua is in mods, right? I think console works in same level as core control.lua
If you call the the function that ManseID posted, somewhere in the mods-control file it is working fine, but you can not call it from the console (AFAIK).
That is maybe not that big issue in that case, because you can just type "game.player.character.insert{name="car", count=1}" instead of gimmeCar()", but
in reference to the 0.2.10 CCMod, where you were able to enter creative-mode via a function call from the console it is a problem in my opinion.
But like I said maybe there is a way to call a function from mod-lua-file I am not sure , but if yes I really want to know how
Code: Select all
remote.addinterface("RemoteInterfacesTest",
{
testprint = function(msg)
game.player.character.print(tostring(msg))
end
})
Good point, totally forgot about thatFreeER wrote:This is an issue but you can not simply tell the game to load the console up where the mod is (many people may have more than one)
Code: Select all
remote.addinterface("RemoteInterfacesTest",
{
testprint = function()
return "Applejuice"
end
})
Code: Select all
game.player.print(remote.call("RemoteInterfacesTest",testprint)
Code: Select all
remote.addinterface("RemoteInterfacesTest",
{
testprint = function(msg)
return testprint
end
})
I have placed it in my Mods folder's control.lua, that's how I want it to be. I just don't want to place it in the base/core's control.lua file. Even in my file it simply doesn't work. I'm trying to make a mod for starting off and this is essential for it. Unless there's a way to append into the main file (not sure what that is) so that my function(s) are able to be called from the console.FreeER wrote:Is there a reason you don't want to place it in your mods control.lua? I suppose you could always use require in the data.lua file to refrence an interface.lua file or something.
edit:I'm fairly sure you can not print a function (unless maybe if you created your own function that used return to put the data into a string, ierk84 wrote: I tried function call in consoleI expected table.Code: Select all
game.player.print(tostring(remote.call("freeplay", "getattackdata"))) -> function:xxxxxxxxxxxxxxxx
or a table (without iterating over the table)Code: Select all
function whatever() remote.call("freeplay", "getattackdata") return tostring(getattackdata) end
Code: Select all
game.player.character.insert{name="car", count=1}
Code: Select all
gimme=function(name,count) game.player.character.insert{name=name, count=count} end
Code: Select all
gimme("car", 1)
Code: Select all
game.oninit(function()
local cheatFile="cheat.txt"
if cheatFile then
game.player.character.insert{name="car",count=1}
end
end)
Code: Select all
remote.addinterface("RemoteInterfacesTest",
{
cheat = function()
local function cheater()
game.player.character.insert{name="car", count=10}
game.player.character.insert{name="iron-ore", count=10}
end
return cheater()
end
}
)