Aller au contenu

Photo

newbie- how to send a message to pc in which the value of an interger is displayed ig


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
el.sombrero

el.sombrero
  • Members
  • 100 messages
 Hy guys,

 How should be the script line to send a message to pc containing the value of a varible?
 In my game I record the performance of the pc on a ze (how many time he needed to complete the maze) and I would like to create a trigger that displays this result to the pc. 
 This is what I'm using right now:

void main(){object oPC = GetEnteringObject(); //for check triggers
if(!GetIsPC(oPC)) return;SendMessageToPC(GetFirstPC(), IntToString(nMinutesTaken) + " Minutes and " + IntToString(nSecondsTaken) + " seconds were taken to solve the maze");
}

 When I add this line (the one with the message) at the same script were I compute the time taken (final time - initial time) the script works well... but when I try to compile  the script I posted above I get this error:
ERROR: VARIABLE DEFINED WITHOUT A TYPE.

Can anyone help me out? I would like to have and independent script for perfomance retrieval because at some moment I would like to inform the player about his performance at several diferent taks.

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages
Uh, do you define nMinutesTaken and nSecondsTaken anywhere? This script doesn't know what they are. If you store them as local integers somewhere you need to retrieve them first using GetLocalInt(...)

#3
el.sombrero

el.sombrero
  • Members
  • 100 messages
I defined them at other script (by defining I mean atribbuting them a value... is that it?)

Hey, sorry, I'm kind of new to this... How should the "GetLocalInt" sintax go?

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages
One script doesn't know what another script knows unless that value is somehow retrieved.

I recommend you check out Knightmare's Scripting for Noobs tutorial. It has a section specifically on setting and getting local variables.

#5
el.sombrero

el.sombrero
  • Members
  • 100 messages
Thx dude, this is the kind of thing I was looking for :0)

#6
Morbane

Morbane
  • Members
  • 1 883 messages
;SendMessageToPC(GetFirstPC(), IntToString(GetGlobalInt("int_name", nMinutesTaken)) + " Minutes and " + IntToString(GetGlobalInt("int_name", nSecondsTaken)));

If I remember this is something I helped with a while back - so it should look a lot like what I put above

:wizard:

Modifié par Morbane, 13 juillet 2012 - 02:52 .


#7
el.sombrero

el.sombrero
  • Members
  • 100 messages
hey Morbane,

Thx for the help with that last script.
Now I'm trying to create an independent "result log". This script will be independent from the script were the time measures are actually taken. His only purpouse will be to show the results (the value contained at some intergers).
First thing I did was try to create a script containing only "on entering" basics and that final line you provided me for the last script, but the compiler accused at that precise line "ERROR: Variable defined without a type".
I tried to use this suggestion you just gave me, the resulting script is this:
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625 */

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

SendMessageToPC(GetFirstPC(), IntToString(GetGlobalInt("nMinutosTranscorridos", nMinutesTaken)) + " Minutes and " + IntToString(GetGlobalInt("nSegundosTranscorridos", nSecondsTaken)) + "seconds.");
}

What the compiler indicates now is that the definition doesn't match the parameters. What I'm doing wrong?
One difference I noticed is that the intergers here are called "GlobalInt" but at that other script, where they were first named, they weren't named "global"... could this be it?

ps: if anyone reading this is confused or interested at the references for the first timer and retrieval script morbane helped me with, it can be found here http://social.biowar.../index/11959962

#8
el.sombrero

el.sombrero
  • Members
  • 100 messages
Hey, I was reading the doc MasterChanger recomended and I came up with this script, but it still doesn't work ok. The script is the following:

void main()
{
object oPC = GetEnteringObject(); //for check triggers

if(!GetIsPC(oPC)) return;

int nMinutosTranscorridos = GetLocalInt(oPC, "nMinutosTranscorridos")
int nSegundosTranscorridos = GetLocalInt(oPC, "nSegundosTranscorridos");

SendMessageToPC(GetFirstPC(), IntToString(nMinutosTranscorridos) + " Minutos e " + IntToString(nSegundosTranscorridos) + " segundos foram gastos para percorrer o labirinto.");

}


The error I got this time is "ERROR: PARSING VARIABLE LIST" at line 8 ( int nSegundosTranscorridos ...). Think I still didint understand the concept of this process :0P

Modifié par el.sombrero, 17 juillet 2012 - 01:57 .


#9
Morbane

Morbane
  • Members
  • 1 883 messages
you need a semi colon after the: int nMinutosTranscorridos = GetLocalInt(oPC, "nMinutosTranscorridos");

Modifié par Morbane, 17 juillet 2012 - 07:17 .


#10
el.sombrero

el.sombrero
  • Members
  • 100 messages
Hey Morbane,

It isnt the semicolon.. at the compiler that line and the next are only in one line, the semi colon is there, after labirinhto.")
Any other idea?

#11
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Morbane's right, open up your compiler and look at line #7. (the compiler throws an error at line #8 because the int declaration is ungrammatical. The line numbers should be on the left.)

#12
Morbane

Morbane
  • Members
  • 1 883 messages
The lines, commands and declarations should not all be on the same line. They are separate lines of code. Look at your post and you'll see the missing semi colon.

#13
el.sombrero

el.sombrero
  • Members
  • 100 messages
wow... I was totally loking at the wrong line. Let's see....
and Yes, now it's running!
thx guys

#14
Morbane

Morbane
  • Members
  • 1 883 messages
kind of funny actually

syntax errors can be tricky because sometimes the compiler throws the error on the next line - this happens in many compiler environments - its just the way the electric brain thinks.