The Dink Network

Reply to Re: Question for implementing new Keys

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
October 16th 2003, 03:58 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Ooh! Ooh! I know of a *perfect* way to do what you're trying to do.

1) Create a global variable called "&current_weapon" in main.c

2) In *every* weapon/item script, add "&current_weapon = &current_script;" in the arm function.

3) In *every* weapon/item script, add a new function called 'alt' or 'altuse' or whatever you want. It is imperative that you create it in *every* weapon/item, even those that don't have alternative modes, otherwise it will cause problems.

4) Then in key123.c or whatever, do this code:

void main(void)
{
run_script_by_number(&current_weapon,"altuse");
kill_this_task();
}

Replacing 'altuse' with whatever function name you chose in step 3.

And that's it. Nice and neat code, no checking to see if which weapon is armed, etc.