[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  .lua
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

.lua

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Caeser   (22 posts)  [Biography] 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.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] 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.
[Go to top] top

Posted by Caeser   (22 posts)  [Biography] bio
Date Reply #2 on Wed 19 Oct 2005 12:47 AM (UTC)
Message
thanks a lot, that worked perfectly.
[Go to top] top

Posted by Caeser   (22 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] 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
[Go to top] top

Posted by Caeser   (22 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] 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
[Go to top] top

Posted by Caeser   (22 posts)  [Biography] 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.
[Go to top] 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.


6,960 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]