 |
 |
 |
|
 |
 |
 |
|
 |
 |
What is the proper syntax for this? |
|
|
|
|
23:30:54 15 October 2012 |
|
Daemonion
All About Audio (Resident)
On forum: 09/27/2011
Messages: 567
|
---QUOTATION--- It's probably missing ', self' where level.name() is. InitStatic requires 2 parameters.
xml:InitStatic("mm_"..level.name(), self)
And yes, level names are like that (same as the dir names in gamedata\levels) ---END QUOTATION---
That did it!
Thanks, Cromm! |
22:56:29 15 October 2012 |
|
Daemonion
All About Audio (Resident)
On forum: 09/27/2011
Messages: 567
|
Also, I am correct in assuming that the level names are l01_escape, l02_garbage, etc etc, yes? |
22:37:42 15 October 2012 |
|
Daemonion
All About Audio (Resident)
On forum: 09/27/2011
 Message edited by: Daemonion 10/15/2012 22:38:07
Messages: 567
|
---QUOTATION--- I've made a typo, sorry. It should be level.name not level_name
if level and level.present() then
xml:InitStatic("mm_"..level.name())
else
xml:InitStatic("mm_start", self)
end
The first line (local level_name = level_name()) is not necessary ---END QUOTATION---
Hm, I am still getting an error (stack trace is blank). The game starts up properly, with the "mm_start" background, but crashes when going back to the menu after loading a save.
Here is the relevant code from my ui_main_menu.script http://pastebin.com/5LrkG7Us
Here is my ui_mm_main.xml http://pastebin.com/87m3chvL |
19:52:12 15 October 2012 |
|
Daemonion
All About Audio (Resident)
On forum: 09/27/2011
 Message edited by: Daemonion 10/15/2012 20:34:17
Messages: 567
|
With this code:
local level_name = level_name()
if level and level.present() then
xml:InitStatic("mm_"..level_name())
else
xml:InitStatic("mm_start", self)
end
I get this error:
Arguments : LUA error: ...ow of chernobyl\gamedata\scripts\ui_main_menu.script:104: attempt to call global 'level_name' (a nil value)
Not sure where to go from here |
11:57:44 15 October 2012 |
|
Daemonion
All About Audio (Resident)
On forum: 09/27/2011
 Message edited by: Daemonion 10/15/2012 12:00:52
Messages: 567
|
What is the proper syntax for this?
I am making a main menu which changes the background texture/video based on which level is active in the current game.
if level and level.present() then
local sg = CSavedGameWrapper(file:NameFull())
local level_name = sg:level_name()
if level_name = ("l01_escape")
xml:InitStatic("mm_l01_escape")
end
else
if level_name = ("l01_garbage")
xml:InitStatic("mm_l02_garbage")
end
else
xml:InitStatic("mm_start", self)
end
Specifically, I think I am messing up with the level_name = ("l01_escape" . The stack trace when I CTD is blank.
This code, however, works just fine:
if level and level.present() then
local htime = level.get_time_hours()
if htime <= 5 or htime >= 20 then
-- night version
xml:InitStatic("mm_night", self)
else
-- day version
xml:InitStatic("mm_day", self)
end
else
xml:InitStatic("mm_start", self)
end
With this last code, the game will check to see if a level/save has been loaded. If it has, it checks the time of that current game in progress and will display either a day or night version of the main menu when the ESC key is pressed. If a level has not even been loaded yet (ie when the game is first booted up), it will display a neutral (mm_start) main menu.
I want to do this same principle, but for each level. So, if the player is in Garbage, I want the main menu to show a specific background for Garbage. |
|
1 | All Messages |
|
|
|
» » |
|
All short dates are in Month-Day-Year format. |
 |
|
 |
|
|
|
 |
 |
 |