Originally Posted by UrbanMonk Oh, whoops. I hate capital sensitive languages. I thought that was just a linux thing. Guess not.
What's the benefits of a capital sensitive language anyways?
most programming languages are case-sensitive, actually
i doubt there's really any benefits to a language being case-sensitive as opposed to not, though on a lower level it's easier to implement them as CS, since you only have one character meaning something instead of two
CS does allow you to have two or more variables with the "same" name, and in cases where those variables are very closely related, it can be convenient for them to share the "same" name as opposed to cluttering them up with underscores or something. for example, in that dialogue script i posted, 'Dialogue' objects use the 'dialogue' table. of course abusing this ability can cause confusion, but then again so can the lexical scoping lua uses:
function doSomething (table)
return table.sort(table)
end
it's very likely you'll get an error when running that, because the 'table' variable in the parameter list overrides the global 'table' when you try accessing it. that's bitten me a couple of times when i haven't paid attention
mmf is semi-case sensitive; you can type something like 'val()' or 'VAL()' or 'vAl()' and it'll take it, but it'll automatically convert it to the "correct" form by the time you view that expression again
Yeah, well on a lower level it would of course make sense, but I still don't see the point in doing it that way.
I don't want people to be confused by it, so I'll most likely make a parse table to convert everything to the correct cases, and for the rest make it lowercase.
I understand that I can get data about mmf objects directly, but I was wondering if mmf can pass information to Xlua from actions. I asked about this already, but I didn't get the answer I was looking for.
So.. Is it possible to create a function that returns data instead of actually carrying out an action. Such as.
GetPlayerName() could return the players name in the form of a string. So
Print(GetPlayerName()) Would print the players name?
Also how do I combine data types in a single input line. OR more specifically how can I include varibles in, say, strings. like:
Print("Hello "+GetPlayerName()+" How do you do?")
But I know that's not how it works, so how would I accomplish this?
if GetPlayerName() is something you'd use in an 'On Function' event, then look under the 'MMF Functions' menu for 'Push String Return'
then you'd do something like this:
On Function "GetPlayerName"
--> XLua - Push String Return: player_name [or whatever GV/AV/array/whatever it's in]
lua does automatic conversions (except in a couple of cases irrelevant here) when possible; right here you don't even have to worry about it, since that function already returns a string. however, lua uses '..' and not '+' to concatenate strings. if you wanted to force a conversion, you could use the tostring() function around whichever function or value you wanted to convert
so as it is, you'd use: Print("Hello " .. GetPlayerName() .. " How do you do?")
Hello, I'm the author of XLua, and I just wanted to throw in that the real reason you should not use the original Lua Object, or the LuaPlus object, is because they are both unstable and crash under larger scripts, and are no longer maintained. That is why XLua came into existence.
XLua is really based on the LuaPlus way of doing things, but you can also do things the old Lua-Object way too. The action "Lua Functions->Inline Parameters->Call With Delimited String" is the same as the Lua-Object "Call Function" action. You can also use DoCall() in your lua scripts to call On Function conditions, like you do in the Lua-Object. Sometimes this is the best way to do things, but it's worth taking the time to learn the other actions because they preserve type information and make some tasks easier.
Originally Posted by Xgoff however, lua uses '..' and not '+' to concatenate strings. if you wanted to force a conversion, you could use the tostring() function around whichever function or value you wanted to convert
so as it is, you'd use: Print("Hello " .. GetPlayerName() .. " How do you do?")
Great! That's the info I was looking for. That's pretty similar to php, I was trying to use "blah " . " Blah" but I see I need two periods now. Nice.
Originally Posted by Retriever2 XLua is really based on the LuaPlus way of doing things, but you can also do things the old Lua-Object way too. The action "Lua Functions->Inline Parameters->Call With Delimited String" is the same as the Lua-Object "Call Function" action. You can also use DoCall() in your lua scripts to call On Function conditions, like you do in the Lua-Object. Sometimes this is the best way to do things, but it's worth taking the time to learn the other actions because they preserve type information and make some tasks easier.
I'm going to take a look at all the new commands too. Some of my functions need to be called from within mmf2 because I want to hide what they are doing. Mostly communicating with the get object to get info from a php script.