This question has probably been asked, but I can not seem to find it. I need help changes a text file into a .lua file. I tried saving it as script.lua, but it saved it as script.lua.txt.
If it helps, I am using the MUSH's built-in editer.
Below the file name there is a dropdown box (for file type), change it from text, to all files (*.*), then it should accept whatever extension you give it.
If you have windows set to display extensions, you can simply delete the .txt from the end in exporer.
thanks a lot, that worked perfectly.
I have a different question now: While searching through these forums, I came upon something similar. I want to have (for Achaea) my cure system work off of tables. I found this code:
for _,name in pairs (names) do
if aff[name] then
eat(cures[name])
end
end
Now, I understand this code but was wondering how would I do it if some of the portions of the table don't have a cure that is eaten? Like, I need something call herb balance in order to eat cures. That would be either "on" or "off." I was wondering, if it comes upon these special circumstances (obviously, I want herb balance to be "on"), how would I flag it so that it'll either continue done the table (if "on") or keep checking until it comes upon the desired effect?
This code looks a bit strange anyway. Why do we need a linear scan of a table to find an item? The whole idea of tables is that you can do keyed access.
Here is an example of how you might store all the afflictions in a single table:
afflictions =
{
["blind"] = { ["cure"] = "water", ["balance"] = true },
["sick"] = { ["cure"] = "medicine", ["balance"] = false },
["drunk"] = { ["cure"] = "coffee", ["balance"] = false },
}
tprint (afflictions )
print (string.rep ("-", 50))
print ("cure for blindess = ", afflictions.blind.cure)
Output from above example
sick:
cure=medicine
balance=false
drunk:
cure=coffee
balance=false
blind:
cure=water
balance=true
--------------------------------------------------
cure for blindess = water
Thus you simply key into the table to look up a particular affliction, and whether a balance flag is set.
More simply, the code for the table can be written without all the quotes and square brackets:
afflictions =
{
blind = { cure = "water", balance = true },
sick = { cure = "medicine", balance = false },
drunk = { cure = "coffee", balance = false },
}
tprint (afflictions )
print (string.rep ("-", 50))
print ("cure for blindess = ", afflictions.blind.cure)
Ah, I thought I said I wanted it to automatically do whatever is needed to cure the affliction. It needs to automatically cure when it has the right balances.
The code I wrote wasn't directly answering that question. Organising your data is the first step. You would make a trigger that recognised the affliction and do a table lookup to find the correct cure.
I see. I did it your way and it works fine. Thanks.