if pentagram == false and dwield == true then
send("carve pentagram")
elseif pentagram == false and dwield == false and dgrasp == true then
send("wield daegger")
omni.doAdd("carve pentagram")
elseif pentagram == false and dwield == false and dgrasp == false then
send("summon daegger")
omni.doAdd("wield daegger")
omni.doAdd("carve pentagram")
elseif pentagram == true then
send("dispel pentagram")
end
It's too long so i put it in function pentagram().
But when I put pentagram() in the scripting box for pentagram alias, it does not work. What can be the problem?
Comments
Did you initialize pentagram to be either false or true?
Making sure your function definition and function call don't have a typo might be a good place to look too.
Also, if the name of your function is "pentagram()" then that is your problem. Change it, and you'll be fine.
Lastly, is this -all- the code in your alias/function?
If none of this works for you, catch me in game in a little while, and we'll go to the debugger.
Also, as a tip, you should change your script to use: if pentagram them, not if pentagram == false then. It's better coding practice, runs faster, and handles undefined (nil) variables automatically (returns false for nil).
I have script for initial stats, @Crixos. Hi.
changing to pentie() made it work.
@Ernam, how will that work? If pentagram then --> does it mean if pentagram variable exists? I do not know how to code using if pentagram and other conditions then.
-- code
end
Will execute the code if pentagram is equal to anything other than false or nil.
The way you wrote it is perfectly fine, but would "crash" out if pentagram is nil.
For a "false only" if statement, you could use:
If pentagram then else --// or if not pentagram then
--code
end
This, however, would execute the code if pentagram is not defined, however, which in your example would be better.
if pentagram then <-- fires if pentagram is not the boolean false or the undefined nil
if not pentagram then <-- fires if it IS the boolean false or the undefined nil
So, for example:
if not pentagram and dwield then
send("carve pentagram")
elseif not pentagram and not dwield and dgrasp then
send("wield daegger")
omni.doAdd("carve pentagram")
elseif not pentagram and not dwield and not dgrasp then
send("summon daegger")
omni.doAdd("wield daegger")
omni.doAdd("carve pentagram")
elseif pentagram then
send("dispel pentagram")
end
Cascades of quicksilver light streak across the firmament as the celestial voice of Ourania intones, "Oh Jarrod..."
So: function pentagam() .... end -- basically saves your function in a variable named "pentagram". However, you were already using that variable, so you were basically overwriting it each time you set pentagram to true or false. (Thus, when you call pentagram(), nothing was happening, as it was a Boolean value, and no longer a function.)
I'd keep your initialize scripts, while it might not be necessary for this script to fire properly (if defaults would be false, for example), it's a good coding habit to prevent things not working for unknown reasons down the line.
Cascades of quicksilver light streak across the firmament as the celestial voice of Ourania intones, "Oh Jarrod..."