ok ive checked every page to do with this and i cant find the sollution so:
here is what ive done:
EDIT - In a new script: (tried putting it in global .ash .asc ect none work)
import int money;
function dialog_request (int hello){
if (hello==1) {
player.Say("I must have that item!");
cGarry.Say("Okay, it costs 5g.");
if (money>=5) { // 5 is price of thing you are buying
player.AddInventory(iPoster);
money-=5;
cGarry.Say("You bought a realy great item!");
dSelling.SetOptionState(1, eOptionOff);
}
else {
cGarry.Say("You don´t have enough money!");
}
}
}
and then in the global script:
int money = 10; //Will give the player 10 dollars to start with
export money;
however it comes up unresolved import when ive done everything (or so i think) that needs to be done
Try putting the import int money thing into the global script header, rather than the script itself. Usually works for me.
nooo. it didnt work. maybe i put it in the wrong place? i put it after is says //END OF CONTROL PANEL FUNCTIONS
Try changing the name to something like MyMoney and see what happens. I suspect you will still get unresolved import on "money", which would mean the problem lies else where, in another room script or a module perhaps.
Tried that and your right but i dont see how the problem could be in a room script as they arnt really connected in this case.
this is so annoying! and who said using the points for money is easy? Some rocket scientist no doubt.
Siddd please don't cross-post your threads, it's a violation of the forum rules.
Your scripts confuse me. Where have you defined dialog_request if not in the global script? Your script should be something like this:
// GlobalScript.ash - the global script HEADER
import int money;
// GlobalScript.asc - global script (body)
int money = 10;
export money;
function dialog_request (int hello){
if (hello==1) {
player.Say("I must have that item!");
cGarry.Say("Okay, it costs 5g.");
if (money>=5) { // 5 is price of thing you are buying
player.AddInventory(iPoster);
money-=5;
cGarry.Say("You bought a realy great item!");
dSelling.SetOptionState(1, eOptionOff);
}
else {
cGarry.Say("You don´t have enough money!");
}
}
}
If you're still getting the error, it would be most useful if we knew exactly what the error message says (Ctrl+C to copy it when it appears).
i was told to put it into a new script and the error:
---------------------------
Adventure Game Studio
---------------------------
Script link failed: Runtime error: unresolved import 'money'
---------------------------
OK
---------------------------
Quote
Tried that and your right but i dont see how the problem could be in a room script as they arnt really connected in this case.
Well, you've made progress. We now know that you were creating the global variable correctly. The reason AGS is still complaining about "money" is because you have used that reference somewhere else.
I would search all the scripts for any occurrences of the word "money". If you find any comment them out for now. Don't forget to search any module scripts you may have also.
You may not find anything in your scripts. I have gotten this error a couple of times and yes it's a pain to find, but just hang in there.
The next place you are going to have to look is in the other game elements. Are there any objects, inventory, characters, or any other elements that reference "money:?
Well be assured that something is referencing it somewhere in your game. Give it another go and lket us know what else you may find. ;)
i have just checked through everything and found only one other word that was money. at that point i was quite excited and i thought if i changed it then all would work but im afraid it didnt make a difference! ill continue searching through to see if i can find anything else but i dont think ill find anything.
ive even tried changing the name 'money' to something that i would definately not use in this case 'cash' but still its a no-go.
You don't need to do all this complicated export/import stuff, just use the Global Variables editor to create a variable called "money".
Get rid of these lines from your scripts:
import int money;
int money = 10;
export money;
and create the variable in the Global Variables editor instead.
This assumes you're using AGS 3.0.2, by the way.
Quote
i have just checked through everything and found only one other word that was money.
Where was that word at?
Like I said I had one of these errors a while ago and if I remember right I think I had created an event (lightning bolt icon) and then deleted or renamed the corresponding handler function in the room script. Check all your objects, inventory, etc.
Hint: Its always good to use an experimental game in which to do experiments and try out
techniques. In this way you keep your actual project clean an free of any crap that may have been generated in the process of devising tis or that technique or method.
Quote from: Siddd on Thu 23/10/2008 20:06:35
and who said using the points for money is easy?
You're not using the points system for money, you're creating your own integer. They're completely different things.
And if you're using AGS 3.0.2 then I'd go with CJ's advice.
~Trent
In case you really don't want to use the user-friendly global variables section of the AGS engine then just do this:
go to the top of the global script and add your integer. I would provide a complete solution if I actually knew where do you want to use the integer.. only in dialog request or just in every script?
well basically all i want is for "Garry" to sell an item that costs 1 point which is deducted from my score or whatever and if i have not enough money then itl say sorry blah blah. so i suppose just dialog_request.
If you are using game score as money, write it as that:
function dialog_request (int hello){
if (hello==1) {
player.Say("I must have that item!");
cGarry.Say("Okay, it costs 5g.");
if (game.score>=5) { // 5 is price of thing you are buying
player.AddInventory(iPoster);
GiveScore(-5);
cGarry.Say("You bought a realy great item!");
dSelling.SetOptionState(1, eOptionOff);
}
else {
cGarry.Say("You don´t have enough money!");
}
}
}
Whats up with this? From what you've said so far it seems like you did the export/import thing correctly and that you still have some unknown reference to "money". So have you found that reference or not? If you haven't there isn't much sense in trying something else; unless of course you intend to start over.
If you need anymore help just ask.
i just want to thank you all for your help and that im gonna give it a few more tries. ive printed out virtually the whole manuel and made it into a book (Y). haha
and ive tried that before:
if (hello==1) {
player.Say("I must have that item!");
cGarry.Say("Okay, it costs 5g.");
if (game.score>=5) { // 5 is price of thing you are buying
player.AddInventory(iPoster);
GiveScore(-5);
cGarry.Say("You bought a realy great item!");
dSelling.SetOptionState(1, eOptionOff);
}
else {
cGarry.Say("You don´t have enough money!");
}
}
}
but it comes up 'unexpected if' for the first line.
The code you posted is fine.
The 'unexpected if' error has to do with the code that comes before it.
Only reason I can think of is that you didn't put this code inside a function.
It would help if you showed us the code that comes before it.
from what ive been told there is no code before it =S its just that in a new script named 1.asc
Quote from: Siddd on Fri 24/10/2008 21:43:20
from what ive been told
Are you referring to something in this thread?
Well, that's the problem. You'll have to put it inside a function. Without functions, AGS wouldn't know when to execute a piece of code.
You should put it back into the Dialogrequest.
Quote from: Siddd on Fri 24/10/2008 21:43:20
from what ive been told there is no code before it =S its just that in a new script named 1.asc
If you think I´ve told you, I have not. I posted this code because from your post it looked like you are using game score as money, so you just had to replace old code, which was using integrer "Money", with new code, which is using game score.