eleglas Posted July 17, 2009 Share Posted July 17, 2009 Hi guys, need help with a script I'm writing for a personal water purifier, I have the below script so far, however, I get a Syntax error on line 5 and I cannot understand why, I may have wrote it wrong, but I've wrote loads like this before, or maybe I forgot something. Any help would be great, thanks guys. SCN WaterPurifierX Begin OnActivate If Player.Showinventory WaterUnpurified == 1 Player.Removeitem WaterUnpurified == 1 Player.Additem WaterPurified == 1 Else Endif END Link to comment Share on other sites More sharing options...
cmal Posted July 17, 2009 Share Posted July 17, 2009 Its pretty simple, you messed up the syntax of the RemoveItem and AddItem commands. There shouldn't be the "==" there. And that script probably won't work as intended, since I'm not sure ShowInventory works that way. If you want an activator that just takes all your unpurified water and gives you purified, you may just want a modified version of the Nuka Vending script. Here's what I did. scn aaPurifierScript ;This script takes all dirty water from player and exchanges them for purified water short WaterOnMe begin OnActivate set WaterOnMe to Player.GetItemCount WaterUnpurified Player.RemoveItem WaterUnpurified WaterOnMe Player.AddItem WaterPurified WaterOnMe set WaterOnMe to 0 end Link to comment Share on other sites More sharing options...
Cipscis Posted July 18, 2009 Share Posted July 18, 2009 cmal is correct in that the "==" operator will cause a syntax error when used as you've used it, because those functions have no return value so there is effectively nothing on the left hand side of the comparator. ShowInventory is also a console only function, and can't be used in scripts, which would again cause a syntax error on line 5. As cmal has suggested, you'll want to use GetItemCount to check the number of dirty water in the player's inventory instead, and use RemoveItem and AddItem according to the syntax stated on the wiki. There are two small changes that I would recommend making to cmal's code:ScriptName aaPurifierScript ; This script takes all dirty water from player and exchanges them for purified water int iWaterCount Begin OnActivate player set iWaterCount to player.GetItemCount WaterUnpurified player.RemoveItem WaterUnpurified iWaterCount player.AddItem WaterPurified iWaterCount EndThe changes that I'm referring to are passing "player" as a parameter to OnActivate so the block only runs when the player activates the reference, and removing the line setting the variable to 0, because the variable will be reset before it is used again anyway so there's no need to set it to 0. Never mind the trivial changes like the variable name - that's just because I re-wrote it and that's how I like to name my variables. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts