Author |
Message |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Sun Jul 09, 2006 9:43 pm Post subject: Globalizing Strings in python |
 |
|
|
|
Yea It seems python is a bit different when it comes to globalizing strings.
I put captain = "None" at the top of my python file, later on when someone types ?cap I make it do captain = p.name.
I made it send a message with the captain name in the same def.
Then I use my command to view the current captain and it resets to none.
How can I globalize strings easily in asss?
****EDIT:****
I thought I figured it out but it was per player. I need to make it do it arena wide. |
|
Back to top |
|
 |
Chambahs Power attack

Joined: Jun 19 2005 Posts: 820 Offline
|
Posted: Mon Jul 10, 2006 12:22 am Post subject: |
 |
|
|
|
Posting the code would help me out to figuring out the problem. |
|
Back to top |
|
 |
xsp0rtsfanx Seasoned Helper

Age:36 Gender: Joined: Dec 27 2004 Posts: 168 Location: California Offline
|
Posted: Mon Jul 10, 2006 12:27 am Post subject: |
 |
|
|
|
he had it up but he figured it out |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Mon Jul 10, 2006 1:14 am Post subject: |
 |
|
|
|
I had it up but it was only for that player. I need to make it arena wide. The code is on my vmware so copying and pasting is hard. Anyways it's a pretty simple question, how do you globalize a string for a module?
def c_cap(cmd, params, p, targ): <-- notice no arena
arena.sd_captainA = p.name
|
How can I make it so arena is added with this. Arena won't work when adding it to that def. Any way around this. I can't do another def like
def cap(arena):
arena.sd_captainA = p.name <--notice no p defined either.
|
What can I do? |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Mon Jul 10, 2006 10:58 am Post subject: |
 |
|
|
|
I think if you want to modify globals you need to make them lists, otherwise they are read only.
See: http://forums.minegoboom.com/viewtopic.php?p=29060#29060
You should stick with storing data in the arena object, since a zone can have many arenas open at once, you wouldn't want a captain in one arena to have control over all the arenas they aren't even in. |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Mon Jul 10, 2006 7:14 pm Post subject: |
 |
|
|
|
Im not really sure on how to put players into a list in python. I was not aware strings were read only. What I am doing is a squad duel plugin so I need two people to be captains upon them typing ?cap. I'm reading the example of lists on some website.
3.3 Mutability
Python data structures are either mutable (changeable) or not. Strings are not mutable - once created they cannot be modified in situ (though it is easy to create new, modified versions). Lists are mutable, which means lists can be changed after being created; a particular element of a list may be modified. Either single elements or slices of lists can be modified by assignment:
>>> x
[1,4,9,'new end of list']
>>> x[2] = 16
>>> x
[1,4,16,'new end of list']
>>> x[2:3] = [9,16,25]
[1,4,9,16,25,'new end of list']
|
I am guessing I can use p.arena.sd_captainA = [p.name] ???
This kind of thing is making me lean towards C. |
|
Back to top |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Mon Jul 10, 2006 9:29 pm Post subject: |
 |
|
|
|
Java Strings are immutable as well, nothing new there.
Probably shouldn't just use the name anyways though. |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Mon Jul 10, 2006 10:22 pm Post subject: |
 |
|
|
|
I want to be able to change the captainA and captainB. Is that supose to be hard.
Hmm this might be some help for me. I don't want to open up vmware if this isn't gonna work but im gonan try http://skunkweb.sourceforge.net/PyDO/node17.html |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Tue Jul 11, 2006 6:59 pm Post subject: |
 |
|
|
|
LOL. Ok good. I was like wth. I spent forever trying to figure it out. Thanks for letting me know. Smong your always cool with me. Thanks. |
|
Back to top |
|
 |
|