Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: Luke on October 11, 2013, 12:35:28 pm

Title: Retrieve players profile name and active campaign
Post by: Luke on October 11, 2013, 12:35:28 pm
Hi

Like the topic says, is it possible?

In documentation i found "getName()" and "getCampaignFilename()", but i am not sure if this are the correct functions and i don't know how i must use this. This functions need a "player handle" but in the FSO LUA docu i found nothing about this.

Any ideas?
Title: Re: Retrieve players profile name and active campaign
Post by: niffiwan on October 11, 2013, 10:02:15 pm
They look like the correct functions to me.  I think you need to use them like this:

Code: (data/tables/somefile-sct.tbm) [Select]
#Conditional Hooks

$Application: FS2_Open

$On Game Init:
[
player_name = ""
player_campaign_file = ""
]

$State: GS_STATE_GAME_PLAY
$On State Start:
[
player_name = hv.Player:getName()
player_campaign_file = hv.Player:getCampaignFilename()
]

$On HUD Draw:
[
if hu.HUDDrawn == true then
    gr.drawString(player_name)
    gr.drawString(player_campaign_file)
end
]

#End
Title: Re: Retrieve players profile name and active campaign
Post by: m!m on October 12, 2013, 02:42:50 am
I don't think that is going to work as hv.Player is a ship handle and not the player handle.
Actually I haven't found any point in the code where a player handle is ever created for the scripting system which means that it's impossible to get a player handle at the moment.
Title: Re: Retrieve players profile name and active campaign
Post by: niffiwan on October 12, 2013, 03:44:32 am
Yeah, you're right, my suggested script doesn't work at all.  I should have tested it before posting  :nervous:
Title: Re: Retrieve players profile name and active campaign
Post by: Luke on October 15, 2013, 07:04:48 am
Ok, thanks anyway.
Title: Re: Retrieve players profile name and active campaign
Post by: m!m on October 15, 2013, 02:59:00 pm
I'll see if I can get around to add that in, this should be a quick addition.