Anyone know Letoscript?
 ForSerious                
                
                    Member Posts: 521
ForSerious                
                
                    Member Posts: 521                
            
                    I have a script to reward XP for unlocking things, and another for disarming traps. I got sick of doing it one by one and found letoscript and moneo.
After playing around for a bit, I was able to make a script that kind of works. Trying to look up syntax for Letoscript is like trying to find living mammoths. Specifically I need to check if the OnDisarm or OnUnlock already have a script assigned and not override it. Was hoping to check the length of the existing string or something, but who knows if that's even a function, and if it is, what letters to input to call it.
Also, I don't want to award XP if the locked object needs a key to unlock. I had the script working for that, but then it started ignoring that condition randomly.
                After playing around for a bit, I was able to make a script that kind of works. Trying to look up syntax for Letoscript is like trying to find living mammoths. Specifically I need to check if the OnDisarm or OnUnlock already have a script assigned and not override it. Was hoping to check the length of the existing string or something, but who knows if that's even a function, and if it is, what letters to input to call it.
Also, I don't want to award XP if the locked object needs a key to unlock. I had the script working for that, but then it started ignoring that condition randomly.
0        
             
                                
Comments
# Find all placeables with a given script by area %mod = 'c:\NeverwinterNights\nwn\modules\Dark Energy.mod' or die; for (%mod['*.git']) { $area = substr($_, 0, -4); %are = %mod[$area + '.are']; $areaname = /Name; close (%are); for (/{'Placeable List'}) { if (/~/OnHeartbeat ne '') {print $area, ";", $areaname, ";", /~/TemplateResRef, ";", /~/OnHeartbeat,";", "\n";} } }If you post the script that stops working randomly, I'll have a look at it.
%mod = '01_FS_Chapter1TEST.mod'; for (%mod['*.git']) { for (/{'Placeable List'}) { if (/~/Static == 0) { if (/~/TrapFlag == 1) { replace 'OnDisarm', '', 'trap_xp'; } [b]if (/~/Locked == 1 && /~/KeyRequired == 0)[/b] { replace 'OnUnlock', '', 'unlock_xp'; } } } for (/{'Door List'}) { if (/~/Static == 0) { if (/~/TrapFlag == 1) { replace 'OnDisarm', '', 'trap_xp'; } if (/~/Locked == 1 && /~/KeyRequired == 0) { replace 'OnUnlock', '', 'unlock_xp'; } } } for (/{'TriggerList'}) { if (/~/TrapFlag == 1) { replace 'OnDisarm', '', 'trap_xp'; } } } %mod = '>'; close %mod;I'll be doing a few more tests, but KeyRequired == 0 is the part that stopped working in that it gets ignored and assigns the script. I just assume double ampersand is the and condition notation because that's most common. Does that mean if exists? (Like JavaScript ? after a parameter variable)
I've never tried replace - to change the current element only, it's something like
I'm not at my desk to double-check the syntax or field names, so if that doesn't work, refer to the examples that ship with moneo on the Vault.
I included some syntax notes in the moneo package on the Vault.
Changing to eq seems to be what I needed. I had to replace 'replace' and I seem to have it working:
%mod = '01_FS_Chapter1.mod'; $lockCount = 0; $TrapCount = 0; $Traps = 0; $DoorTrap = 0; $DoorLock = 0; for (%mod['*.git']) { for (/{'Placeable List'}) { if (/~/Static == 0) { if (/~/TrapFlag eq '1') { if(/~/OnDisarm eq '') { print /~/Tag, ' Trapped!', "\n"; /~/OnDisarm = "trap_xp"; $TrapCount++; } else { if(/~/OnDisarm ne 'trap_xp') { print /~/Tag, ' OnDisarm: ', /~/OnDisarm, "\n"; } } } if (/~/Locked eq '1' && /~/KeyRequired eq '0') { if(/~/OnUnlock eq '') { print /~/Tag, ' Locked!', "\n"; /~/OnUnlock = "unlock_xp"; $lockCount++; } else { if(/~/OnUnlock ne 'unlock_xp') { print /~/Tag, ' OnUnlock: ', /~/OnUnlock, "\n"; } } } } } for (/{'Door List'}) { if (/~/TrapFlag eq '1') { if(/~/OnDisarm eq '') { print /~/Tag, ' Door Trapped!', "\n"; /~/OnDisarm = "trap_xp"; $DoorTrap++; } else { if(/~/OnDisarm ne 'trap_xp') { print /~/Tag, ' OnDisarm: ', /~/OnDisarm, "\n"; } } } if (/~/Locked eq '1' && /~/KeyRequired eq '0') { if(/~/OnUnlock eq '') { print /~/Tag, ' Door Locked!', "\n"; /~/OnUnlock = "unlock_xp"; $DoorLock++; } else { if(/~/OnUnlock ne 'unlock_xp') { print /~/Tag, ' OnUnlock: ', /~/OnUnlock, "\n"; } } } } for (/{'TriggerList'}) { if (/~/TrapFlag eq '1' && /~/TrapDetectable eq '1' && /~/TrapDisarmable eq '1') { if(/~/OnDisarm eq '') { print /~/Tag, ' Trap Trapped!', "\n"; /~/OnDisarm = "trap_xp"; $Traps++; } else { if(/~/OnDisarm ne 'trap_xp') { print /~/Tag, ' OnDisarm: ', /~/OnDisarm, "\n"; } } } } } print "Placeable Traps: ", $TrapCount, "\n"; print "Placeable Locks: ", $lockCount, "\n"; print "Door Traps: ", $DoorTrap, "\n"; print "Door Locks: ", $DoorLock, "\n"; print "Trap Traps: ", $Traps, "\n"; %mod = '>'; close %mod;