Gun

Martin Hello again.

Now my problem is that if ego has taken a gun, and then goes in to another scene, and then goes back, the picture of the gun is there again. I checked the tutorials but I didn
Nychold The easiest way is to make one of your variables a state variable (ie: make variable 112 be isHoldingGun). I forget the AGI syntax since I haven't used it in years. ^^ But then, all you need to do is set that variable when the state changes, and check it when you need to determine the state of the gun. Also, the easiest way of having the ego holding the gun is simply to draw a view with him holding the gun, and switch out the view when necessary. Ego views (I believe) stay with the ego no matter what room it's in, until you change it. Harder ways might exist but...why would you WANT to do it harder? XD
Robin_Gravel The best way is to use obj.in.room("gun",v0) command.

It can be used like

if obj.in.room("gun",v0) then {
draw(gun);
}

Be sure you have set the object's room in object editor or the code will not work.

Use variables for something else.


Robin Gravel
remote No, the easiest way is better coding.

In the object list, be sure to set gun to the current room no. we're dealing with... rather, the same number as the logic you're writing to...

then in the logic:

if(isset(f5)) {
...
load.view(2); //2 or whatever the view number of the gun is
if (obj.in.room(v0,"gun")) {
animate.obj(o1);//use any object you want
set.view(o1,2);
position(o1,x,y);//where x,y are the position on the screen
draw(o1);
}
...
}

then somewhere in the code...

if(said("get","gun")) {
if(obj.in.room(v0,"gun")) {
print("You take the gun.");
get("gun");
erase(o1);
}
else {
print("There's no gun here.");
}
}

That will take of everything. No need to use a variable to see if the gun has been taken or not. If the gun isn't currently in the room (that is if the Ego has it), it won't be drawn there.

I hope that helps.

As for activating the gun...

You need to be something like this in your global code, either Logic 0 or Logic 90, preferably 0 since it handles graphical things better...

if(said("draw","gun")) {
if(has("gun")) {
if(!isset(f50)) {
set(f50);
load.view(5);
set.view(o0,5);
}
else {
print("You've already drawn your gun.");
}
}
else {
print("You don't have a gun.");
}
}
if (said("put away","gun")) {
if(has("gun")) {
if(isset(f50)) {
reset(f50);
load.view(0);
set.view(o0,0);
}
else {
print("It's already put away");
}
}
else {
print("You don't have a gun.");
}
}

I'm making several assumptions here:
That your main Ego view is 0.
That your Ego holding a gun is view 5

Also, notice that I set flag f50. This represents that the gun is drawn. In a sense, I've made it a global flag. You just need to make sure that you don't use f50 anywhere else in the game. When I am coding, I always keep a special list of flags like this that are used throughout the game. You should too.

I hope all this helps. Perhaps later I will write about actually having the gun be able to be fired.
remote Robin's right: obj.in.room("gun",v0) is the right syntax, not obj.in.room(v0,"gun"). You may need to make sure that I wrote all of the code with its proper syntax, and change things here and there, but my coding theory is sound.
MagickPoultry
remote wrote:

As for activating the gun...

You need to be something like this in your global code, either Logic 0 or Logic 90, preferably 0 since it handles graphical things better...



I'm just curious about this part. Why is putting it in Logic 0 better? What problems are there with putting it in Logic 90? I think I've always used 90 for stuff like that.
remote Well, perhaps for simple things like this it doesn't really matter. However, I have had animation manipulations that I needed to be able to enact globally that involved end.of.loop functions, but it also involved moving the character around during specific cels of the loop (if the animation requires the cel to get bigger to the left for just one cel, then the whole animation shifts over on the screen for just that one cel, so I check for the cel and move the whole object over several pixels for that cel and then move it back at the next cel). Anyway, since Logic 90 is a call(90) from Logic 0, it somehow isn't fast enough to execute the graphic manipulations I need. Only having it Logic 0 itself worked for me. Does that make sense?
Martin I have a new problem... it
Martin Oppss, I pasted in the wrong thing... This one is the right: if

(said("look","cuffs")) {
v255 = 2;
if (obj.in.room("handcuffs",v255)) {
print("There are som cuffs there");
}else {
}
}
reset(input_parsed);
// let logic 90 take care of it

}

But it is still the same problem.
MagickPoultry Okay, I think this is how you want it:

if (said("look","cuffs")) {
v255 = 2;
if (obj.in.room("handcuffs",v255)) {
print("There are some cuffs there.");
}
else {
reset(input_parsed);
}
}

First, try fixing that. If that doesn't help it, keep reading.
Is this in the same logic as the gun? If not, make sure you have
#include "defines.txt"
at the top of the logic. That gives a lot of the flags and variables names, i.e. input_parsed.

As for score, the score is contained in v3 (which is named "score" in the defines.txt). So whenever the player does something that increases his score, you just increase v3. For example, you would include a line such as

score = score + 5;

to give the player 5 points. In logic 91, the maximum score is set. There's a line in there

max_score = 0;

You just change the number to whatever you want to be the maximum score. It can't be any higher than 255.

Martin Another problem is that when I write "get gun", it says "ok" and I get the gun, but then it says "You can
MagickPoultry You probably have a "reset(input_parsed);" somewhere by mistake. It needs to be something like:

if (said("get","gun")) {
if (obj.in.room("gun",v255)) {
get("gun");
print("Ok.");
erase(o1);
}
else {
reset(input_parsed);
}
}

It needs to be inside the else block, so that it only gets executed if the gun is not in the room when they try to pick it up. And you have to be mindful of the brackets.