3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: 1 [2] 3 4 ... 6

Author Topic: Script related questions  (Read 8110 times)

jestermon

« Reply #15 on: November 11, 2011, 09:05:04 PM »
How would I do this in AngelScript?
(C++ snippet)
cout << "Your score is " << playerScore << ". Thanks for playing!";
Is there some easy way to achieve this?

Code: [Select]
void Main()
{
   int PRINT = OBJ_0;
   int COUNTER = OBJ_22;
   int playerScore = 20;

   string S=playerScore; //convert to string so it can be printed

   //Method 1
   iObjectTextSet(PRINT,"Your score is "+S+". Thanks for playing");

   //Method 3
   iPrint("Your score is "+S+". Thanks for playing", -6,3,PRINT);

   //Method 3
   S = IN_22;
   iPrint("Your score is "+S+". Thanks for playing", -6,4,PRINT);

}

See attached project for use. See also default project "iPrint.3dr"

Also refer to Script Reference

iPrint(string,float,float,OBJ_X)
   Print the specified string by using the font and character settings as configured in the specified
   TextPrint object
   string = text (255 characters max). Multi-line text is supported (use '\r' to specify a new line character).
   float,float = screen position. Note that resulting text location depends on source TextPrint object settings.
   OBJ_X = TextPrint object handle.
   NOTE: this function will only print the text once. In order to display a permanet text it must be executed
         at every script loop.

(iPrint coordinates x go from -16 to +16, y go from -12 to +12 {36x24 layout}
You can use decimals eg 1.02 for more precise placement. 0,0 is center of screen.)

iObjectTextSet(OBJ_X,string)
   Set the specified text for the specified object (for example the TextPrint object)
   OBJ_X = object handle.
   string = text



« Last Edit: November 11, 2011, 09:15:47 PM by jestermon »

11Dogs

« Reply #16 on: November 11, 2011, 10:01:20 PM »
Your project works fine... but when I try in my project, the words of the variable quickly disappear. The rest of my text is still on screen.  :-\
Don't see how... but could it be that I changed my variable in an if() statement? There is nothing else that deals with that variable...

EDIT: Yup, that's what it is. When a variable is changed in an if() statement, and the if() statement is no longer true, it must undo the variable? Now my question is, how to fix this?

See attached code to see what I mean:

Code: [Select]
void Main()
{
   int COUNTER = 5;

   string chosenLocation;
   if (COUNTER == 5) { chosenLocation = "puddles and mud"; COUNTER = 2; }

   iPrint("You play in "+chosenLocation+".",-12,0,OBJ_0);

}

If you get rid of the "COUNTER = 2;" part, it works just fine.

I must be off tonight... what in the world is going on??
No... that was right. Forgot to include initial COUNTER value.  :P

I think this is a personal best for most edits without a reply... and arguing with myself. Slash text, unslash text, slash text, unslash text... GOODNIGHT! :D

 :o Why is the above script working now!? Grr...
« Last Edit: November 11, 2011, 10:33:31 PM by 11Dogs »

jestermon

« Reply #17 on: November 12, 2011, 01:44:49 AM »
You missed the part in the reference that said:

this function will only print the text once. In order to display a permanet text it must be executed at every script loop

Make sure you call the iPrint on every loop that you want it displayed. You can use if.. to turn it on and off..  for example

if(I_want_to_print == true)
   iPrint("Hello World", -14,0,OBJ_0);

11Dogs

« Reply #18 on: November 12, 2011, 10:18:15 AM »
Either I'm really missing something, or you don't understand me? In my game, "You play in ." is all it shows. The variable disappears - not the iPrint()'s main text.

jestermon

« Reply #19 on: November 12, 2011, 10:58:03 AM »
Code: [Select]
void Main()
{
   int COUNTER = 5;
   string chosenLocation;
 
   if (COUNTER == 5) {
      chosenLocation = "puddles and mud";
      COUNTER = 2;
   }
   iPrint("You play in "+chosenLocation+".",-12,0,OBJ_0);
}

...Works fine for me in 6.50, 7.03, 7.22
What version are you using?

11Dogs

« Reply #20 on: November 12, 2011, 11:02:50 AM »
Yea, that was working all of a sudden for me last night, but in my actual game... blah, I can't explain it. I decided to go a little different route to avoid this. Thanks anyways.
« Reply #21 on: January 06, 2012, 05:41:26 PM »
Does anyone have a script that will play set1 animation on clicking the left mousebutton

The switch is glitchy and ive tried to get it working

jestermon

« Reply #22 on: January 06, 2012, 06:03:26 PM »
Many logic glitches occur because one conditional check is usually not enough.
In this demo, the mouse button state AND the animationSet is checked, before triggering the change.
If you don't add this 2nd check, then the script is continually resetting the animation to the first frame of the set, causing animation jitters.

Code: [Select]
bool TOGGLE = false;
int animationSet = 0;
int newAnimationSet;

void Main()
{
   if(iMouseButtonDown(0)){
      TOGGLE = true;
   }else{
      TOGGLE = false;
   }

   if(TOGGLE && animationSet == 0){
      animationSet = 1;
      OUT_2 = animationSet;
   }

   if(!TOGGLE && animationSet == 1){
      animationSet = 0;
      OUT_2 = animationSet;
   }
}

Have fun.
« Last Edit: January 06, 2012, 06:15:41 PM by jestermon »
« Reply #23 on: January 07, 2012, 01:41:00 AM »
Once again thanks Jess :D
« Reply #24 on: April 19, 2012, 01:21:38 PM »
hey can you help me i need a script for an animated spoiler i made i need a script that will trigger the spoilers animation that raises the spoiler when the car hit the target speed and the spoiler lowers when the car gets out of the target speed.
do you think you can help me with that please.
I be trippin!
« Reply #25 on: April 20, 2012, 07:58:30 AM »
you can do this yourself dt... you really gotta stop depending on other people to write your projects for you...

also, if you want help, it would help the people helping you if you could be a lil more specific...

you never told anyone exactly how you are raising the spoiler... so i'm gonna assume it's FBF animation...

also, how many frames of animation is it... that's important to know as it'll determine the logic you'll need... therefore i'm gonna use a simple 2 frame animation as a basis for the following help...

1 - in order to know when to raise and lower the spoiler you'll need to know the speed of the vehicle, right... so you've gotta have a variable for that and a line of code in the main loop that always gets this value and stores it in the variable so it can be checked...

2 - the rest is simple... a conditional if(speed > whatever speed you  want the spoiler up) { change the frame to the raised position frame }  else {change the frame to the lowered position frame }

that's it... see how simple it is if you take a few minutes to think the solution out...

now that you have the logic, it should be simple to write the code...  if you do that and still have problems, lemme know and i'll help you figure it out... but if you can't do that, i can't waste any more time here... i'm not gonna do foor you what you can simply do for yourself...

unless you pay me... and my hourly rate is $150 U.S.   ;D

you can do it... good luck...

--Mike

« Reply #26 on: April 20, 2012, 11:19:08 AM »
i used animations in fragmotion to have the spoiler change it orientations uhhh heres the skinmesh i hoe this will help out what im talking about ther is 4 animations in it.for the animations that raise and lower the spoiler there is 16 frames and for the animation that keeps the spoiler lowerd or raised is 1-5 frames
I be trippin!
« Reply #27 on: April 20, 2012, 12:21:05 PM »
so, these are not FBF based animations, but boned based anims...

this is an important piece of the information you've gotta provide when asking questions like this...

if you wanna see the spoiler raise up like in fragmotion, step 2 above now becomes :

2 - the rest is simple... a conditional if(speed > whatever speed you  want the spoiler up) { start the animation and let it run  it until the last sequence }  else {if spoiler is raised reverse anim until at the start of the sequence}


if you just wanna have it pop up and then pop down, use the logic i gave you above...

i don't need the skinmesh... you just have to write out the script to make it happen using the logic i gave you...

or at least try... then i'll help you get it right...

--Mike
« Reply #28 on: April 22, 2012, 07:40:22 PM »
ok thanks for the info ill try
I be trippin!
« Reply #29 on: April 22, 2012, 07:54:59 PM »
ok now im getting confused i tryed this

void Main()
{
float speed;
   if(speed > 2) { OUT_2 = 2 ;
 
}

else (speed > 0 ) ;{OUT_2 = 3;

}
}
but nothing works i tryed other stuff but they just send it to last frame in the animation can you help me please
im trying my hardest to get this right but it's to hard for me right now
I be trippin!
Pages: 1 [2] 3 4 ... 6