Author Topic: New Main hall (Big pic)  (Read 13796 times)

0 Members and 1 Guest are viewing this topic.

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: New Main hall (Big pic)
Current hooks:
Current scripting hooks are:
Code: [Select]
#Global Hooks
$Global: ;;Executes every single time a frame is displayed
$Splash: ;;Executes once, when the splash screen is displayed (Override disables default splash). Override disables default splash.
$GameInit: ;;Executes after everything has been loaded, but the splash screen is still displayed. An ideal spot to put mn.loadMission(). Override does nothing.
$HUD: ;;Executes every frame that the HUD is displayed. Override disables Game HUD
#End

#State Hooks
$State: ;;Can be any state. Look up GS_state_text in gamesequence.cpp for the full list. Override disables normal FS2 state.
#End

gamesequence.cpp

I've added some functions to CVS as well, here's the list: http://fs2source.warpcore.org/temp/scripting.html
Operator support is also in, so vectors can be modified (ie object.Position + object.Velocity will get a ship's position next frame, assuming its velocity doesn't change).

drawImage is broken right now, it's in the process of being updated by taylor to support the extra arguments. :nod:
-C

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Skype
    • Steam
    • Twitter
Re: New Main hall (Big pic)
just when i thought of something cool for the draw-image. :lol:
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Skype
    • Steam
    • Twitter
Re: New Main hall (Big pic)
ooookay, i pressed the middle mouse button 3 times and i got this

LUA ERROR: [string "GS_STATE_MAIN_MENU"]:50: attempt to index global `maybe_ship' (a nil value)
------------------------------------------------------------------

LUA Stack:
------------------------------------------------------------------
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: New Main hall (Big pic)
That's probably a bug on my part.

Find the section of code like this:
Code: [Select]
if (not render_ship) or force_random then
render_ship = tb.getShipClassByIndex(1)
num_ship_classes = tb.getNumShipClasses()
for count=1,num_ship_classes do
maybe_ship = tb.getShipClassByIndex(ma.getRandomNumber(1, num_ship_classes))
if maybe_ship:isInTechroom() then
render_ship = maybe_ship
break
end
end
end

You'll notice that the 0s are now 1s...this is because Lua expects everything to start at 1, rather than fs2, which generally expects it to start at 0.
-C

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Skype
    • Steam
    • Twitter
Re: New Main hall (Big pic)
pressed it ten times and no problems. :D
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

  
Re: New Main hall (Big pic)
mn.unloadMission doesn't seem to work. Pertinent Lua code is:
Code: [Select]
--Load the mission
if not load_mission then
mn.unloadMission()
load_mission_success = mn.loadMission("MenuScene-01.fs2")
load_mission = 1
end
--Make sure we actually loaded the mission
if load_mission_success then
mn.simulateFrame()
mn.renderFrame()
end

--Function to handle a section every frame
section = function(name, event, num)
--Setup color and margin for this resolution
margin = gr.getScreenHeight()/6
gr.setColor(0, 255, 0)

--Get corner coordinates for this box
x1 = gr.getScreenWidth()-180
y1 = margin*num+20
x2 = gr.getScreenWidth()-21
y2 = margin*num+55

--When the mouse is OVER this section...
if ms.getX() > x1 and ms.getX() < x2 and ms.getY() > y1 and ms.getY() < y2 then
--Draw the dark green insides
gr.setColor(0, 96, 0)
gr.drawRectangle(x1, y1, x2, y2, true, false)

--Draw the little target lines now
gr.setColor(0, 255, 0)
x = x1+(x2-x1)/2
y = margin*num

--Top target line
gr.drawLine(x, y, x, y+15)

--Bottom target line
y = margin*num+65
gr.drawLine(x, y, x, y+15)

--Left target line
x = gr.getScreenWidth()-200
y = margin*num+40
gr.drawLine(x, y, x+15, y)

--Right target line
x = gr.getScreenWidth()-16
gr.drawLine(x, y, x+15, y)

--Handle the button click
if ms.isButtonDown("Left") then
bs.setEvent(event)
gr.drawRectangle(x1, y1, x2, y2, false, false)
sd.playInterfaceSound("user_c.wav")
load_mission = 0
end
end

--Draw the outline
gr.drawRectangle(x1, y1, x2, y2, false, false)

--Color should always be pure green, so I'll skip setting the color for the name
gr.drawString(name, x1 + ( (x2-x1) - gr.getTextWidth(name) ) / 2, margin*num+35, false)
end

section("Ready Room", "GS_EVENT_NEW_CAMPAIGN", 0)
section("Campaign Room", "GS_EVENT_CAMPAIGN_ROOM", 1)
section("Tech Room", "GS_EVENT_TECH_MENU", 2)
section("Barracks", "GS_EVENT_BARRACKS_MENU", 3)
section("Options", "GS_EVENT_OPTIONS_MENU", 4)
section("Exit", "GS_EVENT_QUIT_GAME", 5)
If you play a mission and then leave it somehow, going back to the main menu, you will still be "in that mission". I tried to fix this by making the intro level reload upon leaving the main menu. Setting load_mission=0 upon entering a different section (e.g. Techroom) caused FS2 to crash upon returning; therefore, I then tried to add an unloadMission before the loadMission thinking that the problem was that I had a loadMission statement with a mission already loaded. Then I got the error:
Code: [Select]
LUA ERROR: [string "GS_STATE_MAIN_MENU"]:3: attempt to call field `unloadMission' (a nil value)
------------------------------------------------------------------

LUA Stack:
------------------------------------------------------------------
Using a new reload_mission flag to cause unloadMission to fire only on returning to the main hall, and not on first startup (before the mission's loaded), did not resolve the problem.

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: New Main hall (Big pic)
You might not have a build that supports it. Use -output_scripting and see if there's an unloadMission() in your build.

If not grab this one: http://fs2source.warpcore.org/temp/particled.zip
-C

 
Re: New Main hall (Big pic)
-output_scripting dumped nothing about scripting into fs2.log. :confused: Right now I'm using redmenace's optimized CVS (01/16); the link you gave me crashes upon trying to into the main menu:
Code: [Select]
Assert: be->handle == handle
File: c:\documents and settings\administrator\my documents\my source code\fs2_open\code\bmpman\bmpman.cpp
Line: 2552
[This filename points to the location of a file on the computer that built this executable]

Call stack:
------------------------------------------------------------------
    fs2_open_d-opt-cvs.exe 0048cdc5()
    fs2_open_d-opt-cvs.exe 00401da0()
    fs2_open_d-opt-cvs.exe 00613d53()
    fs2_open_d-opt-cvs.exe 00770ffd()
    fs2_open_d-opt-cvs.exe 00774ec2()
    fs2_open_d-opt-cvs.exe 00771660()
    fs2_open_d-opt-cvs.exe 006ff17a()
    fs2_open_d-opt-cvs.exe 00770986()
    fs2_open_d-opt-cvs.exe 00771cc4()
    fs2_open_d-opt-cvs.exe 006ff0ef()
    fs2_open_d-opt-cvs.exe 0058c06e()
    fs2_open_d-opt-cvs.exe 004291e7()
    fs2_open_d-opt-cvs.exe 006d36c8()
    fs2_open_d-opt-cvs.exe 00426cd4()
    fs2_open_d-opt-cvs.exe 007b512a()
------------------------------------------------------------------
Incidentally, that was the fastest response I've ever seen. :p

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: New Main hall (Big pic)
Well, I wouldn't try unloading a mission before it's loaded...try removing that, so that it only unloads the mission if it was loaded successfully.

Edit: I ran your script, minus the mission, and it seemed to work fine except that I changed 'bs' to 'ba' in the more recent builds, for obvious reasons. :p
« Last Edit: January 21, 2006, 03:29:44 pm by WMCoolmon »
-C

 
Re: New Main hall (Big pic)
I changed the first bit to:
Code: [Select]
--Load the mission
if not load_mission then
if reload_mission then
mn.unloadMission()
reload_mission = 0
end
load_mission_success = mn.loadMission("MenuScene-01.fs2")
load_mission = 1
end
and the part in section() that handles clicking to:
Code: [Select]
--Handle the button click
if ms.isButtonDown("Left") then
mn.unloadMission()
ba.setEvent(event)
gr.drawRectangle(x1, y1, x2, y2, false, false)
sd.playInterfaceSound("user_c.wav")
reload_mission = 1
load_mission = 0
end
Still no luck; now when I click a section the game crashes with the same error. Moving the mn.unloadMission() in section() around doesn't help.

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: New Main hall (Big pic)
You shouldn't call unload_mission twice, which is what will end up happening...first the mission will be unloaded and reload_mission will be set to 1, you'll enter the section, then come back to the mainhall. Reload_mission will be 1, so the second unloadMission call will execute, and reload_mission will be set to 0.
-C