Page 1 of 2

help with code

PostPosted: Sat Aug 04, 2007 1:13 pm
by Zehper48
whats wrong with this code? and how do i fix it

Code: Select all
if Icoins.textNumber =<15;
{
Iairrune.textNumber + 1;
Icoins.textNumber - 15;
}

The error message was
Error line 1: expected (
Error line 1: Undefined type for relational operation

thanks

PostPosted: Sat Aug 04, 2007 1:36 pm
by metal_pt
Try ir like this:

Code: Select all
if (Icoins.textNumber <= 15)
{
    Iairrune.textNumber += 1;
    Icoins.textNumber -= 15;
}

PostPosted: Sat Aug 04, 2007 1:48 pm
by Zehper48
thanks it worked!

PostPosted: Sat Aug 04, 2007 5:47 pm
by Zehper48
this is my piece of code i get the error
Error line 1: Incompatible types


Code: Select all
if (Imindrune.textNumber&Iairrune.textNumber >=1)
{
Imindrune.textNumber -=1;

Iairrune.textNumber -=1;

CreateActor("airstrike1", "airstrike", "(none)", "(none)", 0, 0, false);
}



how do i fix it
thanks

PostPosted: Sat Aug 04, 2007 5:55 pm
by d-soldier
if (Imindrune.textNumber >=1 && Iairrune.textNumber >=1)
{
Imindrune.textNumber -=1;

Iairrune.textNumber -=1;

CreateActor("airstrike1", "airstrike", "(none)", "(none)", 0, 0, false);
}

try that.

PostPosted: Sat Aug 04, 2007 6:41 pm
by Zehper48
thanks for all the help

i dont have a code error but my code isnt doing what i want it to do

this is the code for my bullet actor
Code: Select all
if (lastdirection = 1)
{
    y=y-10;
}
if (lastdirection = 2)
{
    x=x+10;
}
if (lastdirection = 3)
{
    y=y+10;
}
if (lastdirection = 4)
{
    x=x-10;
}

this is the code for my guy
Code: Select all
Key down up
lastdirection=1;
Key down right
lastdirection=2;
then same for down and left

btw lastdirection is a variable
when i press space bar actor guy creates the bullet but it stands still and doesnt move
if anybody understands my problem please help me thank you

PostPosted: Sat Aug 04, 2007 6:45 pm
by d-soldier
Zehper, anytime you have a line that says "if" you need to have 2 "=" signs. (with the exception of the <>'s)

PostPosted: Sat Aug 04, 2007 7:08 pm
by Zehper48
alright i did that but now when actor guy creates the bullet it is created 10 units infront of him instead of continuosly moving. how do i make the bullet continuously move? thanks for helping me and having patience

PostPosted: Sat Aug 04, 2007 7:20 pm
by d-soldier
If you put that code in the bullet's create-actor event, then it runs it one time only, moving it 10 increments once. In the create actor you need to use a code like:

for left:

xvelocity = -15;

for up:

yvelocity = -15;

etc.

Your code would only work in the draw-actor event, but would not work given the way you are scripting the direction based on the player's last movement.... so try the codes above (in the create-actor event as discussed).

PostPosted: Sun Aug 05, 2007 10:13 am
by Zehper48
that worked thank you
i have another question lol
what is the code for loading a .ged and loading and saving variables, like if you hit a save button it will save like 10 variables :?:

:) :) :)

PostPosted: Sun Aug 05, 2007 10:36 am
by DilloDude
If you gave the variables in a save group, just use the saveVars function.

PostPosted: Sun Aug 05, 2007 4:38 pm
by Jay S.
Zehper48 wrote:how do you give the variable a save group?

On the "Add new variable" window, you can type in the save group in the "Save group" section.

So say you have a variable called Energy and make its save group called Health. What you'd what to do is:
Code: Select all
saveVars("game.sav", "Health");

What this code does is save the variables stored in Health be saved to an external file name "game.sav." :) Now, to load it back:
Code: Select all
loadVars("game.sav", "Health");

This says to load the Variable values from the file "game.sav" and load the Health group.

To load another file, use:
Code: Select all
LoadGame("game.ged");


Hope this helps. :wink:

PostPosted: Sun Aug 05, 2007 4:42 pm
by Zehper48
i deleted my post above yours to re word it but you gave a perfect answer thank you, but i have another question

what is the code to make actor1 follow actor 2, and what is the code to make actor 1 create a bullet in the direction of actor 2 without folloing it just going in the direction of it?

PostPosted: Sun Aug 05, 2007 6:18 pm
by Troodon
Bullet question:
Make the actor1 do the bullet normally.
Then add in the create actor of bullet the MoveTo code so that it moves towards the actor2. It will not follow it like aiming missile because it's in the create actor code. So it will just move straight in the wanted direction.

1st question:
You can use the MoveTo in this also but some people prefer some very complicated ways to have better AI. However I would start with the MoveTo code but this time in the draw actor so that it always follows.

:)

PostPosted: Sun Aug 05, 2007 7:38 pm
by Zehper48
ok for the bullet i think there is a code to make it move all the way through instead of just stop at the spot the actor was at but i dont remember it, the move to with the draw actor worked thanks tekdino