GoldenEye: Source Forums

  • November 22, 2024, 11:35:57 am
  • Welcome, Guest
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Global Variables in Python?  (Read 7784 times)

0 Members and 1 Guest are viewing this topic.

WNxEuphonic

  • 00 Agent
  • ***
  • Posts: 217
  • Reputation Power: 106
  • WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!
  • Offline Offline
    • Euphonic.dev
Global Variables in Python?
« 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?

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: Global Variables in Python?
« Reply #1 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
Logged

WNxEuphonic

  • 00 Agent
  • ***
  • Posts: 217
  • Reputation Power: 106
  • WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!
  • Offline Offline
    • Euphonic.dev
Re: Global Variables in Python?
« Reply #2 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.

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: Global Variables in Python?
« Reply #3 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.
Logged

WNxEuphonic

  • 00 Agent
  • ***
  • Posts: 217
  • Reputation Power: 106
  • WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!WNxEuphonic is awe-inspiring!
  • Offline Offline
    • Euphonic.dev
Re: Global Variables in Python?
« Reply #4 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.
« Last Edit: February 15, 2011, 07:30:19 am by WNxEuphonic »
Logged
Pages: [1]   Go Up