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
python region

 
Post new topic   Reply to topic Printable version
 View previous topic  Some Odd Questions Post :: Post ten years  View next topic  
Author Message
Guest



Offline

PostPosted: Sat Apr 02, 2011 6:09 pm    Post subject: python region Reply to topic Reply with quote

Not sure exactly whats going and and why its not working.

The terminal is telling me;
TypeError: arg isn't a 'region'

But it have added the same region name in DCME.

Code: Show/Hide
def cr (arena, p, bid):
   if mapdata.RegionName (cr):
      chat.SendArenaSoundMessage (arena, 1, "%s Attempted to make a goal within the crease. Goal not counted. Faceoff!" % (p.name))
      balls.SpawnBall (arena, 0)
   return cr


I am not a programmer by any means and just trying to do some things.
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Apr 02, 2011 9:46 pm    Post subject: Reply to topic Reply with quote

I'm no expert on ASSS python, but I think RegionName isn't the method you want. Your code doesn't actually check any coordinates.

Perhaps someone else can shed some light on the correct way to do this.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Sun Apr 03, 2011 12:26 am    Post subject: Reply to topic Reply with quote

One thing that strikes me as weird about your code is the following:
Quote:
def cr (arena, p, bid):
___if mapdata.RegionName (cr):
______chat.SendArenaSoundMessage (arena, 1, "%s Attempted to make a goal within the crease. Goal not counted. Faceoff!" % (p.name))
______balls.SpawnBall (arena, 0)
___return cr

Your argument 'cr' in mapdata.RegionName points right back to the entire function, and so it's invalid. Moreover, your return is also wrong as there's no element named 'cr' within your function to return (If you don't need to return anything, just leave 'return' on its own).

As Dr Brain pointed out, you're never actually comparing any coordinates. All that RegionName does is return the name of a given region. You'll want to use the mapdata function Contains(region,x,y) in conjunction with FindRegionByName(arena, name). The latter allows you to retrieve a region, while the former will search to see if the coordinates x and y are within that region. Thus, you could pair them like this:
Code: Show/Hide
rgn = mapdata.FindRegionByName(arena, "myfirstregionname")
if mapdata.Contains(rgn, 100, 600):
    chat.SendArenaMessage(arena, "Here is a message")

Since I assume you want to check to see whether the player is within the region, you'll have to get their coordinates using p.position[0] (x) and p.position[1] (y), and have them each divided by 16.
Code: Show/Hide
rgn = mapdata.FindRegionByName(arena, "myfirstregionname")
if mapdata.Contains(rgn, p.position[0] / 16, p.position[1] / 16):
    chat.SendArenaMessage(arena, "Here is a message")
Back to top
View users profile Send private message Add User to Ignore List Send email
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: 648 page(s) served in previous 5 minutes.

phpBB Created this page in 0.558757 seconds : 28 queries executed (83.9%): GZIP compression disabled