A few things:
- ZScript is case sensitive.
- a function looks like this:
Code:
type function-name ( [type param1 [, ...]] ) {
contents of function
//if function requires a return value, then you must use return(...) at some point
}
The first type is the the type that the function returns.
- void is a special type, and can only be used as a return type. It means "I don't return anything"
- NPC->Weapon(18) doesn't work because zscript is looking for a variable called "NPC", and can't find one.
- npc->Weapon(18) doesn't work because you're trying to call a function using a base type. Doesn't work for the same reason "int->Weapon(18)" doesn't work.
- You should create a variable to hold the NPC in, like this:
Code:
npc myenemy;
myenemy = Screen->CreateNPC(NPC_SHOOTROCK)
- But, even if you do that, it still won't have a Weapon() function. You can't really force enemies to do anything in particular.
- Game->PlaySound(51) does work (but the compiler doesn't get that far);
- in std.zh, you'll see a lot of lines that look like this:
Code:
const int SFX_ROCK = 51; // Octorok rock is fired.
const int WPN_REFROCK = 18;
This is a constant. It means that "WPN_REFROCK" means 18, and "SFX_ROCK" means 51.
- You are strongly advised to put this line at the top of every single script file you create:
This will cause the compile to recognize all the aforementioned constants.
So, you know assembly, but not C? Odd.