Author Topic: Arguments in tremulous  (Read 3882 times)

googles

  • Posts: 219
  • Turrets: +30/-19
Arguments in tremulous
« on: November 26, 2007, 11:11:35 am »
hey :-D i was just wondering where would i put/make an argument( like /say trem is $s would print trem is awesome!) in tremulous(cgame.qvm?) if you know please give me an example where and an example of an argument i already have the source and all that i just need a little direction :) please dont flame me :(

Lakitu7

  • Tremulous Developers
  • *
  • Posts: 1002
  • Turrets: +120/-73
Re: Arguments in tremulous
« Reply #1 on: November 27, 2007, 05:24:00 am »
Well, with the current state of Trem you know that making a cgame mod is pointless if you ever want anyone to play it.

I don't really know what you're thinking, but an example that simple could be done in just game.qvm via g_cmds.c. The code you're looking for is argc/argv. If you want to use all arguments "ie everything after token #x," look at how g_say works and see what function calls it uses.

If you really want cgame, look at cg_consolecmds.c. It's done pretty similarly there though, I imagine.

/dev/humancontroller

  • Posts: 1033
  • Turrets: +1002/-383
Re: Arguments in tremulous
« Reply #2 on: November 27, 2007, 07:40:50 pm »
So you want to add variable support... A quick look at the source:

In cmd.c (which is part of the tremulous executable, not cgame), there are functions named Cbuf_*(), which are related to command line processing. Console and script commands are executed by adding them to the console buffer (as '\n'-terminated character strings), which are then executed every frame, or when you explicitly call Cbuf_Execute(). To add to the console buffer, use the Cbuf_AddText or Cbuf_InsertText commands, or you can use the Cbuf_ExecuteText to execute-right-now.

That said, inside these 3 latter commands, you can edit and replace the $* characters with characters of the corresponding variable value. Note: for the ease of programming, you can store variables in cvars, named as $*, if you prefer. Note2: I don't see '$' being used anywhere in the command line processing, so normally, '$' will not conflict with anything. (If it will, you'll might want to replace variables in known commands, such as /say. But don't bother yourself with this.)

googles

  • Posts: 219
  • Turrets: +30/-19
Re: Arguments in tremulous
« Reply #3 on: November 27, 2007, 09:36:15 pm »
just to note im modding my client for anyone that doesnt know. I would also like to thank both of you for your advice and direction :)
« Last Edit: November 27, 2007, 09:38:53 pm by googles »