(New message)
Subject review (reverse sequence)
Posted by
Tkl1129
Hong Kong (43 posts) bio
Date
Wed 28 Dec 2011 01:57 AM (UTC) [ quote
]
Message
okok, I try to rewrite in table format :D, thanks.
top
Posted by
Nick Gammon
Australia (18,770 posts) bio
Forum Administrator
Date
Wed 28 Dec 2011 01:54 AM (UTC) [ quote
]
Message
I strongly agree with Fiendish here. You are better off making a table and indexing into it. Then you can do this...
skills = skills or {} -- make table if necessary
test = "Big-sword"
skills [test] = 42
Or even:
skills ["Big-sword"] = 42
However if you *must* use global variables <sigh> then you can do this:
However I warn you that it is easy to serialize (save for tomorrow) a normal table, not the _G table.
- Nick Gammon
www.gammon.com.au, www.mushclient.com top
Posted by
Fiendish
USA (848 posts) bio
Global Moderator
Date
Wed 28 Dec 2011 01:35 AM (UTC) [ quote
] Amended on Wed 28 Dec 2011 01:36 AM (UTC) by Fiendish
Message
You're probably going to need to use the dostring function. Again, I think you should reconsider using table members.
http://aardwolfclientpackage.googlecode.com/ top
Posted by
Tkl1129
Hong Kong (43 posts) bio
Date
Wed 28 Dec 2011 01:25 AM (UTC) [ quote
]
Message
Thanks, it's work, but a problem again.
For the skill name
1. Sword
2. Unarmed
3. Axe
This 3 cap in the code below is work,
but for this case won't be work, it occur error base on "=" & "-"
1. Big-sword
2. Big-Axe
I cannot cap in Lua Global Var "lv_Big-Axe"
Error Message:
[String "Trigger: "]:3: '=' expected near '-'
-_-"
top
Posted by
Fiendish
USA (848 posts) bio
Global Moderator
Date
Tue 27 Dec 2011 04:22 PM (UTC) [ quote
] Amended on Tue 27 Dec 2011 04:26 PM (UTC) by Fiendish
Message
%x expansion happens before the script engine is run, so you can just do
But I think you should reconsider the decision to not do it inside a table. A table would guarantee that you can easily keep track of all of your dynamically created variables.
http://aardwolfclientpackage.googlecode.com/ top
Posted by
Tkl1129
Hong Kong (43 posts) bio
Date
Tue 27 Dec 2011 03:13 PM (UTC) [ quote
]
Message
Hi all,
I have a question for this coding method, please kindly advice, thanks.
Case:
Trigger - > Skill: Unarmed - 100 lv
Sword - 120 lv
Pattern %1 = skill name, %2 = lv
local a = tostring("lv_" .. "%1")
local b = "%2"
SetVariables(a , b)
The Variables set in Mushclient was
Name : "lv_Sword"
Value: "120"
however this only use in Mush Global Var, how can I perform the same effect but only save in Lua Global Var?
what I want is
"lv_unarmed" - "100"
"lv_sword" - "120"
"lv_xxxx" - "xxx"
Normal Global var set in lua is
, but this will occur error
tostring("lv_" .. "%1") = "%2"
Do there any method can write in this way? I want to write in seperate var, not in Lua table. 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.
1,074 views.
Reply to this subject
Start a new subject
  Refresh page
Go to topic:
(Choose topic)
Area Editor: Bug reports
Area Editor: General
Area Editor: News and updates
Area Editor: Suggestions
Area Editor: Tips and tricks
Dawn of Time: Administration
Dawn of Time: Configuration
Dawn of Time: Installing/compiling the server
Dawn of Time: New Dawn Muds Announcements
Dawn of Time: Playing
Dawn of Time: What is Dawn of Time (Dawn)?
Electronics: Microprocessors
Electronics: Operational Amplifiers
Forum: About
Forum: Announcements
Forum: Mailing other users
Forum: Problems
Forum: Registering
Forum: Searching
Forum: Subscribing
Forum: Suggestions
Forum: Test
Forum: Time zones / time display
Forum software: Administration
Forum software: Installation
MUDs: Announcements
MUDs: General
MUDs: MUD Design Concepts
MUSHclient: Announcements
MUSHclient: Beta testing
MUSHclient: Bug reports
MUSHclient: Development
MUSHclient: General
MUSHclient: Getting Started
MUSHclient: International
MUSHclient: Jscript
MUSHclient: Lua
MUSHclient: Miniwindows
MUSHclient: MXP and Pueblo
MUSHclient: Perlscript
MUSHclient: Plugins
MUSHclient: Python
MUSHclient: Suggestions
MUSHclient: Tips and tricks
MUSHclient: VBscript
MUSHclient: Wine
PennMUSH: Compiling the server
PennMUSH: Running the server
Programming: General
Programming: STL
Quilting: General
ROM: Compiling the server
ROM: Running the server
SMAUG: Commands
SMAUG: Compiling the server
SMAUG: Lua
SMAUG: Running the server
SMAUG: SMAUG coding
Search the forum
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )