Jump to content

Question

Posted (edited)

Hi,

 

im trying to do something in AI and i keep getting erros in the NPC server as soon as AI is loaded, as if the ai.obj gets corrupted, its a huge stack(after compiling it to .obj and adding the compiled code) if i use the s0 variable but if i remove that variable and use hardcoded strings it works, this code is simple i just want to test something where i manage a string every time MENU_SELECTED is invoked.

What i expected this code to do was basically the NPC would say the string "l2Bbuffer002.htm". (no sense i know, but i cut the code to figure what was corrupting it)

The NASC code

class 1 buffer : default_npc
{
parameter:
  string fnHi = "l2Bbuffer001.htm";
  string page = "l2Bbuffer001.htm";
 
handler:

EventHandler TALKED(talker) {
myself::ShowPage(talker,fnHi);
return;
}

 

EventHandler MENU_SELECTED(ask,reply,item,action_id,s0) {
s0 = "l2Bbuffer002.htm";
myself::Say(s0);
return;
}//event
}//class
 

Edited by caganitas

9 answers to this question

Recommended Posts

  • 0
Posted

While i applaud posting of your test - posting without the specific error or info on when in the process shit goes wrong - makes stuff very hard to help with.

  • 0
Posted (edited)

This is the errors i get with that code, as i said its like the AI get corrupted if i use the s0 or any native string variable to do this. if i remove the s0 and use hardcoded strings it works. Im using interlude compiler and replacing the ID's with the GF ID's (im running GF), this is working fine for other variables and functions that didnt change its signature.

 

Untitled2.jpg

 

And if i use a parameter set by me i get these errors, i guess parameters cant change at run time?

 

 

 

Untitled.jpg

Edited by caganitas
  • 0
Posted

The compiled code for that NASC after replacing the ID's is:
 

class 1 buffer : default_npc
parameter_define_begin
    string fnHi "l2Bbuffer001.htm"
    string page "l2Bbuffer001.htm"
parameter_define_end
handler 3 13    //  TALKED
    variable_begin
        "talker"
        "myself"
        "_choiceN"
        "_code"
        "_from_choice"
    variable_end

    push_event    //  myself
    push_const 784
    add
    fetch_i
    push_event    //  talker
    push_const 40
    add
    fetch_i
    push_parameter fnHi
    func_call 235012165    //  func[showPage]
    shift_sp -2
    shift_sp -1
    exit_handler
handler_end

handler 31 19    //  MENU_SELECTED
    variable_begin
        "ask"
        "reply"
        "item"
        "action_id"
        "s0"
        "myself"
        "_choiceN"
        "_code"
        "_from_choice"
    variable_end

    push_event    //  s0
    push_const 576
    add
    push_reg_sp
    fetch_iS881.    "l2Bbuffer002.htm"
    push_string S881
    assign
    shift_sp -1
    push_event    //  myself
    push_const 784
    add
    fetch_i
    push_event    //  s0
    push_const 576
    add
    fetch_i    func_call 234946622    //  func[say]
    shift_sp -1
    shift_sp -1
    exit_handler
handler_end

class_end

 

  • 0
Posted (edited)

So let me get this straight - you not knowing shit about the language use a compiler for something completely different and replace only IDs.

Yet expect it to work like magic?

 

 

The fact that you don't register this as bad - or think "okay can't use c4 compiler" is scary.

 

 

 

Syntax looks correct per NASC - so get a GF compiler and see if the output is different.

(I'm assuming by logic - it will have to be as param syntax matches other uses of s0 in GF).

 

Most probably error is the assigning to s0 - that does not look GF alike natively.

Edited by mcbigmac
  • 0
Posted (edited)

Well it worked for some cases and i read on another forum that the native syntax didnt change from interlude to GF only some function signature and ID's for functions/variables/handlers, and from the cases i tried it was true (which im aware doesnt make it true for every case), so i tried this case and wanted to know from those who actually have knowledge on the subject if it was the process of "converting" to a newer chronicle or just some other wrong code i had, guess i'll have to buy the GF compiler then.

 

Another question, is there any way from the MENU_SELECTED handler to know or go back to the htm page that requested it, like a variable that has that information or a function that redirects? or i just need to send that information from the htm page to the AI?

Edited by caganitas
  • 0
Posted

People look at GF and C4 AI and see no major differences - and there aren't.

But string assigning like that could have changed, find a native example in both and check.

 

 

There's no way to know requesting html by AI - as far as i remember.

Such info is simply not saved in memory in either daemons.

  • 0
Posted

Now that i look at it again - i'm actually confuzzled.

 

That was until i noticed this...

 

fetch_iS881.    "l2Bbuffer002.htm"

 

 

If that's not a copy paste error by you, well there's your error.

  • 0
Posted (edited)

Now that i look at it again - i'm actually confuzzled.

 

That was until i noticed this...

 

fetch_iS881.    "l2Bbuffer002.htm"

 

 

If that's not a copy paste error by you, well there's your error.

yep your right that was it...

 

comparing to a place from compiled GF AI has an assign to s0

 

push_event    //  s0

    push_const 576            //s0

    add

    push_reg_sp

    fetch_i            //expr =

S278.    "String"

    push_string S278

    assign

    shift_sp -1

 

so yeah.... you can close the topic while i go write on a board im a dummy 200 times :D thanks again 

mcbigmac

Edited by caganitas
Guest
This topic is now closed to further replies.


×
×
  • Create New...