Page 1 of 1
LUA display message on start
Posted: Wed Apr 01, 2009 6:32 pm
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
Re: LUA display message on start
Posted: Wed Apr 01, 2009 6:44 pm
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.
Re: LUA display message on start
Posted: Wed Apr 01, 2009 6:48 pm
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
Re: LUA display message on start
Posted: Thu Apr 02, 2009 12:01 am
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.
Re: LUA display message on start
Posted: Thu Apr 02, 2009 10:59 am
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?
Re: LUA display message on start
Posted: Thu Apr 02, 2009 4:02 pm
by Fiodis
I don't know. Try moving it to the very, very end of ScriptPostLoad.
Re: LUA display message on start
Posted: Thu Apr 02, 2009 4:17 pm
by ryukaji
It is.
Re: LUA display message on start
Posted: Thu Apr 02, 2009 6:39 pm
by [RDH]Zerted
Post your lua. What type of pop-up do you want? There are multiple kinds...
Re: LUA display message on start
Posted: Thu Apr 02, 2009 6:45 pm
by Maveritchell
ShowObjectiveTextPopup("string", TEAM)
ShowMessageText("string")
Two ways of doing it. The first is like a campaign, the second is like ingame chat.
Re: LUA display message on start
Posted: Thu Apr 02, 2009 7:03 pm
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?
Re: LUA display message on start
Posted: Thu Apr 02, 2009 7:07 pm
by Teancum
Put it in your OnCharacterSpawn code.
Re: LUA display message on start
Posted: Thu Apr 02, 2009 7:07 pm
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.
Re: LUA display message on start
Posted: Fri Apr 03, 2009 12:20 am
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
)
Re: LUA display message on start
Posted: Fri Apr 03, 2009 1:51 am
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