Jump to content

Executing a cfg file from a script?


Recommended Posts

Is it possible to execute a cfg file from a script? I want to use cg_drawhud 0, cg_drawcrosshair 0, and cg_drawgun 0 for a specific part of my SP mod, and I have a cfg file that does that, and another one that sets all those back to 1. Is there a way to run these from an Icarus script?

Link to comment

Well there's going to be a lightsaber fight during that bit, so the user needs to be able to use weapons, I just don't want any HUD stuff showing up. It's during a sort of flashback.

 

EDIT: Now that I think about it, I've done something before where I ran a cfg file from a menu. And I've also found a way to open a custom menu using icarus scripting. Maybe I could make a menu that's invisible, and does nothing but activate the cfg then close itself? Maybe I'll try that.

therfiles likes this
Link to comment

Well there's going to be a lightsaber fight during that bit, so the user needs to be able to use weapons, I just don't want any HUD stuff showing up. It's during a sort of flashback.

 

EDIT: Now that I think about it, I've done something before where I ran a cfg file from a menu. And I've also found a way to open a custom menu using icarus scripting. Maybe I could make a menu that's invisible, and does nothing but activate the cfg then close itself? Maybe I'll try that.

But if you open a menu it will take exclusive input control and you won't be able to move the character or look around.

therfiles likes this
Link to comment

Okay, I can't quite figure out how I accomplished the whole opening a menu from a script thing before. It was probably a couple of years ago when I first figured it out. I still have the files, and here's what I think I did:

 

1. I edited my behavEd.bhc to add the name of my menu to this block:

<%s="MENUSCREENS">
{
	"mainMenu"
	"ingameMainMenu"
	"ingameloadMenu"
}

so that I can select my menus from the behavEd SET_MENU_SCREEN command. I'm pretty sure the name parameter in the menuDef section of my menu needs to match this, as well as the name of the menu file itself maybe. The names in the menuDefs for my two menus are "hide_HUD" and "show_HUD" and the file names are the same.

 

2. I added my new menus to base/ui/ingame.txt. I don't know if it's necessary to add them to base/ui/menus.txt, but I did it anyway.

 

3. I added a SET_MENU_SCREEN command to my scripts with the menus set to my menus I added in the behavEd.bhc file.

 

I think that's it. But when I load my game I get this: "WARNING: Menus_ActivateByName: Unable to find 'show_HUD'" I've looked through my files I had from the first time I tried and succeeded in doing this, but I can't find anything else that I did to make it work. Anyone have any ideas? These are my menu files by the way:

{
	menuDef
	{
		name "hide_HUD"
		onOpen
		{
			exec "hide_HUD.cfg"
			close hide_HUD
		}
	}
}
{
	menuDef
	{
		name "show_HUD"
		onOpen
		{
			exec "show_HUD.cfg"
			close show_HUD
		}
	}
}

And these are my config files:

helpusobi 1
cg_drawhud 0
cg_drawcrosshair 0
helpusobi 0
helpusobi 1
cg_drawhud 1
cg_drawcrosshair 1
helpusobi 0
Link to comment

@@DarthStevenus: You are very clever. I've tried a similar technique before. However, I think the error lies in the .menu file. Something about the close menu command in the onOpen block will make the menu unreadable. To confirm this, try "uimenu show_HUD" in the console to see if it works.

 

I've had to add a blank object that runs the command on the "hover over" (not what its called lol) block and closes. However, this will still cause the problem @@ensiform describes, however momentary. Also, you'll need the game to draw the game behind the menu, which is tricky. Let me see if I can find the code I used to do that.

DarthStevenus likes this
Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...