Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → messed up cog.
messed up cog.
2002-04-06, 4:58 AM #1
#Money cog for MP
#Made by LHarm
#Special credit to GBK and Zagibu for thier help
#------------------------------------
Symbols
Message Startup
Int NYcity
Thing Player
End
Code

Startup:
Player = GetLocalPlayerThing();
Setthinguserdata(Player,50);
NYcity = GetThingUserData();

Sleep(2);
PrintInt(NYcity);
Return;
End
#-------------------------------------
Heres my money test cog whats wrong with it
Ive moved over to JK2
2002-04-06, 5:07 AM #2
And also I have not found out how to make a FOR stament in cog.
Ive moved over to JK2
2002-04-06, 5:55 AM #3
a for statement works like this:
Code:
for(i=0;i<10;i=i+1)
{
 PrintInt(i);
}


------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-04-06, 5:58 AM #4
and the problem with your cog might be the startup message. As far as I know, you can't do all operations in it. Try this:
Code:
startup:
 SetTimer(10);
 Return;

timer:
 //do your stuff here
 Return;



------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-04-06, 6:31 AM #5
You can do anything in startup, just not emmiedetly. Add a 'Sleep(0.5)' after the message.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-04-06, 9:04 AM #6
how is making a timer have to do with a money test cog.

and be a little more descriptive on the for statment.
Ive moved over to JK2
2002-04-06, 11:22 PM #7
You left the varible out of your nycity line ...

Like this...

NYcity = GetThingUserData(player);
2002-04-07, 12:03 AM #8
more descriptive? Do you just don't know how it works in cog, or don't you understand it?
Well, anyway, I think it's well explained in the Datamaster, but I can give it a try, too:
when the program enters the for loop, it uses the first statement in the parentheses, in my example above i=0. Then it checks if the second statement is true, if not, the whole for thing won't be processed. If it is, it enters the body and does everything you have there (only a Print in my example). When done, it performs the last statement you had put into the parentheses, so in my example, it will increase i by 1. Then it reenters the whole thing and does everything anew, except that it will neglect the first statement in the parentheses, so that i will be 1 this time...
what it will exactly do in my example, is printing "0" "1" ... "9". Did you understand this? I know, my english sucks, but give the Datamster a try instead...

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-04-07, 5:07 AM #9
how do you set a integer.

[This message has been edited by LHarm (edited April 07, 2002).]
Ive moved over to JK2
2002-04-07, 10:49 AM #10
hmmm...what do you mean? Assigning values to them? Declaring them? BTW: Don't mind the i variable in my example...it does not have to be declared...just use it like that. And this IS an integer, btw. Int = Integer = 0, 1, 2...-1, -10 etc.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides cherokee)

[This message has been edited by zagibu (edited April 07, 2002).]
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-04-07, 11:09 AM #11
Like add one to it.
Ive moved over to JK2
2002-04-07, 12:25 PM #12
Code:
#Money cog for MP
#Made by LHarm
#Special credit to GBK and Zagibu for thier help
#------------------------------------
Symbols
Message Startup
Message Activate
Int    NYcity    local
Thing  Player    local
thing Itemmachine Linkid=89
thing GHoSt
Template Railguner
surface switch0 linkid=1
surface switch1 linkid=1
surface switch2 linkid=1
surface switch3 linkid=1
surface switch4 linkid=1
End
Code

Startup:
 Player = GetLocalPlayerThing();
 Setthinguserdata(Player,50);
return;

Activate:
 If(GetSenderID() = 1){
Print("You have");
sleep(0.5);
NYcity = getthinguserdata(Player);
PrintInt(NYcity);
sleep(0.5);
print("credits");
}
return;
If(Getsenderref()= Itemmachine){
If(Getthinguserdata(Player)>=50){
Print("You bought a ST Rifle");
Setthinguserdata(Player,Getthinguserdata(player)-50);
CreateThing(Railguner,GHoSt);
}
}
return;


Return;
End

Now whats wrong.
Ive moved over to JK2
2002-04-07, 4:28 PM #13
You have too many returns. Remove the excess.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-04-08, 1:39 AM #14
the first return in activate has either to be inside of the first if statement (if you want the activate message to do no further processing after that case) or to be deleted. Same with the second last (It won't be useful to have it inside at the moment, but I guess you wan't to add further if statements later, right). And AFAIK, Integers can't be increased using i++ or i+=1...you have to use i=i+1 (i being the integer variable).

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)

↑ Up to the top!