Hi Guys,
I'm running the latest version of factorio and i've come across a little niggly issue. My friend and I wanted to start, travel away from eachother, and each make factories ourselves, and work against eachother, then build up the possibility of using the rail system for other more railway'ey things like stations for us, and maybe setups for trading resources etc etc... ANYWAY enough about our gameplay plans. What I wanted to do... Is I have my code for this already (I think, still not been able to test) as follows:
function enableTravel()
for plr in game.players do
plr.insert{{name="car", count=1}}
plr.insert{{name="coal", count=50}}
end
end
And referenced this in the base data.lua as required. (I know, I know, dont modify base, bla bla bla, but This is just for me testing and i CBA to send my friend a mod for me to just run a script to automate me giving each of us some items).
My question is as follows:
How do i call "enableTravel" from in-game? I found out quickly that "/c enableTravel()" does not do what I would expect. Any help? ^_^
If the answer is "Multiplayer is buggy, wait until they've released their first stable iteration of Multiplayer" then fair enough. But I thought i'd ask the question anyway
[0.11.3] Running custom functions from MP
-
- Inserter
- Posts: 20
- Joined: Sat Nov 22, 2014 1:16 am
- Contact:
Re: [0.11.3] Running custom functions from MP
if you are on singleplayer, may use
/c game.player.insert({name="car", count=1}) game.player.insert({name="coal", count=50})
if you are on multiplayer may use (if you are first on login)
/c game.players[1].insert({name="car", count=1}) game.player.insert({name="coal", count=50})
if you want a function for this, may use in your control.lua (this add a car and coal to all players)
Must use /c remote.call("yourmod","enableTravel")
MP is in alfa, but it works.
/c game.player.insert({name="car", count=1}) game.player.insert({name="coal", count=50})
if you are on multiplayer may use (if you are first on login)
/c game.players[1].insert({name="car", count=1}) game.player.insert({name="coal", count=50})
if you want a function for this, may use in your control.lua (this add a car and coal to all players)
Code: Select all
remote.addinterface("yourmod",
{
enableTravel = function()
for _,v in ipairs(game.players) do
v.insert{{name="car", count=1}}
v.insert{{name="coal", count=50}}
end
end,
})
MP is in alfa, but it works.
-
- Inserter
- Posts: 20
- Joined: Sat Nov 22, 2014 1:16 am
- Contact:
Re: [0.11.3] Running custom functions from MP
Beautiful, the remote.addinterface, right on the money. I knew about the ordering of how to access player/players from sp/mp and its syntax, but thanks for clarification anyway. And thanks for supplying the solution for me, muchas gracias
-
- Inserter
- Posts: 20
- Joined: Sat Nov 22, 2014 1:16 am
- Contact:
Re: [0.11.3] Running custom functions from MP
Hi, further to my code addition, I now have the function working faultlessly in-game.. but code I believed to be setting what controls what where why etc does not do what i expected it to do.
This is my code now:
c.setcontroller line does not work properly. and defines.controllers only has character, free and god. So i thought the car may be accepted as a controllable "character"... but it tells me no.
Anyone have any luck with mounting people in vehicles via mods?
This is my code now:
Code: Select all
remote.addinterface("skint",
{
enableTravel = function()
for _,c in ipairs(game.players) do
local car = game.createentity{name = "car", position = c.position, force = game.forces.player}
car.insert({name="coal", count=50})
c.setcontroller({type = defines.controllers.character, character = car})
end
end,
})
Anyone have any luck with mounting people in vehicles via mods?
Re: [0.11.3] Running custom functions from MP
I think "setcontroller" must be a character, car is not a character, maybe can possess a biter XD is a joke, neither can be possessed, it only works with type = "player" i think.
-
- Inserter
- Posts: 20
- Joined: Sat Nov 22, 2014 1:16 am
- Contact:
Re: [0.11.3] Running custom functions from MP
yeah I thought i'd give it a go none the less. As the "player" is a class that controls how the player interacts with the game, not the in-game character instance. So i presumed I could set how what the player is currently controlling (car, train, character, etc) via that setcontroller function. I guess it doesn't do what it says on the tin yet though. ALPHA!! ^_^
Does anyone have any joy with automating getting in vehicles. seeming as the "vehicle" property is read-only i cant se the vehicle instance directly on that value.
Does anyone have any joy with automating getting in vehicles. seeming as the "vehicle" property is read-only i cant se the vehicle instance directly on that value.