Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ .lua
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Caeser
(22 posts) Bio
|
Date
| Tue 18 Oct 2005 11:24 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Wed 19 Oct 2005 12:23 AM (UTC) |
Message
| 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. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Caeser
(22 posts) Bio
|
Date
| Reply #2 on Wed 19 Oct 2005 12:47 AM (UTC) |
Message
| thanks a lot, that worked perfectly. | Top |
|
Posted by
| Caeser
(22 posts) Bio
|
Date
| Reply #3 on Wed 19 Oct 2005 10:17 PM (UTC) |
Message
| 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 20 Oct 2005 06:39 AM (UTC) |
Message
| 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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #5 on Thu 20 Oct 2005 06:44 AM (UTC) |
Message
| 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)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Caeser
(22 posts) Bio
|
Date
| Reply #6 on Thu 20 Oct 2005 09:24 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #7 on Thu 20 Oct 2005 09:41 PM (UTC) |
Message
| 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Caeser
(22 posts) Bio
|
Date
| Reply #8 on Mon 24 Oct 2005 01:47 PM (UTC) |
Message
| I see. I did it your way and it works fine. Thanks. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
26,391 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top