GoldenEye: Source Forums

Editing and Customization => Modding Help => Topic started by: WNxEuphonic on February 13, 2011, 07:51:36 pm

Title: Global Variables in Python?
Post by: WNxEuphonic on February 13, 2011, 07:51:36 pm
I'm making a gameplay and need to use a global variable (not per player, mind you). I've been using:

global globvar
globvar = "value"

As I usually do in python, but it's not working for me. Does global work in GE:S? Or should I recheck my code?
Title: Re: Global Variables in Python?
Post by: killermonkey on February 13, 2011, 08:16:31 pm
Simple question. Why?

You can create class scope constants by simply declaring vars at top of class outside of the function blocks.

Can be referred as CLASSSNAME.varname or self.varname
Title: Re: Global Variables in Python?
Post by: WNxEuphonic on February 14, 2011, 10:28:49 pm
Thank you KillerMonkey! Sorry I keep bugging you with questions, I really appreciate your help. I am almost done with my gameplay...all I have to do now is figure out how to do a HUD progress bar. Is there any documentation on how to set those up? I searched on the wiki and through other gameplays but I can't seem to get it to work.
Title: Re: Global Variables in Python?
Post by: killermonkey on February 15, 2011, 12:01:37 am
Yes, sorry, the documentation for python is in a sorry sorry state. Although would you rather have working gameplays or working documentation, take your pick ;-)

As for HUD stuff here is a simple breakdown of all the functions:
Anything in brackets [] is an optional variable


GEUtil.HudMessage( player, msg, xper, yper, [color], [secs_to_show], [channel] )
GEUtil.HudMessageTeam( teamid, msg, ... )

xper/yper -> [0.0 to 1.0] use -1 for center
player -> use 'None' for ALL players (same for the rest)


GEUtil.ShowPopupHelp( player, title, msg, [image], [secs_to_show], [archive_me] )
GEUtil.ShowPopupHelpTeam( teamid, title, ... )

GEUtil.InitHudProgressBarPlayer( player, channel, title, options, max_value, xper, yper, bar_width, bar_height, color )
GEUtil.UpdateHudProgressBarPlayer( player, channel, value )
GEUtil.ConfigHudProgressBarPlayer( player, channel, title, [color] )
GEUtil.RemoveHudProgressBarPlayer( player, channel )

For team functions, just change Player to Team and use teamid

Some notes on the progress bars. You must init the progress bar before you can post updates to it. Options can be the following:

GEGlobal.HUDPB_TITLEONLY, GEGlobal.HUDPB_SHOWBAR, GEGlobal.HUDPB_SHOWVALUE, GEGlobal.HUDPB_VERTICAL

You can 'or' them together like: GEGlobal.HUDPB_SHOWBAR | GEGlobal.HUDPB_VERTICAL

use the config function to change the title or color of the progress bar instead of re-initing it which is network intensive.
Title: Re: Global Variables in Python?
Post by: WNxEuphonic on February 15, 2011, 03:21:12 am
Thanks! That's exactly what I needed to know. On a side note, how does one give mines to a player? All the other weapons are working no problem.

player.GiveNamedWeapon(crWeapon, crAmmo)
player.SwitchToWeapon(crWeapon)

Where crWeapon is the name of the weapon and crAmmo is the amount of custom ammo to give. I've tried remote_mines and remote_mine but it just gives an error.
Nevermind, figured it out.