Server Help

ASSS Custom Projects - <py> dodgeball

xsp0rtsfanx - Sat Mar 18, 2006 6:15 pm
Post subject: <py> dodgeball
Ok so this is my first attempt at a module.. and I know there is a syntax error and what line but the error is not marking the code itself.. but the whitespace after the code. It's attached. Line 25 if you people could help me get it working perfectly I'd appreciate it.


PS. there are no commands due to the fact I was making this module for Hockey Zone and there are modules made to set commands up for the module without putting them in the actual code.
Mr Ekted - Sat Mar 18, 2006 6:29 pm
Post subject:
I don't know python, but from the syntax I see, it looks like inconsistent use of the colon after an if.
xsp0rtsfanx - Sat Mar 18, 2006 6:46 pm
Post subject:
Oh shit I completely didn't notice that. That's probably it.
xsp0rtsfanx - Sun Mar 19, 2006 1:28 am
Post subject:
Update: I figured out my problems from the first post.. I just can't get the the attach to work and I can't figure out the code for detach :/
Smong - Sun Mar 19, 2006 8:51 am
Post subject:
There's some stuff here Wiki:Writing Modules In Python about attaching modules and other things you can do in python.
xsp0rtsfanx - Sun Mar 19, 2006 10:31 pm
Post subject:
I've already been to the site but I'm getting errors with my attach and I'm not sure what to put in the detach. Would the detach have the callbacks and have it = None?
Chambahs - Sun Mar 19, 2006 11:14 pm
Post subject:
def mm_attach(arena):
arena.wpn_cb1 = reg_callback(CB_KILL, kill, arena)
#arena.wpn_oldfm = get_interface(I_FREQMAN, arena)
#arena.wpn_myfm = reg_interface(I_FREQMAN, myfm, arena)

# make one timer only
if wpn_bigref[0] == None:
wpn_bigref[0] = make_region_timer(500, 100)
wpn_bigref_count[0] += 1

def mm_detach(arena):
for attr in ['cb1', 'oldfm', 'myfm']:
try: delattr(arena, 'wpn_' + attr)
except: pass

wpn_bigref_count[0] -= 1
if wpn_bigref_count[0] <= 0:
wpn_bigref[0] = None

Theres some code from a module of UT, showing how the attach and detach looks on some of our modules. Also, I am rewritting your whole module, but it turns up that I need some help as well. Ill try to finish it by tomarrow. (Monday)
Smong - Mon Mar 20, 2006 6:04 am
Post subject:
In Chambahs example ignore the stuff about the region timer (that's there because there is no region callback for py). To see another example of attach/detach with proper indenting look at the py modules that come with asss. Such as bin/fg_wz.py.

Another thing is you should be prefixing your per arena/player data with the name of your module to prevent clashes with other modules. For example: arena.db_timer where db_ means dodgeball.
Chambahs - Mon Mar 20, 2006 1:48 pm
Post subject:
Was going to finish the dodgeball module i was working on, but it seems that smong beat me to the punch, and his is better. So check his out to see what can be done to make yours better.
Smong - Mon Mar 20, 2006 5:30 pm
Post subject:
Well I was never planning on releasing it since I want to see other people working on asss. If anyone still wants to see it they can pm me.
xsp0rtsfanx - Tue Mar 21, 2006 6:13 pm
Post subject:
Ok so I have the code working but it wont attach (no errors it just wont attach). Help please
Chambahs - Tue Mar 21, 2006 11:45 pm
Post subject:
Hmm, i dont think that attach and detach code should be in there.
xsp0rtsfanx - Tue Mar 21, 2006 11:46 pm
Post subject:
what do you mean? how else would i load the module tongue.gif
Chambahs - Tue Mar 21, 2006 11:57 pm
Post subject:
About the detach and attach code, when I started python, I never used it. And when I did decide to use it, I always use this:

def mm_attach(arena):
# do stuff with arena
def mm_detach(arena):
# undo stuff

In my opinion I believe that the attach and detach code is specifically there so if you have settings that change or things you define, you put them in there. Let me give you an example of how -I- use it.


def blah(arena):
this code will make settings so 2 repels are max
this code has a callback in it

attach code:
repels = max when the code is attached
calls a callback when it attaches

detach code:
repels = back to normal settings because its detached
callback isnt called when detached


That was lamens terms. Now I will show you actual code that shows you what I meant.


def mm_attach(arena):
arena.leader_killcb = reg_callback(CB_KILL, kill, arena)
arena.leader_cmd1 = add_command("startgame", c_start_game, arena)
arena.leader_cmd2 = add_command("stopgame", do_game_over, arena)

def mm_detach(arena):
arena.leader_killcb = None
arena.leader_cmd1 = None
arena.leader_cmd2 = None


Still keep in mind im no expert, but I should be on the right track.
Chambahs - Wed Mar 22, 2006 12:00 am
Post subject:
Also, sorry for the double post. But here is an attempt I made on the dodgeball module. Ive never done anything with balls before, so I was kind of shooting in the dark. Its not finished and I doubt all of it is good coding but meh, just showing ya what I tried.
Smong - Wed Mar 22, 2006 10:54 am
Post subject:
xsp0rtsfanx wrote:
Ok so I have the code working but it wont attach (no errors it just wont attach). Help please
You shouldn't have to use a try/except block in mm_attach.

There's a lot of things wrong in your module. I'll start from the top:

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group