Any help with Unresolved import

Started by Zipofthe95, Sat 10/04/2021 08:40:28

Previous topic - Next topic

Zipofthe95

I question my sanity at this point.

So. In global script (.asc) I added a function that does a thing. In header (.ash) I've stated import function (it's name)... now after name it says (parameters). After that if I'm reading the manual correctly I call the function in the room by just saying function name (parameter value).

The gist is this. Whenever an object is clicked the function is supposed to fire off. Yet, whatever parameter I add it says "unresolved import" (I say this because (for now at least) parameter doesn't matter (in manual it's animation number, I don't need anything that specific) I just need it to run). What parameter should I use or at least where should I use it (I mean, room or global script(s))?

Thanks ahead.

Crimson Wizard

#1
Please post actual code of function declaration, import declaration, how do you call the function, and also full error message (in Editor you can right click on output panel and choose to copy to clipboard, and also Cltr+C works to copy runtime message boxes to clipboard).
Otherwise it's impossible to diagnose the problem when description is so abstract.

Zipofthe95

#2
Code: ags


function cmbrnd1()
  {
    cMain.LockView(3);  
    cMain.Animate(0, 3, eOnce);
    cMain.UnlockView();
    cMain.Walk(45, 182, eBlock, eAnywhere);
    cMain.LockView(3);  
    cMain.Animate(2, 4, eOnce);
    cMain.UnlockView();
    Dmg1 = (PlAt WpM)- o1D;
    o1H = o1H - Dmg1;
  }  



So this is within global script (.asc) (all in lower two lines are int variables, all defined in .asc)

Code: ags


import function cmbtrnd1();



This is header (.ash)

Code: ags


function oB1_Interact()
{
    cmbtrnd1();
cMain.Walk(82, 182, eBlock, eAnywhere);
cMain.LockView(6); 
cMain.Animate(0, 1, eOnce);
cMain.UnlockView();
}



And this is room code.

Error message (upon starting the game) is: "An internal error has occured. Please note down the following information. If problem persists, post the details on AGS technical forum (ACI version 3.5.0.24)

Error. Unable to create local script: Runtime error: unresolved import 'cmbtrnd1' "

Wherever I added, either named parameter or just declaring int or just number, that's the message I receive (that's why parenthesis are blank, result is the same). What's in brackets (or curly braces?)is irrelevant to me, I just split things like that to see how it works (I'm at the test room, precisely for things like thigs), I can delete it/rewrite it as neccessary, how to call the function is what's problematic.

I'm not exactly programming expert so I hope I provided what you asked (or to be exact, I just copied everything I did in regards to this). I hope it helped!

P.S. So... um... I just noticed. In .asc code, function is called "cmbrnd" and everywhere else is "cmb(t)rnd" ... I've added "t" and that seems to work. Wow. What a moron I am.

But, if I may ask. If just that "t" was fine and that's how functioning works, I think I have an actual question. In the .asc, o1H is health of an object. By that formula it should calculate dmg1 first and then subtract it from o1H, whereupon the subtracted value should be the new o1H, and if the o1H is zero, object should be.Visible = false. However, it doesn't do that. The object just stays. Did I do the formula wrong or should I unblock movement or (I added that object should be invisble a 0 o1H both in room and global script btw)?

Crimson Wizard

#3
Ah, it's just import had different name, yes that happens.

Quote from: Zipofthe95 on Sat 10/04/2021 15:05:43
I think I have an actual question. In the .asc, o1H is health of an object. By that formula it should calculate dmg1 first and then subtract it from o1H, whereupon the subtracted value should be the new o1H, and if the o1H is zero, object should be.Visible = false. However, it doesn't do that. The object just stays. Did I do the formula wrong or should I unblock movement or (I added that object should be invisble a 0 o1H both in room and global script btw)?

Could you tell how do you test the health? For example, if you test exactly (o1H == 0) then this won't work if it gets negative. But that's only one possible reason, there may be others.

It may also help to add the health on a label for instance:
Code: ags

MyLabel.Text= String.Format("%d", o1H);

right after "o1H = o1H - Dmg1;"

Zipofthe95

#4
I'm testing by just changing the code and launching the game to see if it works, but I'll try to deal with that on my own because that's off topic. Thanks very much for helping!

SMF spam blocked by CleanTalk