antopicio Posted June 9, 2016 Author Share Posted June 9, 2016 about your problem ...that's probably because zero dividein math we all know that 0 (zero) is baddiesomething like ' 0 / 3 ' or ' 5 / 0 ' will produce not desirable result (if you using MS excel it will say NA = Not Available)so .... for this fix, notice that in my script I wrote it like this Let curUses := curCharge / (enchCost + 0.001) see that ' 0.001 ' ? that trick will make the system avoid zero divide errorOR you can do something like this Let curUses := eval(curCharge / enchCost)i see your point i'll put it for security but i don't think it is a problem cause enchcost can never be 0 if there is an enchantment active, in a weapon it will always cost something, unless forced i think Link to comment Share on other sites More sharing options...
lubronbrons Posted June 9, 2016 Share Posted June 9, 2016 I tried to recheck the codes, it will gonna be a bad loop it seems scn FlamingSwordChargedScript ... ElseIf switchtime != 2 if (enchh / chargeCost) <= 1 ;this gonna be trouble let switchTime := 1 endif ... scn FlamingSwordDischargedScript ... if (charge / chargeCost) >= 1 ;this gonna be trouble let switchtime := 1 endif ... so you should use the conditional like this.by change both of ' >= 1 ' & ' <=1 ' . they both can be true right? at value 1??this is the revision scn FlamingSwordChargedScript ... ElseIf switchtime != 2 if eval(enchh / chargeCost) < 1 ;added eval for safe code, fix the comparation let switchTime := 1 endif ... scn FlamingSwordDischargedScript ... if eval(charge / chargeCost) > 0 ;added eval for safe code, fix the comparation let switchtime := 1 endif ... Link to comment Share on other sites More sharing options...
antopicio Posted June 9, 2016 Author Share Posted June 9, 2016 aaaah you're rigth i'm stupid, i had also thinked about it, then forgotted thank you a lot, it's is difficult for it to be 1 so it kinda work but i'll change it thanks.just to understand (i have no knowledge of java programming, just some c) is the eval necessary? wuold not be enough to erase un = in the <. and my english sucks sorry Link to comment Share on other sites More sharing options...
lubronbrons Posted June 9, 2016 Share Posted June 9, 2016 (edited) don't mind, me too speak & write funny English (coz I'm not native) I believe put eval there is no harm, so you will not get error compile or something like thatI've had experience on this too... in my case : while trying detect valued item, sometimes can return 0 that makes my script breakbetter safe than sorry, but don't know for sure. My teacher should have better opinion on this after look it more and more you use this line incorrectly ' if (charge / chargeCost) >= 1 'that var charge is only assigned at first !? that's why forli use ' GetCurrentCharge ', stick with it :smile:I revised it once more, this should be good to goFlaming one (have Uses > 1) scn FlamingSwordChargedScript ;the flaming one ref owner ref ench float chargeCost short switchWeapon Begin OnEquip Let ench := GetEnchantment Let chargeCost := GetEnchantmentCost ench Let owner := GetContainer End Begin GameMode If IsEquipped == 0 Return ElseIf owner.IsRidingHorse Return ElseIf switchWeapon Let switchWeapon := 0 RemoveMe ElseIf eval(GetCurrentCharge / chargeCost) < 1 ;if 0 USES, Switch to non-flame owner.AddItemNS provanofiamma 1 owner.EquipItem2 provanofiamma Let switchWeapon := 1 EndIf End Non-Flaming (zero enchant uses) scn FlamingSwordDischargedScript ;non-flame sword ref owner ref ench float chargeCost short switchWeapon Begin OnEquip Let ench := GetEnchantment Let chargeCost := GetEnchantmentCost ench Let owner := GetContainer End Begin GameMode If IsEquipped == 0 Return ElseIf owner.IsRidingHorse Return ElseIf switchWeapon Let switchWeapon := 0 RemoveMe ElseIf eval(GetCurrentCharge / chargeCost) > 0 ;USES available! Flaming on! owner.AddItemNS provafiammakatana1 1 owner.EquipItem2 provafiammakatana1 Let switchWeapon := 1 EndIf End btwthis is no java, this is no cthis is OBSE scripting buddy :smile:and the programming logic is 'Universal' applied to all of them java, c, OBSE, etcwhich is Master Forli is very excel at that, he can make many very streamlined code in one go Edited June 9, 2016 by lubronbrons Link to comment Share on other sites More sharing options...
antopicio Posted June 9, 2016 Author Share Posted June 9, 2016 yeah i know but for what i know eval is a java function, and i had to search it cause i had no idea of what it did.i changed the getcurrentcharge cause it made my game freezed , i would left it cause it's a better solution than mine, more elegant.and sorry i'm a stupid man in a new world what did i do wrong whit the charge var??anyway it seems to work for now (probably random fortune) Link to comment Share on other sites More sharing options...
antopicio Posted June 9, 2016 Author Share Posted June 9, 2016 (edited) it's not working with eval and getcurrentcharge, i think my game is having problem with the getcurrentcharge, as he said error failed to evaluete to a valid result, boh i don't understandthank you for your time Edited June 9, 2016 by antopicio Link to comment Share on other sites More sharing options...
lubronbrons Posted June 9, 2016 Share Posted June 9, 2016 (edited) hey anto :smile: please don't discourage & insult yourself like that eval is good for many OBSE script, not only in handling integer float or prevent zero divide. it is usually used in OBSE array function see here I wonder if the code working fine so I tried running simulation in my head and I think there will still be a problem, if that newly created non-flaming sword have enchant ? it will be problem right? >>> Make sure that non-flaming have charge some too like you flaming one so here's the code for Flaming version ONLY, you'll notice the how's the different in adding item there. The newly created non-flaming sword is forced to have 0 charge in creation scn FlamingSwordChargedScript ;the flaming one ref owner ref ench float chargeCost short switchWeapon ref temp Begin OnEquip Let ench := GetEnchantment Let chargeCost := GetEnchantmentCost ench Let owner := GetContainer End Begin GameMode If IsEquipped == 0 Return ElseIf owner.IsRidingHorse Return ElseIf switchWeapon Let switchWeapon := 0 RemoveMe ElseIf eval(GetCurrentCharge / chargeCost) < 1 ;if 0 USES, Switch to non-flame ;generate non-flame sword that HAVE 0 USES. exactly 0 uses Let temp := CreateTempRef provanofiamma temp.SetRefCount 1 SetEnchantmentCharge 0 temp ;make this newly created non-flame sword have 0 uses temp.CopyIR owner ; add to current host owner.EquipItem2 provanofiamma Let switchWeapon := 1 EndIf End Edited June 9, 2016 by lubronbrons Link to comment Share on other sites More sharing options...
antopicio Posted June 9, 2016 Author Share Posted June 9, 2016 yeah i did that, if you see my code, i also made in the way that when recharged of a certain amount the flaming weapon is charged of the same amount Link to comment Share on other sites More sharing options...
lubronbrons Posted June 9, 2016 Share Posted June 9, 2016 a little information anyway, aside from the code this script may be in trouble. or ... at least we will not see the non-flaming one if you use this mod >>> Enchantment Restore Over Time :) Link to comment Share on other sites More sharing options...
antopicio Posted June 9, 2016 Author Share Posted June 9, 2016 yaeh but with that mod it lose its utility i mean it will be always (or almost) be enchanted why should it turn off the flames? =) Link to comment Share on other sites More sharing options...
Recommended Posts