Some MWSE scripting questions

Post » Thu Sep 18, 2014 9:49 am

I wrote the following MWSE script (including comments to myself) as a test. It is supposed to use the MWSE function xMyCellID to return a string showing Ajira's current location and display it on screen. It doesn't work as expected, however, and I don't know if it's due to the script itself or how I test it in the game. atm, I write a test script, compile it in MWEdit and save it to an .esp I'm using for them. I start the game (GOTY edition, MGE XE) and load the test mod and a chargen MOD. When I run the script from the console, it appears as if the command ran - no warning messages appear in the console, but OTOH no message box appears on the game screen.

So, first, is there anything wrong with how I'm testing it. The procedure seems to work, and the scripts are simple - I'm just seeing if I can write a script using one, maybe two MWSE functions and display the string or value in a MessageBox (my way to test if the script works

Second, I'm using Ajira because she is an NPC with a unique ObjectID and I know where she's located and therefore what should be shown. I'm trying to check out two things with this script. One, of course, getting a string and displaying it. The second thing is the concept that MWSE can work with NPCs and creatures to get their location even if the object has not been loaded for the current game session. From what I read in Yacoby's MWSE manual, I should be able to do that. What should be though hasn't worked out in practice yet for me :smile:

Help appreciated. Thanks.

Edit: fix format problem

Spoiler
Begin _JH_WhereIsAjira

;xMyCellID returns the string with the name of the cell where an NPC or unique creature currently is

Long WhereAjira ;long is used for strings, this is a variable


setx WhereAjira to "Ajira"->xMyCellID ;returns string showing where Ajira is

xMessageFix, "Ajira is in %s", WhereAjira ;MWSE function %s formats the variable display in
;the message, WhereAjira is the variable
;a MessageBox MUST follow the xMessageFix line
MessageBox, "abcdefghijklmnopqrstuvqxyz0123456789abcdefghijk" ;dummy placeholder for string value

stopScript, _JH_WhereIsAjira ;needed to stop script from looping


End _JH_WhereIsAjira

User avatar
Monique Cameron
 
Posts: 3430
Joined: Fri Jun 23, 2006 6:30 am

Post » Thu Sep 18, 2014 12:37 am

First of all you should not start any ID with an underscore.

Ajira is an NPC record. Most MWSE functions work with object references.
This script works

Begin JH_WhereIsAjiraLong WhereAjira      Long AjiraRefsetx AjiraRef to xGetRef "Ajira"setx WhereAjira to AjiraRef->xMyCellID xMessageFix "Ajira is in %s" WhereAjira   MessageBox "abcdefghijklmnopqrstuvqxyz0123456789abcdefghijk"  End
User avatar
Steph
 
Posts: 3469
Joined: Sun Nov 19, 2006 7:44 am


Return to III - Morrowind

cron