Jump to content

I am honestly confounded by this.


Icendoan

Recommended Posts

No, that makes sense, but I am wondering why it let my other 18 blocks of code that use the same macro and didn't complain.
Because they come after the first block where you'd defined the variable, the lack of which was what it was complaining about. If they come before it, then something seriously wack is going on with your code.
Link to comment
Ah, but I hadn't ever touched that variable
And this is the problem. Although the macro documentation says they are set to zero (or 100 for probability1) by default, this is only true after the first time you run the macro. Therefore, at the beginning of your mod, you should have a "variable initialisation" section where you set every variable you're going to use in the macros to zero (or 100, or null ~~ for SPRINT strings). Null is not a valid value for integer variables, which is what it was complaining about, since it wasn't set, not even to zero (which is of course a valid value).
Link to comment

Maybe you'll need to post your full code then. All I can think of is maybe the first 18 blocks are conditional on something that never triggered, or calling different macros that don't need the same variables, or something.

Link to comment

I shortened it, so it no longer needs all 18, just around 11 now.

 

ACTION_FOR_EACH ~itmfile~ IN ~sper02~ ~sper05~ ~sper06~ ~quiver01~ ~quiver02~ ~quiver03~ ~quiver04~ ~quiver05~ ~quiver06~
~bull02~ ~bull03~ ~bolt02~ ~bolt06~ ~arow02~ ~arow11~ ~ax1h04~ ~ax1h06~ ~dart01~ ~dart02~
~blun05~ ~blun21~ ~hamm02~ ~hamm08~ ~halb02~ ~halb07~ ~dagg02~ ~dagg15~ ~dagg11~ ~dagg05~ ~sw2h02~ ~sw2h11~
~blun07~ ~blun15~ ~blun01~ ~sw1h02~ ~sw1h42~ ~staf02~ ~staf18~ ~blun03~ ~blun13~ ~sw1h08~ ~sw1h09~ ~sw1h05~
~sw1h06~ ~ax1h02~ ~ax1h03~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%itmfile%.itm~ BEGIN
 COPY_EXISTING ~%itmfile%.itm~ ~override/%itmfile%s.itm~
 SET %opcode% = 12
 SET %target% = 2
 SET %Parameter2% = 524288
 SET %dicenumber% = 1
 SET %dicesize% = 3
 SET %timing% = 1
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
 FOR( i = 0 ; i < 4; i = ( i + 1 ) ) BEGIN
  SET %opcode% = 60
  SET %target% = 2
  SET %timing% = 0
  SET %duration% = 10
  SET %probability1% = 10
  SET %parameter2% = "%i%"
  SET %parameter1% = 50
  LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
 END
END
END
ACTION_FOR_EACH ~itmfile~ IN ~sper02~ ~sper05~ ~sper06~ ~quiver01~ ~quiver02~ ~quiver03~ ~quiver04~ ~quiver05~ ~quiver06~
~bull02~ ~bull03~ ~bolt02~ ~bolt06~ ~arow02~ ~arow11~ ~ax1h04~ ~ax1h06~ ~dart01~ ~dart02~
~blun05~ ~blun21~ ~hamm02~ ~hamm08~ ~halb02~ ~halb07~ ~dagg02~ ~dagg15~ ~dagg11~ ~dagg05~ ~sw2h02~ ~sw2h11~
~blun07~ ~blun15~ ~blun01~ ~sw1h02~ ~sw1h42~ ~staf02~ ~staf18~ ~blun03~ ~blun13~ ~sw1h08~ ~sw1h09~ ~sw1h05~ 
~sw1h06~ ~ax1h02~ ~ax1h03~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%itmfile%.itm~ BEGIN
 COPY_EXISTING ~%itmfile%.itm~ ~override/%itmfile%r.itm~
 SET %opcode% = 12
 SET %target% = 2
 SET %Parameter2% = 2097152
 SET %dicenumber% = 1
 SET %dicesize% = 3
 SET %timing% = 1
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
 SET %opcode% = 101 //Protection from Opcode
 SET %target% = 2
 SET %timing% = 0
 SET %duration% = 10
 SET %probability1% = 10
 SET parameter2 = 98
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
END
END
ACTION_FOR_EACH ~itmfile~ IN ~sper02~ ~sper05~ ~sper06~ ~quiver01~ ~quiver02~ ~quiver03~ ~quiver04~ ~quiver05~ ~quiver06~
~bull02~ ~bull03~ ~bolt02~ ~bolt06~ ~arow02~ ~arow11~ ~ax1h04~ ~ax1h06~ ~dart01~ ~dart02~
~blun05~ ~blun21~ ~hamm02~ ~hamm08~ ~halb02~ ~halb07~ ~dagg02~ ~dagg15~ ~dagg11~ ~dagg05~ ~sw2h02~ ~sw2h11~
~blun07~ ~blun15~ ~blun01~ ~sw1h02~ ~sw1h42~ ~staf02~ ~staf18~ ~blun03~ ~blun13~ ~sw1h08~ ~sw1h09~ ~sw1h05~
~sw1h06~ ~ax1h02~ ~ax1h03~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%itmfile%.itm~ BEGIN
 COPY_EXISTING ~%itmfile%.itm~ ~override/%itmfile%r.itm~
 SET %opcode% = 12
 SET %target% = 2
 SET %Parameter2% = 131072
 SET %dicenumber% = 1
 SET %dicesize% = 3
 SET timing = 1
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
 SET %opcode% = 40
 SET %target% = 2
 SET %timing% = 0
 SET %duration% = 10
 SET %probability1% = 10
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
END
END
ACTION_FOR_EACH ~itmfile~ IN ~sper02~ ~sper05~ ~sper06~ ~quiver01~ ~quiver02~ ~quiver03~ ~quiver04~ ~quiver05~ ~quiver06~
~bull02~ ~bull03~ ~bolt02~ ~bolt06~ ~arow02~ ~arow11~ ~ax1h04~ ~ax1h06~ ~dart01~ ~dart02~
~blun05~ ~blun21~ ~hamm02~ ~hamm08~ ~halb02~ ~halb07~ ~dagg02~ ~dagg15~ ~dagg11~ ~dagg05~ ~sw2h02~ ~sw2h11~
~blun07~ ~blun15~ ~blun01~ ~sw1h02~ ~sw1h42~ ~staf02~ ~staf18~ ~blun03~ ~blun13~ ~sw1h08~ ~sw1h09~ ~sw1h05~ 
~sw1h06~ ~ax1h02~ ~ax1h03~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%itmfile%.itm~ BEGIN
 COPY_EXISTING ~%itmfile%.itm~ ~override/%itmfile%n.itm~
 SET %opcode% = 12
 SET %target% = 2
 SET %Parameter2% = 65536
 SET %dicenumber% = 1
 SET %dicesize% = 3
 SET timing = 1
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
 SET %opcode% = 74
 SET %target% = 2
 SET %timing% = 0
 SET %duration% = 10
 SET %probability1% = 10
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
END
END

ACTION_FOR_EACH ~itmfile~ IN ~sper02~ ~sper05~ ~sper06~  ~ax1h04~ ~ax1h06~ ~dart01~ ~dart02~
~blun05~ ~blun21~ ~hamm02~ ~hamm08~ ~halb02~ ~halb07~ ~dagg02~ ~dagg15~ ~sw2h02~ ~sw2h11~
~blun07~ ~blun15~ ~blun01~ ~sw1h02~ ~sw1h42~ ~staf02~ ~staf18~ ~blun03~ ~blun13~ ~sw1h08~ ~sw1h09~ ~sw1h05~ 
~sw1h06~ ~ax1h02~ ~ax1h03~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%itmfile%.itm~ BEGIN
 COPY_EXISTING ~%itmfile%.itm~ ~override/%itmfile%d.itm~
 SET %opcode% = 1
 SET %target% = 1
 SET %Parameter1% = 1
 SET timing = 2
 LAUNCH_PATCH_MACRO ADD_ITEM_EFFECT
END
END

ACTION_FOR_EACH ~file~ IN ~bow02~ ~bow04~ ~bow06~ ~bow16~ ~bow17~ ~bow18~ ~xbow02~ ~xbow05~ ~xbow07~
~xbow09~ ~slng02~ ~slng04~ ~ax1h06~ ~ax1h04~ ~dart02~ ~dart01~ ~dagg05~ ~dagg11~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%file%.itm~ BEGIN
 COPY_EXISTING ~%file%.itm~ ~override/%file%d.itm~
 SET %opcode% = 1
 SET %target% = 1
 SET probability2 = 100
 SET %Parameter1% = 1
 SET timing = 2
 LAUNCH_PATCH_MACRO ADD_ITEM_EQEFFECT
END
END

ACTION_FOR_EACH ~file~ IN ~bow02~ ~bow04~ ~bow06~ ~bow16~ ~bow17~ ~bow18~ ~xbow02~ ~xbow05~ ~xbow07~
~xbow09~ ~slng02~ ~slng04~ ~ax1h04~ ~ax1h06~ ~dart02~ ~dart01~ ~dagg05~ ~dagg11~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%file%.itm~ BEGIN
 COPY_EXISTING ~%file%.itm~ ~override/%file%s.itm~
 SET %opcode% = 89
 SET %target% = 1
 SET %Parameter1% = 5
 SET timing = 2
 SET probability2 = 100
 LAUNCH_PATCH_MACRO ADD_ITEM_EQEFFECT
END
END


ACTION_FOR_EACH ~ring~ IN ~ring06~ ~ring07~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%ring%.itm~ BEGIN
  COPY_EXISTING ~%ring%.itm~ ~override/%ring%a.itm~
  SET opcode = 98
  SET targettype = 1
  SET timing = 2
  SET parameter1 = 8
  SET parameter2 = 3
  LAUNCH_PATCH_MACRO ADD_ITEM_EQEFFECT
 END
END
ACTION_FOR_EACH ~ring~ IN ~ring06~ ~ring07~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%ring%.itm~ BEGIN
  COPY_EXISTING ~%ring%.itm~ ~override/%ring%b.itm~
  SET opcode = 98
  SET targettype = 1
  SET timing = 2
  SET parameter1 = 6
  SET parameter2 = 3
  LAUNCH_PATCH_MACRO ADD_ITEM_EQEFFECT
END
END
ACTION_FOR_EACH ~ring~ IN ~ring06~ ~ring07~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%ring%.itm~ BEGIN
  COPY_EXISTING ~%ring%.itm~ ~override/%ring%c.itm~
  SET opcode = 98
  SET targettype = 1
  SET timing = 2
  SET parameter1 = 2
  SET parameter2 = 3
  LAUNCH_PATCH_MACRO ADD_ITEM_EQEFFECT
END
END

 

It only complained when it got down to the bows, some 6 sections down.

 

Icen

Link to comment

(@codebox: :))

 

All I can think of is that at that point you switched from ADD_ITEM_EFFECT to ADD_ITEM_EQEFFECT and that the latter actually needed that variable pre-defined and the former did not. Someone like Taimon or the bigg would have to confirm that since I don't know exactly how the macros are implemented in Weidu-code.

 

Also, re: SET %Parameter2% = 524288 - try to stay away from syntax like this. Firstly, I'm not sure if it's case-sensitive. Probably isn't, but stay with parameter2 to be safe. Secondly, enclosing the variable name in quotes* has a tendency to evaluate it to what the variable actually represents. So just use "parameter2 = 524288" (the SET is also optional, unless it's an OUTER_SET outside a patch, which it should be at first to "initialise" the variables).

 

*Edit: quotes is a bit misleading - I meant %%s.

Link to comment
as soon as weidu does not have default vaules, I guess a macro to initialize them could be useful, so that one wouldn't have to worry about it. Just copy-paste from the same library they originated from.
Since these are now embedded in WeiDU.exe, in this case you can pretty much just copy and paste from the WeiDU documentation. (Hopefully that will avoid typos, case mismatch and false %% evaluation too :).)
Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...