LUA display message on start

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

LUA display message on start

Post by ryukaji »

Code: Select all

onfirstspawn = OnCharacterSpawn(
        function(character)
            if IsCharacterHuman(character) then
            popupText = "level.DOM.message.1"
	end
				)

end
I put this in at the end of ScriptPostLoad()
but I get an error:C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\DOM\DOMg_eli.lua:38: unexpected symbol near `)'
ERROR[scriptmunge scripts\DOM\DOMg_eli.lua]:Could not read input file.ERROR[scriptmunge scripts\DOM\DOMg_eli.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings

And if i take the ) away it says it needs one to close so Im really confused
Last edited by ryukaji on Wed Apr 01, 2009 6:54 pm, edited 1 time in total.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: LUA display message on start

Post by Fiodis »

Are you sure that your gameplay type supports popup mesages? I'm not certain, but it's possible only Campaign mode supports them.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: LUA display message on start

Post by ryukaji »

Does it matter? If it does then I could easily change it to campaign and give the AI deathmatch objective... but I think my problem has to be the code I added is wrong
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA display message on start

Post by [RDH]Zerted »

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
popupText = "level.DOM.message.1"
end
end
)
But you can't do pop ups like that. That line is only storing the string 'level.DOM.message.1' into the new popupText variable.

Any game mode can do pop ups.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: LUA display message on start

Post by ryukaji »

[RDH]Zerted wrote:
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
popupText = "level.DOM.message.1"
end
end
)
But you can't do pop ups like that. That line is only storing the string 'level.DOM.message.1' into the new popupText variable.

Any game mode can do pop ups.
How do you get it to display then? The color helps me understand the code a bit better though, thanks I didnt know you needed an end for the if-then

EDIT: When I added this I got no errors this time, but all my other PostLoad script things like to disable the minimap and a teleporter stopped working Why would this code mess up those?
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: LUA display message on start

Post by Fiodis »

I don't know. Try moving it to the very, very end of ScriptPostLoad.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: LUA display message on start

Post by ryukaji »

It is.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA display message on start

Post by [RDH]Zerted »

Post your lua. What type of pop-up do you want? There are multiple kinds...
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: LUA display message on start

Post by Maveritchell »

ShowObjectiveTextPopup("string", TEAM)
ShowMessageText("string")

Two ways of doing it. The first is like a campaign, the second is like ingame chat.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: LUA display message on start

Post by ryukaji »

Thanks, that worked I wanted it like campaign popup. The only problem is that it displays every time you spawn and not just the first time. Why is that?
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: LUA display message on start

Post by Teancum »

Put it in your OnCharacterSpawn code.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: LUA display message on start

Post by Maveritchell »

ryukaji wrote:Thanks, that worked I wanted it like campaign popup. The only problem is that it displays every time you spawn and not just the first time. Why is that?
Because that's what you're telling it to do. If you just want it to display once, you could do something like this:

Code: Select all

firstspawned = 0
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) and firstspawned == 0 then
ShowObjectiveTextPopup("level.DOM.message.1", ATT)
firstspawned = 1
end
end
)
You've got to make sure that there's a condition it fulfills if you want something to happen at a specific time.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA display message on start

Post by [RDH]Zerted »

This way is slightly better as the OnCharacterSpawn callback will be removed, instead running and checking firstspawned every time someone spawns:

Code: Select all

onfirstspawn = OnCharacterSpawn(
    function(character)
        if IsCharacterHuman(character) and firstspawned == 0 then
            ShowObjectiveTextPopup("level.DOM.message.1", ATT)
            ReleaseCharacterSpawn(onfirstspawn)
        end
    end
)
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: LUA display message on start

Post by ryukaji »

Ill put that one in tomorrow, maybe it will fix the problem where the minimap displays partially (the triangles show up but there is no circle around the map) I doubt it will fix it but its worth a shot
Post Reply