Forum

Coding Syntax

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Coding Syntax

Postby frsotywinters » Tue Feb 21, 2006 3:40 pm

Hey im kinda new to the whole QuakeC programming experience, i've written a little piece of code and was just wondering if i have the fundamentals right, like is there anything i've left out that should be in every QuakeC code written (like leaving out a main method or return type in java)

Anyway heres how my code basically looks, any feed back would be greatly appreciated!!

void main() =
{

map myMap; //Define the map to be used


// Create a dynamic entity and make it static cause i want it for the whole game

entity a_1 = spawn();
a_1.movetype = 2;
a_1.solid = 1;
setmodel(a_1, "progs/entity.mdl");
setsize(a_1, VEC_MAX);
setorigin(a_1, x y z);
makestatic(a_1);


//Some code to specify how my entites behave when interacted with



} //End my main method
frsotywinters
 
Posts: 14
Joined: Wed Jan 25, 2006 11:34 am

Re: Coding Syntax

Postby lth » Tue Feb 21, 2006 5:10 pm

frsotywinters wrote:map myMap;


This line doesn't make a whole heap of sense - you need to declare what datatype you're using from QuakeC's limited selection of: float, string, vector or entity.
User avatar
lth
 
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Re: Coding Syntax

Postby RenegadeC » Tue Feb 21, 2006 6:23 pm

frsotywinters wrote:void main() =
{
map myMap;
entity a_1 = spawn();
a_1.movetype = 2;
a_1.solid = 1;
setmodel(a_1, "progs/entity.mdl");
setsize(a_1, VEC_MAX);
setorigin(a_1, x y z);
makestatic(a_1);
}


Corrected:

void main() =
{
local entity a_1;

// map myMap; This is invalid, if you want it to see what map you're currently on then do this:

if (world.model == "maps/blah.bsp")
do_stuff();

a_1 = spawn();
a_1.movetype = 2; // use MOVETYPE_BLAH in defs.qc for easier reading
a_1.solid = 1; // Same dealie, SOLID_NOT for example..
setmodel(a_1, "progs/entity.mdl"); // Right
setsize(a_1, VEC_MAX); // Wrong, it's setsize (entity, lower bounding box, upper bounding box);

setorigin(a_1, x y z); // fill x,y,z origin in or use entity.origin
makestatic(a_1); // You should be aware that makestatic entities
// cannot have think functions, makestatic is good for detail objects! Also remember only 128 static entities can be placed in a
// map unless you're using darkplaces which has zero limits as far as I know! Makestatic entities are also not solid.

}; // put a semicolon ; at the end, it's just prettier and people will thank you for it...
User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest