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

Place to get help with not working mods / modding interface.
Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

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

Post 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.

User avatar
mojo2012
Inserter
Inserter
Posts: 25
Joined: Fri Apr 01, 2016 8:05 am
Contact:

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

Post 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)

Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

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

Post 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).

User avatar
mojo2012
Inserter
Inserter
Posts: 25
Joined: Fri Apr 01, 2016 8:05 am
Contact:

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

Post 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 :)

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2168
Joined: Thu Jun 12, 2014 3:05 am
Contact:

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

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

Post Reply

Return to “Modding help”