.lua

Posted by Caeser on Tue 18 Oct 2005 11:24 PM — 9 posts, 36,371 views.

#0
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.
USA #1
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.
#2
thanks a lot, that worked perfectly.
#3
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?
Australia Forum Administrator #4
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.

Australia Forum Administrator #5
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)
#6
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.
Australia Forum Administrator #7
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.
#8
I see. I did it your way and it works fine. Thanks.