Chalki13 Posted April 10, 2019 Share Posted April 10, 2019 (edited) Hey Guys i have a Problem, iam new to Scripting and i wonder why my script not works. Globals is set = short its a healspell, duration 0, Magnitude 1, manacost 5, always succeds When i go ingame and cast my spell, i dont get my item to the inventory. and how i can script, that i only can have 5 skulls in my inventory. begin 1soulfragmentsummon if ( summonsoulskull == 1 )set timer to ( timer - getsecondspassed ) if ( timer < 0 ) set summonsoulskull to 0 set timer to 0 player->additem "1soulfragment" 1endif if ( summonsoulskull == 0 )if (player->GetSpellEffects callfragament1 == 1 )set summonsoulskull to 1set timer to 1.5MessageBox "test"endifendif end 1soulfragmentsummon Edited April 11, 2019 by Chalki13 Link to comment Share on other sites More sharing options...
cyran0 Posted April 11, 2019 Share Posted April 11, 2019 (edited) You didn't mention it but I expect your message does not display either. You are missing an 'endif' after the line player->additem "1soulfragment" 1. These things are more apparent with properly indented code. This is what the game engine is reading: begin 1soulfragmentsummon if ( summonsoulskull == 1 ) set timer to ( timer - getsecondspassed ) if ( timer < 0 ) set summonsoulskull to 0 set timer to 0 player->additem "1soulfragment" 1 endif if ( summonsoulskull == 0 ) if (player->GetSpellEffects callfragament1 == 1 ) set summonsoulskull to 1 set timer to 1.5 MessageBox "test" endif endif end 1soulfragmentsummon It thinks that the second if-block is nested under the first. Seventeen years ago after Morrowind was first released modders used to nitpick over small irregularities in syntax that they supposed could be responsible for scripts not behaving as intended. I don't know how much of that is true and how much of it was because the real source for an error was never identified, but I tend not to leave such things to chance. Use one 'space' consistently between elements in a line and use parenthesis to liberally so there is no confusion what is being compared. E.g. if ( ( player->GetSpellEffects callfragament1 ) == 1 ). Since seems to run continuously, it would be good to include some 'returns' so it does not burden the system too much. It is not necessary for 'summonsoulskull ' to be a global variable unless another script is referencing it. This is an example of what I am describing with a method to limit the number of skulls to 5: Begin 1soulfragmentsummon short summonsoulskull ;short skullCount float timer if ( menumode == 1 ) return endif ;if ( skullCount >= 5 ) ; this would be nice to have, but I suspect skulls can be removed ; return ;endif if ( summonsoulskull == 1 ) set timer to ( timer - getsecondspassed ) if ( timer > 0 ) return ; prevent further processing of script else set summonsoulskull to 0 set timer to 0 ; if ( skullCount >= 5 ) ; this is more efficient than an inventory count if ( ( player->GetItemCount "1soulFragment" >= 5 ) messagebox "No more skulls can be gathered" else player->additem "1soulfragment" 1 ; set skullCount to ( skullCount + 1 ) ; if ( skullCount >= 5 ) ; StopScript "soulfragmentsummon" ; endif endif return endif endif if ( summonsoulskull == 0 ) if ( ( player->GetSpellEffects callfragament1 ) == 1 ) set summonsoulskull to 1 set timer to 1.5 messagebox "Spell effect detected" endif endif End 1soulfragmentsummon If the duration of the spell causing the effect is greater than 1 second, you might want to change that or have the script remove it. Otherwise, all 5 skulls could be gathered at once. Also, (if appropriate) you can stop this script from running after 5 skulls have been collected with StopScript. Edit: I just now noticed you never declared 'timer' as a variable. Edited April 11, 2019 by cyran0 Link to comment Share on other sites More sharing options...
Recommended Posts