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.