help with code

Non-platform specific questions.

help with code

Postby Zehper48 » Sat Aug 04, 2007 1:13 pm

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
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby metal_pt » Sat Aug 04, 2007 1:36 pm

Try ir like this:

Code: Select all
if (Icoins.textNumber <= 15)
{
    Iairrune.textNumber += 1;
    Icoins.textNumber -= 15;
}
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby Zehper48 » Sat Aug 04, 2007 1:48 pm

thanks it worked!
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby Zehper48 » Sat Aug 04, 2007 5:47 pm

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
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby d-soldier » Sat Aug 04, 2007 5:55 pm

if (Imindrune.textNumber >=1 && Iairrune.textNumber >=1)
{
Imindrune.textNumber -=1;

Iairrune.textNumber -=1;

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

try that.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Zehper48 » Sat Aug 04, 2007 6:41 pm

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
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby d-soldier » Sat Aug 04, 2007 6:45 pm

Zehper, anytime you have a line that says "if" you need to have 2 "=" signs. (with the exception of the <>'s)
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Zehper48 » Sat Aug 04, 2007 7:08 pm

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
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby d-soldier » Sat Aug 04, 2007 7:20 pm

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).
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Zehper48 » Sun Aug 05, 2007 10:13 am

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 :?:

:) :) :)
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby DilloDude » Sun Aug 05, 2007 10:36 am

If you gave the variables in a save group, just use the saveVars function.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Jay S. » Sun Aug 05, 2007 4:38 pm

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:
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby Zehper48 » Sun Aug 05, 2007 4:42 pm

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?
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby Troodon » Sun Aug 05, 2007 6:18 pm

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.

:)
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby Zehper48 » Sun Aug 05, 2007 7:38 pm

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
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest