Ok, so I've coded an advanced Garry's Mod weapon:
[url]http://www.facepunch.com/showthread.php?t=920907[/url]
Thing is, I would prefer if it were in somewhat more... [I]solid[/I] code, if you get me. So I want to convert into C++ to use with Source.
Now I'm pretty sure that there's no Deus Ex Machina for this (that is, a program that converts Lua into C++), but can anyone give me an idea of how I would go about doing this?
I'm new to C++ (although I've read quite a few articles), but I do have a lot of programming experience in other languages so I know how it works and whatnot.
And also, why can I never find an actual command list in C++? It seems to be large blocks of ifs, elses and whatnot, but I don't see that many commands...
So, any ideas?
Don't expect to get much work done for a while. Jumping into the source engine with no real prior experience is like shooting yourself in the foot. I HIGHLY suggest you do a bit of C++ command line work before you go anywhere near a source mod.
OP should listen to post number two. I have been coding in C++ for a while now and there are many differences between it and other languages, especially Lua.
EDIT:
Differences that can add up in something big like the source engine.
[QUOTE=JgcxCub;21453120]but I do have a lot of programming experience in other languages so I know how it works and whatnot.[/QUOTE]
Evidently you don't. There's no such thing as a "command", be it C++ or Lua.
[QUOTE=JgcxCub;21453120]I would prefer if it were in somewhat more... [I]solid[/I] code, if you get me. So I want to convert into C++ to use with Source.[/QUOTE]
You don't know how to write proper Lua yet - an equivalent C++ project simply wouldn't get you anywhere. If you want to write more "solid" code, focus on the language you're currently using - Lua.
[QUOTE=Nipa;21453372]Don't expect to get much work done for a while. Jumping into the source engine with no real prior experience is like shooting yourself in the foot. I HIGHLY suggest you do a bit of C++ command line work before you go anywhere near a source mod.[/QUOTE]
Ok... Right.
Well thanks for that.
Problem is, Source has a lot of examples, ideas, and most of all, I have a great incentive to code for it. Unfortunately, Other than the last point (and even then), I have none of these for... Command line work, whatever that is.
And seriously. Where are the commands in C++? \_(O_o)_/
**EDIT**
[QUOTE=jA_cOp;21453855]Evidently you don't. There's no such thing as a "command", be it C++ or Lua.
[/QUOTE]
Oh, spare me your elitism. Function, for all I care. That's what it was called in other programming languages. I can still use them while using a different name.
[QUOTE=jA_cOp;21453855]
You don't know how to write proper Lua yet - an equivalent C++ project simply wouldn't get you anywhere. If you want to write more "solid" code, focus on the language you're currently using - Lua.[/QUOTE]
Look, I'm ok at writing Lua. Thanks for your help anyway.
By solid code, I meant more low level stuff. Obviously, you can't get more high level than Lua (for Source, that is).
They're functions, not commands.
[QUOTE=JgcxCub;21453873]Oh, spare me your elitism. Function, for all I care. That's what it was called in other programming languages. I can still use them while using a different name.[/QUOTE]
It's called a function in both C++ and Lua... and almost every other language I know. The only family of languages I can think of with "commands" are shell scripting languages.
That's not the point, though, the point is, if you're unable to find a "command list for C++", you don't understand basic C++ and you're probably far from fluent in Lua; hence there's no benefit from moving your project to a different language.
If you were looking for a standard library reference for the C++ language, [url=http://www.cplusplus.com/reference/]this[/url] is a pretty decent overview. The Lua equivalent would be the [url=http://www.lua.org/manual/5.1/index.html]Lua reference manual[/url]. The only difference between a standard library and any other library is that the standard library is guaranteed to be present in a language-compliant implementation; you can find third-party libraries for pretty much anything with both Lua and C++.
[QUOTE=JgcxCub;21453873]Look, I'm ok at writing Lua. Thanks for your help anyway.
By solid code, I meant more low level stuff. Obviously, you can't get more high level than Lua (for Source, that is).[/QUOTE]
You don't need any lower level code for this SWEP. You can write just as efficient and safe code in Lua - but a lot faster.
I understand that you want it to be more lower-leveled, but there's no point. EVERY other SWEP works fine with LUA. Why do you care?
It doesn't sound like you know much about C++ at all. Do you know how to work with pointers & references? Are you familiar with object-oriented programming concepts like classes, inheritance, polymorphism, and encapsulation? Are you familiar with generic programming concepts like class,method, & function templates?
I don't really see the point in writing LUA-style code in C++. You would design software differently with C++ , using the features of the language.
With LUA, most of the time you're just using an API to call compiled C++ methods, so unless you're doing an operation that's particularly resource-intensive, I don't know if there's much to gain.
[QUOTE=Metanoia;21461379]It doesn't sound like you know much about C++ at all. Do you know how to work with pointers & references? Are you familiar with object-oriented programming concepts like classes, inheritance, polymorphism, and encapsulation? Are you familiar with generic programming concepts like class,method, & function templates?
I don't really see the point in writing LUA-style code in C++. You would design software differently with C++ , using the features of the language.
With LUA, most of the time you're just using an API to call compiled C++ methods, so unless you're doing an operation that's particularly resource-intensive, I don't know if there's much to gain.[/QUOTE]
Yeah, there's nothing to gain with a project like this. He'd need a lot more code, there would be a much bigger potential for bugs, and if he ported it best he could directly from idiomatic Lua, chances are the Lua version would be a lot faster.
(And are you guys intentionally mistyping it as "LUA"? :sigh: )
[QUOTE=jA_cOp;21454202]It's called a function in both C++ and Lua... and almost every other language I know. The only family of languages I can think of with "commands" are shell scripting languages.
That's not the point, though, the point is, if you're unable to find a "command list for C++", you don't understand basic C++ and you're probably far from fluent in Lua; hence there's no benefit from moving your project to a different language.[/QUOTE]
Thanks for the help, by the way.
I didn't say I could understand C++ at the moment. I wasn't born with any kind of programming knowledge; I have to learn somewhere. So far, the only examples or anything I can find are in Source.
The reason I want to move my SWep to C++ is because, I'm pretty sure, Lua is not taken that seriously when it comes to programming. The only game that I play that uses Lua is Gmod: since without GMod, my Lua code would be useless, I'd prefer something with a larger platform. It's not because I want to feel safe working with a code I already know reasonably well.
Tl;dr: I can't do Source programming with Lua.
Ps. Despite being able to find the GMod lua reference easily (with all the functions and whatnot), I still never really found (by my own search) a decent C++ manual. Not sure why.
**EDIT** In response...
[QUOTE=Metanoia;21461379]It doesn't sound like you know much about C++ at all.[/QUOTE]
Already stated that.
[QUOTE=Metanoia;21461379]Do you know how to work with pointers & references?[/QUOTE]
Just a little.
[QUOTE=Metanoia;21461379]Are you familiar with object-oriented programming concepts like classes, inheritance, polymorphism, and encapsulation?[/QUOTE]
Barely.
[QUOTE=Metanoia;21461379]Are you familiar with generic programming concepts like class, method, & function templates? [/QUOTE]
Reasonably well, yes.
[url=http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games]Lua is the most popular scripting language in the video game industry[/url]. That aside, it's about choosing the right language for the job; if your goal was to create a cool sword on the Source engine, Lua with the Garry's Mod platform is indeed the tool that will get the job done. Using the Source mod interfaces in C++ to do the equivalent takes longer and is a much more tedious process.
If you want to make your own Source mod with this weapon, then naturally you can't use Garry's Mod and its Lua platform, but the Source engine is a terrible entry point for learning C++.
edit:
Besides, learning Lua properly will help you a lot when trying out other programming languages. Also, Lua is a pretty awesome programming language stand-alone - there's a myriad of libraries and with runtimes like LuaJIT, performance is even less of a problem (the standard Lua implementation is one of the fastest interpreted languages out there to begin with), leaving lots of room for more performance critical applications like games and other rendering to be done in Lua.
[QUOTE=jA_cOp;21461443]
(And are you guys intentionally mistyping it as "LUA"? :sigh: )[/QUOTE]
fuck. bad habit that I've been trying to shake off. It's hard, because for a long time I've lurked around the 'LUA Scripting' forum here. That should be fixed
@OP just to add on to my previous post, I didn't mean to quiz you on C++ & come off as an arrogant prick. I guess the point I wanted to make is that you should know exactly why C++ is useful over other languages before choosing it for a project. If you're familiar with the features of the language you'll know what you would/wouldn't want to do with it, and you'll know how your app design will change when you switch from a light scripting language to C++
I think coding specific weapons in C++ is overkill and that stuff should be scripted (though the default HL2 weapons aren't scripted IIRC, so it's subjective and I should probably shut up). the underlying code that many weapons share is not overkill for c++, though. so maybe it would be reasonable to write a melee combat system in C++ that would apply to many types of weapons
I'd suggest just grabbing the SDK and spending a lot of time reading code.
also, [url]http://developer.valvesoftware.com/wiki/Category:Programming[/url]
Wouldn't be better to create the gamemode or mod you want in Lua? Especially since you started work on that sword there?
[QUOTE=jA_cOp;21461583][url=http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games]Lua is the most popular scripting language in the video game industry[/url]. That aside, it's about choosing the right language for the job; if your goal was to create a cool sword on the Source engine, Lua with the Garry's Mod platform is indeed the tool that will get the job done. Using the Source mod interfaces in C++ to do the equivalent takes longer and is a much more tedious process.
If you want to make your own Source mod with this weapon, then naturally you can't use Garry's Mod and its Lua platform, but the Source engine is a terrible entry point for learning C++.
edit:
Besides, learning Lua properly will help you a lot when trying out other programming languages. Also, Lua is a pretty awesome programming language stand-alone - there's a myriad of libraries and with runtimes like LuaJIT, performance is even less of a problem (the standard Lua implementation is one of the fastest interpreted languages out there to begin with), leaving lots of room for more performance critical applications like games and other rendering to be done in Lua.[/QUOTE]
I'm pretty sure everything you've said about Lua is true. However, I just want to move on. There's really not much more I can do for the sword, and I'm only really interesting in scripting weapons. Hence my question.
You can do a a lot more in Lua. I've seen some awesome SWEPs around these here forums.
One can't say you can do a lot more in Lua, when the whole interface is not available in the Lua implementation. :)
You will do a lot more with Lua*
Better :D
Guys...
:doh:
I have nothing against Lua. I like Lua. Hell, I [B]love[/B] Lua. I just want something new. I know C++ is a highly respected language, used for a lot of things, so I was hoping that I could use this as a springboard for other stuff.
And the reason I wanted to use Source, I repeat, is because I have easily available examples, and most of all, [B]inspiration[/B] and [B]motivation[/B] to do the work. As silly as this sounds, I'm not too sure what I could program in C++ that would sustain my interest long enough for me to do any work on it. At least with Source, I have something to work off, and I know where to start.
Motivation to post topics maybe... Not really sure what you're actually aiming to get out of this. There's no c++ for source tutorial, first you learn c++ and once you know it then you can start to understand the source engine sdk and then just code pretty much.
And if by "solid code" you mean something more than a wildly flailing view model giving out arbritrary physics pushes, then prepare to be way in over your head.
[QUOTE=Pj The Dj;21487932]And if by "solid code" you mean something more than a wildly flailing view model giving out [B]arbitrary[/B] physics pushes, then prepare to be way in over your head.[/QUOTE]
[B]Jesus H Christ[/B]. What is your problem? I'm ambitious. I don't care if it's over my head. I want to learn.
And seriously, was that necessary? "Wildly flailing viewmodel giving out [B]arbitrary[/B] physics pushes" is both unnecessarily harsh and, judging from the amount of positive reviews of it, incorrect. In my opinion, the physics adds a sense of realism, considering the power at which you are swinging the sword, but if crappy 5 second melee weapons are your cup of tea, oh well.
I must admit, arbitrary was hugely unnecessary. Really added a sting ;)
Seriously, dude, do you not think this forum is populated with ambitious, intelligent people? Listen to them! They are trying to help you. You are correct in saying that you are in over your head, and that isn't something to be proud of. If you are in over your head, normally you drown.
If you do not listen to these people, you will stumble into a project that is much to complex for you, and you will drown.
If you need to be making games to be able to motivate yourself, you are not cut out to be a programmer! Everybody here enjoys programming itself, as an activity, and they will quite happily program something for the love it, and for the hell of making anything at all.
Everybody starts small, or, if they don't, then they are intelligent enough to find the relevant examples themselves and play with them. And this often leads to people becoming worse coders than people who do the tutorials, or, even better, buy a book, and take the time to go through it.
Listen to the advice. We are trying to help you.
[QUOTE=TheBoff;21489173]I must admit, arbitrary was hugely unnecessary. Really added a sting ;)
Seriously, dude, do you not think this forum is populated with ambitious, intelligent people? Listen to them! They are trying to help you. You are correct in saying that you are in over your head, and that isn't something to be proud of. If you are in over your head, normally you drown.
If you do not listen to these people, you will stumble into a project that is much to complex for you, and you will drown.
If you need to be making games to be able to motivate yourself, you are not cut out to be a programmer! Everybody here enjoys programming itself, as an activity, and they will quite happily program something for the love it, and for the hell of making anything at all.
Everybody starts small, or, if they don't, then they are intelligent enough to find the relevant examples themselves and play with them. And this often leads to people becoming worse coders than people who do the tutorials, or, even better, buy a book, and take the time to go through it.
Listen to the advice. We are trying to help you.[/QUOTE]
Thank you, at least you were a bit more objective this time.
Thing is, I'm really not too sure where to start considering C++. I mean, writing small applications that help me word process or sort my files is hardly that exciting. On the other hand, the library for Source programming has already been done for me: at least there's something to do there. I can't really find where to start with normal apps.
[QUOTE=cpf;21453956]They're functions, not commands.[/QUOTE] Or subroutines if they don't return anything whichever suits your fancy.
[editline]09:27PM[/editline]
[QUOTE=jA_cOp;21461583][URL="http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games"]Lua is the most popular scripting language in the video game industry[/URL]. That aside, it's about choosing the right language for the job; if your goal was to create a cool sword on the Source engine, Lua with the Garry's Mod platform is indeed the tool that will get the job done. Using the Source mod interfaces in C++ to do the equivalent takes longer and is a much more tedious process.
If you want to make your own Source mod with this weapon, then naturally you can't use Garry's Mod and its Lua platform, but the Source engine is a terrible entry point for learning C++.
edit:
Besides, learning Lua properly will help you a lot when trying out other programming languages. Also, Lua is a pretty awesome programming language stand-alone - there's a myriad of libraries and with runtimes like LuaJIT, performance is even less of a problem (the standard Lua implementation is one of the fastest interpreted languages out there to begin with), leaving lots of room for more performance critical applications like games and other rendering to be done in Lua.[/QUOTE]
Yea, LuaJIT can compete in speed and such to C#, atleast running on Mono don't know about Microsoft's stuff but I'd expect them to benchmark similarly.
[url]http://developer.valvesoftware.com/wiki/Adding_weapons[/url]
This link might be able to tell you what you want to do. Although you will have to re-write a lot of the logic, you might not be able to use the same concepts. I think that's why these people are telling you that it isn't so cut and dry.
Sorry, you need to Log In to post a reply to this thread.