Author |
Message |
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 8:46 am Post subject: Python or C? |
|
|
|
|
I'm just wondering what would probably be easier to learn? I know the basics of python, but that does not help me at all when it comes to making modules. I know a little c (A lot less c then python). I've been wanting to code a module for a while, but when I try to I get very confused after the 'from asss import *' in Python.
Fail, yes I know.
I would like some opinions from you guys since you guys are very good at coding, on what would probably be the easiest to make a module in for a nub like me.
Last edited by Acer1001 on Fri Aug 14, 2009 12:06 pm, edited 1 time in total |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Fri Aug 14, 2009 10:39 am Post subject: |
|
|
|
|
C++ or C?
For ASSS, I originally started off with Python because to me it was much easier to understand and simpler to modify. But at the time I started to use it, it had a number of shortcomings; there weren't enough examples, and the wiki tutorial felt incomplete. Later on I was passed Devastation's ASSS modules so that we could continue trying to make the transition, but everything was in C. Quite a few things available in C weren't possible in Python; at least, not without constantly making changes to pymod.c, which to me wasn't a feasible option. This was the final straw that made me switch to using C.
Personally, I think Python is a good starting point, with Python modules being easier to load/unload and make modifications in ASSS. In the long run though, you'll likely inevitably need to use or understand C. To someone who's new at coding, writing C modules for ASSS can be a little bit intimidating at first. But every trial and error will definitely help you learn and understand how things work over time.
So in all, Python gets my vote for ease of use, but I recommend also going for C. Once you learn one or the other, switching between either one isn't so difficult. |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Aug 14, 2009 11:07 am Post subject: |
|
|
|
|
Ultimately, it depends on what you want to do. If you're looking to do simple bot replacement on ASSS, then I'd suggest python.
If, on the other hand, you're looking to push boundaries on what can be done with ASSS and SubSpace, then you're going to need C. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 12:03 pm Post subject: |
|
|
|
|
Alright, so in the end I'll really need C. So I guess I have to start learning that.
What do you guys suggest, online tutorials or school?
I learned the very basics from online. But that would help at all with creating modules for Asss. |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Fri Aug 14, 2009 1:23 pm Post subject: |
|
|
|
|
To be honest, I had never learned C before diving into ASSS. I'm terrible with tutorials, so I learn by looking at what other people have done and by spending a lot of time searching for stuff (whether on google or this forum). Asking someone else the occasional question also helped.
It ultimately comes down to how you prefer to learn. If you're better at following tutorials, then go for it. School could be an interesting option, but note that your class may go at a slow pace and could possibly be more theory than hands-on depending on your teacher.
The ASSS wiki has a lot of good information on how to write a module and how to compile it. You should check it out. If you don't have one already, you should grab yourself a C IDE such as wxDev-C++ (any other will also do) to be able to compile a module. Start off with something simple like writing a module that sends an arena message when you type a ?command. Then slowly work your way around from there. Everything you learn at first will seem impractical and useless, but chances are you'll find a use for them sometime later on. |
|
Back to top |
|
|
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 1:46 pm Post subject: |
|
|
|
|
Hm, I'm using Devcpp right now. I think I should probably switch to something else.
It's nice that there are templates but, it's very hard to understand. I guess it's just trial and error now. |
|
Back to top |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Fri Aug 14, 2009 1:51 pm Post subject: |
|
|
|
|
My first experiences with C came from building my own bots in C, then my own bot core. Most of that was spent looking at what others did, modifying some stuff compiling, seeing the errors, and trying again until it works.
In hindsight, it was an OK way to start, but I really picked up some bad habits. At the very least, check out the C Programming Language book. If you are lucky, it might be in your local library. It won't tell you how to be a good programmer, or how to implement algorithms, but it will explain the syntax so you won't spend your first week figuring out compile time errors. |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Fri Aug 14, 2009 1:52 pm Post subject: |
|
|
|
|
If you're using (wx)Dev-Cpp, don't forget this part. If it's highlighting asss.h, then this means it can't find the file. You need to tell it where to find the file (i.e. include directory). Check out Step #7 - make sure you put it in include directories, and not library directories.
Edit: woah I have no clue what I'm replying to anymore. |
|
Back to top |
|
|
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 2:03 pm Post subject: |
|
|
|
|
Hakaku wrote: | If you're using (wx)Dev-Cpp, don't forget this part. If it's highlighting asss.h, then this means it can't find the file. You need to tell it where to find the file (i.e. include directory). Check out Step #7 - make sure you put it in include directories, and not library directories.
Edit: woah I have no clue what I'm replying to anymore. |
Yeah I edited it, cause I thought I knew how to fix it. But, it didn't work, I'll look over the tutorial again.
I might just go out a buy a C book of I cannot get one for free some where. Just to give me even more background info. :/
Edit: I'm getting a little bit a head of my self but, I see chat = mm->GetInterface(I_CHAT,ALLARENAS). If I wanted to add bounty or something would it be cfg = mm->GetInterface(I_CONFIG, ALLARENAS) ?
Edit2: Also I have the asss.h in it and the directories. But it still says asss.h: No such file or directory.
Could it be that I'm suppose to be saving it in the asss folder? |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:24 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Fri Aug 14, 2009 2:52 pm Post subject: |
|
|
|
|
What Bak said. You just need to link the folder it's contained in (all of that info is already done in the tutorial). In your first screenshot, asides pthread, the rest should not be there. In your second screenshot, you did exactly what I told you not to You put it in the sub-tab called "Library Directories"; you really want to put all those links in the little tab named "Include Directories". |
|
Back to top |
|
|
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 2:57 pm Post subject: |
|
|
|
|
Yeah, I got the asss.h to work now.
I don't know why I keep on getting errors with this code.
#include asss.h
// Interfaces
local Imodman *mm;
local Ichat *chat;
// Functions
local void ShipChange(Player *p,int newship, int newfreq)
{
chat->SendMessage(p,"You have changed ships.");
}
// The entry point:
EXPORT int MM_template(int action, Imodman *mm_, Arena *arena)
{
int rv = MM_FAIL; // return value
if (action == MM_LOAD)
{
mm = mm_;
chat = mm->GetInterface(I_CHAT,ALLARENAS);
if (!chat) // check interfaces
rv = MM_FAIL;
else
{
mm->RegCallback(CB_SHIPCHANGE, ShipChange, ALLARENAS);
rv = MM_OK;
}
}
else if (action == MM_UNLOAD)
{
mm->UnregCallback(CB_SHIPCHANGE, ShipChange, ALLARENAS);
mm->ReleaseInterface(chat);
rv = MM_OK;
}
return rv;
} |
I got to go to work. I'll be back later and see what I can read up about syntax error before the Ichat |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Fri Aug 14, 2009 3:14 pm Post subject: |
|
|
|
|
Post your error log. It may be that either you misconfigured something, or it could be a problem with Dev-Cpp itself. |
|
Back to top |
|
|
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 3:21 pm Post subject: |
|
|
|
|
Compiler: Default GCC compiler
Building Makefile: "C:\Users\JP\Desktop\Makefile.win"
Executing make...
mingw32-make.exe -f "C:\Users\JP\Desktop\Makefile.win" all
gcc.exe -c Untitled1.c -o Output/MingW/Untitled1.o -I"C:/Program Files/Dev-Cpp/Include" -DBUILDING_DLL=1 -fexpensive-optimizations -O3
Untitled1.c:1:10: #include expects "FILENAME" or <FILENAME>
Untitled1.c:2: error: syntax error before '}' token
Untitled1.c:4: warning: data definition has no type or storage class
Untitled1.c:5: error: syntax error before "Ichat"
Untitled1.c:5: warning: data definition has no type or storage class
Untitled1.c:8: error: syntax error before "void"
Untitled1.c:8: error: syntax error before '*' token
Untitled1.c: In function `ShipChange':
Untitled1.c:10: error: request for member `SendMessage' in something not a structure or union
Untitled1.c:10: error: `p' undeclared (first use in this function)
Untitled1.c:10: error: (Each undeclared identifier is reported only once
Untitled1.c:10: error: for each function it appears in.)
Untitled1.c: At top level:
Untitled1.c:14: error: syntax error before "int"
Untitled1.c:14: error: syntax error before "Imodman"
Untitled1.c: In function `MM_template':
Untitled1.c:16: error: `MM_FAIL' undeclared (first use in this function)
Untitled1.c:18: error: `action' undeclared (first use in this function)
Untitled1.c:18: error: `MM_LOAD' undeclared (first use in this function)
Untitled1.c:20: error: `mm_' undeclared (first use in this function)
Untitled1.c:22: error: request for member `GetInterface' in something not a structure or union
Untitled1.c:22: error: `I_CHAT' undeclared (first use in this function)
Untitled1.c:22: error: `ALLARENAS' undeclared (first use in this function)
Untitled1.c:28: error: request for member `RegCallback' in something not a structure or union
Untitled1.c:28: error: `CB_SHIPCHANGE' undeclared (first use in this function)
Untitled1.c:29: error: `MM_OK' undeclared (first use in this function)
Untitled1.c:32: error: `MM_UNLOAD' undeclared (first use in this function)
Untitled1.c:34: error: request for member `UnregCallback' in something not a structure or union
Untitled1.c:35: error: request for member `ReleaseInterface' in something not a structure or union
mingw32-make.exe: *** [Output/MingW/Untitled1.o] Error 1
Execution terminated
Compilation Failed. Make returned 2
Alright, rides here, gotto go. Be back later. |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Fri Aug 14, 2009 3:31 pm Post subject: |
|
|
|
|
Change your first line back to
|
|
Back to top |
|
|
Acer1001 Newbie
Joined: Jun 13 2008 Posts: 20 Offline
|
Posted: Fri Aug 14, 2009 5:33 pm Post subject: |
|
|
|
|
Alright. Well thanks, now it's working properly. =p Just miss read a few things. |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:24 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Aug 14, 2009 6:16 pm Post subject: |
|
|
|
|
yes, the line
"Untitled1.c:1:10: #include expects "FILENAME" or <FILENAME> "
is trying to tell you to put quotes around your filename(asss.h)
in general the first error is usually the cause of the problem (although there also may be multiple things wrong) |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri Aug 14, 2009 10:45 pm Post subject: |
|
|
|
|
yeah, with one error the compiler gets his syntax all messed up and is flailing blindly through the code, popping errors here and there.
That applies to pretty much every programming language too _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
|