deratiseur Posted October 3 Posted October 3 (edited) I'm trying to create a spell that removes summoning spells from a kit. I'm using this code to find out if we're on IWDEE or if IWDEE spells are installed. But it writes" SPELL_RE" as the resource to delete. What's wrong? OUTER_SET spell_num = IDS_OF_SYMBOL (~spell~ ~CLERIC_GIANT_INSECT~) ACTION_IF (spell_num >= 0) THEN BEGIN LAF RES_NAME_OF_SPELL_NUM INT_VAR spell_num RET spell_res END ACTION_IF FILE_EXISTS_IN_GAME "%spell_res%.spl" BEGIN COPY_EXISTING ~pxdelm0.spl~ ~override~ LPF ADD_SPELL_CFEFFECT INT_VAR opcode = 172 target = 1 STR_VAR resource = %spell_res% END END END Edited October 3 by deratiseur Quote
jmerry Posted October 3 Posted October 3 The truncation is, of course, because resource names are capped at eight characters. But what's really going on here is that you have a "failed to evaluate variable" error. And looking at the WeiDU documentation ... %% are mentioned as a valid string delimiter in the section on the .D format. I suspect that's also true in the broader language. So when you say "STR_VAR resource = %spell_res%" and the parser sees %spell_res% where it expects a string, the %% are interpreted as string delimiters and the literal string "spell_res" is passed to the function. To fix it, add string delimiters around that %spell_res": "STR_VAR resource = ~%spell_res%~" should work. Quote
argent77 Posted October 3 Posted October 3 55 minutes ago, jmerry said: To fix it, add string delimiters around that %spell_res": "STR_VAR resource = ~%spell_res%~" should work. You'll also have to add the EVAL keyword (unless the mod uses the AUTO_EVAL_STRINGS directive.) OUTER_SET spell_num = IDS_OF_SYMBOL (~spell~ ~CLERIC_GIANT_INSECT~) ACTION_IF (spell_num >= 0) THEN BEGIN LAF RES_NAME_OF_SPELL_NUM INT_VAR spell_num RET spell_res END ACTION_IF FILE_EXISTS_IN_GAME "%spell_res%.spl" BEGIN COPY_EXISTING ~pxdelm0.spl~ ~override~ LPF ADD_SPELL_CFEFFECT INT_VAR opcode = 172 target = 1 STR_VAR resource = EVAL "%spell_res%" END END END Quote
deratiseur Posted October 3 Author Posted October 3 ok, thanks, it works with the combination of your 2 solutions, EVAL and ~~. Quote
jmerry Posted October 4 Posted October 4 Yeah. AUTO_EVAL_STRINGS is something I pretty much always use, to the point it "goes without saying" ... but it shouldn't. It, or the EVAL, needs to be said. Quote
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.