Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Globalizing Strings in python

 
Post new topic   Reply to topic Printable version
 View previous topic  module uploading Post :: Post ASSS Errors  View next topic  
Author Message
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Sun Jul 09, 2006 9:43 pm    Post subject: Globalizing Strings in python Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Chambahs
Power attack
Power attack


Joined: Jun 19 2005
Posts: 820
Offline

PostPosted: Mon Jul 10, 2006 12:22 am    Post subject: Reply to topic Reply with quote

Posting the code would help me out to figuring out the problem.
Back to top
View users profile Send private message Add User to Ignore List
xsp0rtsfanx
Seasoned Helper


Age:36
Gender:Gender:Male
Joined: Dec 27 2004
Posts: 168
Location: California
Offline

PostPosted: Mon Jul 10, 2006 12:27 am    Post subject: Reply to topic Reply with quote

he had it up but he figured it out
Back to top
View users profile Send private message Add User to Ignore List MSN Messenger
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Jul 10, 2006 1:14 am    Post subject: Reply to topic Reply with quote

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?

Code: Show/Hide

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

Code: Show/Hide

def cap(arena):
   arena.sd_captainA = p.name  <--notice no p defined either.


What can I do?
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Jul 10, 2006 5:35 am    Post subject: Reply to topic Reply with quote

FIXED!

I decided to use p.arena.sd_captainA.
It works. It only works in sub-arenas but I was gonna make it a squad duel thing anyways. It's only in ?go sd.

So everything works. For those who are new like me I will show you the code.

Python's way of globalizing strings is a lot different from java and C++, you can't just stick the string at the top of the source.

Code: Show/Hide

    p.arena.sd_captainA = p.name


I didn't post the full code because its too long and not needed.
So I seem to slowly be learning the way asss works with python.

Wish me luck!
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Mon Jul 10, 2006 10:58 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Jul 10, 2006 7:14 pm    Post subject: Reply to topic Reply with quote

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.


Code: Show/Hide

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
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Muskrat
Server Help Squatter


Age:38
Joined: Aug 24 2004
Posts: 829
Location: Swamp
Offline

PostPosted: Mon Jul 10, 2006 9:29 pm    Post subject: Reply to topic Reply with quote

Java Strings are immutable as well, nothing new there.

Probably shouldn't just use the name anyways though.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Jul 10, 2006 10:22 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Tue Jul 11, 2006 10:15 am    Post subject: Reply to topic Reply with quote

Sorry if I confused you, your original code was correct:
Code: Show/Hide
arena.sd_captainA = p.name

Even if strings are immutable you can still assign values to arena.sd_captainA as many times as you like.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Tue Jul 11, 2006 6:59 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 48 page(s) served in previous 5 minutes.

phpBB Created this page in 0.472222 seconds : 35 queries executed (93.8%): GZIP compression disabled