Thank you for the explanation I think I'm getting a better grasp on it now, or rather I thought I was but now I'm getting an error message in the
openxcom.log.
[24-02-2022_16-26-06] [ERROR] Error in parsing script 'newTurnItem' for 'Global Event Script': invalid variable definition after other operations: 'var int Fuse_State;'
What I've been trying to do is adapt
Greenscarf's "Automatic Priming" script to include a few more options that can be quickly altered in a
.rul file.
For convenience I've attached a small example mod to this post that reproduces the error:
TestGrenadeAutoPrime V0-1.zipThe lines that seems to be tripping the error are:
var int Fuse_State;
item.isFuseEnabled Fuse_State;
Line #1 which I thought should be fine creates a variable for storing an integer is created called Fuse_State.
Line #2 Fuse_State is assigned the value of item.isFuseEnabled.
The end goal for this script is:
. Allow automatic priming of grenades of varying fuse times as defined in .rul file.
. Toggle if the grenade can automatically prime while on the ground or only inside the carrying unit's inventory.
. Toggle if the grenade is only automatically primed on the first turn. (Useful if it can be disarmed.)
Here is the full script I'm working with:
extended:
tags:
RuleItem:
AUTO_PRIMED_ENABLED: int
AUTO_PRIMED_FUSE_TIME: int
AUTO_PRIMED_GROUND_ARM: int
AUTO_PRIMED_FIRST_TURN_ONLY: int
scripts:
newTurnItem:
- offset: 52
code: |
var int Current_Turn;
battle_game.getTurn Current_Turn;
var int Fuse_State;
item.isFuseEnabled Fuse_State;
var ptr RuleInventory Items_Inventory;
var int Inventory_Slot;
item.getSlot Items_Inventory;
Items_Inventory.getType Inventory_Slot;
var int Auto_Prime;
item.getTag Auto_Prime Tag.AUTO_PRIMED_ENABLED;
var int Fuse_Time;
item.getTag Fuse_Time Tag.AUTO_PRIMED_FUSE_TIME;
var int Ground_Arm;
item.getTag Ground_Arm Tag.AUTO_PRIMED_GROUND_ARM;
var int First_Turn_Only;
item.getTag First_Turn_Only Tag.AUTO_PRIMED_FIRST_TURN_ONLY;
# If Grenade is not set for Auto Prime, Return.
if neq Auto_Prime 1;
return;
end;
# If Grenade is already armed, return
if neq Fuse_State 0;
return;
end;
# If Grenade is on ground and cannot be armed on ground, return
if eq Ground_Arm 0;
if eq Inventory_Slot INV_GROUND;
return;
end;
end;
# If Grenade can only be auto armed on first turn and it is after that, return
if eq First_Turn_Only 1;
if neq Current_Turn 1;
return;
end;
end;
# Set Grenade fuse to Fuse_Time
item.setFuseTimer Fuse_Time;
return;
It feels like I'm grasping at smoke, if '
var int Fuse_State;' is incorrect why isn't '
var int Current_Turn;' throwing an error as well?
TIS-100 and Shenzen I/O are nice games to get into the assembler mind set.
Both
Shenzen I/O &
TIS-100 are available for Linux!
I'll have to pick them up later, thank you for the recommendations.