Page 1 of 1

Can I have the mod send a private message to player?

Posted: Fri Jul 22, 2016 7:49 pm
by Peter34
I'm making a mod that "gifts" the player with additional starting items. That part I think I've got a handle on.

I presume this effect happens any time a given character is first created in the game, e.g. Peter34 or Robert_the_XI or whatever. I'd like the mod to also send a series of short messages to the player when his character is first created, briefly explaining the items. If I just print to console using function print_all(text) then it'll be alot of spam seen by everyone.

What command do I use to do have the mod "talk" privately to each player? And is there some way I can delay the effect? Either just each of the 5 messages, or else have a combined delay so that the first item is gifted after 20 seconds accompanied by the text, then 20 seconds after that the 2nd item is gifted, and so forth.

Re: Can I have the mod send a private message to player?

Posted: Fri Jul 22, 2016 8:02 pm
by mojo2012
Hi,

Have you tried player.print (http://lua-api.factorio.com/latest/LuaP ... ayer.print)?
In the on plaer created event you get the actual player. The print method should just affect this one.

What kind ofmod are sou trying to create? I'm still looking for interested devs to join my modding team (currently only me)

Re: Can I have the mod send a private message to player?

Posted: Fri Jul 22, 2016 8:09 pm
by Peter34
mojo2012 wrote:Hi,

Have you tried player.print (http://lua-api.factorio.com/latest/LuaP ... ayer.print)?
In the on plaer created event you get the actual player. The print method should just affect this one.
Thanks, I'll try that!
mojo2012 wrote:What kind ofmod are sou trying to create? I'm still looking for interested devs to join my modding team (currently only me)
This mod is just one that gifts exactly 34 extra items to the players, to make the game start a bit easier and faster, and to demo some new items from two other mods (the Flare Capsules and even more so the Agent Orange Capsules, both by Ranakastrasz).

1 extra Burner Mining Drill
10 Raw Wood
1 Solid Fuel
16 Agent Orange Capsule
6 Flare Capsule

I think the gifting itelf is going to work fine, because I'm "cribbin'" from another mod which I know works. But I'd like the mod to be more user-friendly, and if possible I'd like a delay effect, so that the player is given the 5 gifts in order, with a delay of 10 or 15 or 20s between each, depending on what my testing suggests is best.

So it's really a very, very simple mod, and the reason I'm asking for help is that I am very new to modding Factorio (or indeed modding computer games in general).

Re: Can I have the mod send a private message to player?

Posted: Fri Jul 22, 2016 8:39 pm
by mojo2012
If sou need more help, just drop me a Pm. I know hard it is to get into it ... I just recently started :)

Re: Can I have the mod send a private message to player?

Posted: Sat Jul 23, 2016 12:23 am
by Ranakastrasz

Code: Select all

function globalPrint(msg)
  local players = game.players
      for x=1, #players do
        game.players[x].print(msg)
      end
end
Replace x with the correct player's handle instead, on it's own. Or just use the player's handle.