inventory item problem: every item does anything

Started by Matex, Sun 10/06/2007 10:32:48

Previous topic - Next topic

Matex

this question has probably been asked before, but I'm new ags(and I'm not going through 200 pages to find if someone asked). I have a hotspot which is a key hole in a tree trunk. i have set the interaction, (I havn't learnt to scrip) to use inventory and then :remove an object from the room(key hole), then turn object back on(open door way). The problem is that when i use the key on the it works.when i use the axe on the door it works. When i use the crystal ball on the door it works... every item seems to work on the keyhole and i cant find a feture that makes it a specific item.
I'm probably just overlooking somthing but can somone help me?
or better yet find another way to do it because the problem with a door way beign an object is that i have to interact with it(use hand) to go into it and i can't just walk into it.
I could however make the area near the edge not a walkable area exept for the door way then make it that walking to that edge takes me to another room therefore creating the illusion of walking into a door but that doesnt solve the first problem
i would realy appreciate help

Akatosh

#1
Hi Matex, welcome to the forums :). Here are some answers for you:

To your first question:

You also need to check WHICH item the player used on the tree trunk, e.g.:

EDIT: the 'Conditional - If inventory item was used' Interaction Editor option
To your second question:

Erm... I don't quite understand what you mean. Do you mean you want a doorway that makes the player change the room via just walking onto it?

Matex

thanxs for the first answer and as for the second question...
i want it so that when the key is used on the key hole the keyhole dissapears and the door appears.
to do this i have drawn a picture of a door and imported it then made an object out of it.
my point was that since it was an object i had to grab/interact/use hand to make it take me to the cave beond the door(another room) my idea was that i make the walkable area again so that it doesnt hit the edge then make an iteraction so that when player wlaks of top edge they go to room x(cave).i was going to make a small section of walkable area that hits the edge at the bottom of the doorway(the top edge of room is where grass meets the bottom of trees and the doorway touches the bottom of the trees. With your first answer i could probably do this but i was wondering if there was a way to make it so that if you walked on an object(in this case the doorway)it would take you to another room(the cave)or, is you could make some sort of entrance to another room appear when i use key on keyhole.

Ashen

#3
Akatosh, please don't use JUST screenshots if you can avoid it - it makes it harder for people searching to fnd the answer they want.

Matex, you don't have to search the 200+ Pages by hand - there's the Forum Search to do it for you. And, if you'd read the forum rules, you'd know you're expected to do that before posting. Not being able to find your answer is one thing, "I couldn't be bothered to look" is unacceptable. Also, the forum rules would've told you to try the BFAQ, which also answers your first question.

For the second, use a Region. Have it initially disabled, and enable it when you use the Key. Check the manual for more details. (There's no equivilant Interaction Editor command, so you'll have to script it.) You may need to do something similar with a Walkable area.
I know what you're thinking ... Don't think that.

Matex

could you do it with ints?
if so then why isnt this working?

// room script file


#sectionstart object1_a  // DO NOT EDIT OR REMOVE THIS LINE
function object1_a() {
  // script for Object 1: Use inventory on object
int doorv = 1;
doorv += 1;
}
#sectionend object1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region1_a  // DO NOT EDIT OR REMOVE THIS LINE
function region1_a() {
  // script for Region 1: Player walks onto region
int doorv = 1;
if (doorv == 2) { 
  cEdd.ChangeRoom (5, 100, 195);
}
}
#sectionend region1_a  // DO NOT EDIT OR REMOVE THIS LINE


curently using that will do nothing when i test the game
i think its because in the bit that says player walks onto region
i've put the int roomv = 1 again which reset the int to 1

but if i get rid of that when i go to save the room to play the game i get an error mesage that says

there was an error compiling your script
the problem was:
in: 'room 4 script'

error(line 15): unidentified symbol: doorv

so i changed it to have 'int' before the roomv part on line 15(starts with if...)

then i get the same error mesage but now the error is
error(line15): parse error in expr near int

and i have now clue what that means...

Ashen

#5
You need to declare the int BEFORE the interactions. An int (or other variable like String, bool etc) that's declared in a function. is only valid in that function - that's why you got the original error. Try:

Code: ags

// room script file
int doorv;

#sectionstart object1_a  // DO NOT EDIT OR REMOVE THIS LINE
function object1_a() {
  // script for Object 1: Use inventory on object
doorv = 1;
}
#sectionend object1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region1_a  // DO NOT EDIT OR REMOVE THIS LINE
function region1_a() {
  // script for Region 1: Player walks onto region
if (doorv == 1) { 
  cEdd.ChangeRoom (5, 100, 195);
}
}
#sectionend region1_a  // DO NOT EDIT OR REMOVE THIS LINE


I've replaced the doorv +=1; with just = 1; as it was if you used the Item again (and there doesn't look to be anything to stop you - unless that's done with Interaction Editor commands), doorv would increase again and the condition in 'Player walks onto Region' wouldn't work. (You could also use >= 2, of course).

Quote
error(line15): parse error in expr near int

I'm guessing that line would've been:
Code: ags

if (int doorv == 2) {


Right? Basically, you can't declare an int in a conditional like that. If the int declaration is there, AGS looks for a ';' to end the line, or a single '=' to set an initial value. With the '==' there AGS can't understand what you mean, which is what a 'parse error' is.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk