HTOTM: FUSION
Originally Posted by leverdier View Post
You need to use get_player_info(0) and get_player_info(1).
Player number 2 doesn't exist

Also, if player1.injury > player2.injury then player 2 is winning. Injury of player 1 corresponds to the score of player 2.

And you can of course use player1.name or player2.name

Ohhh, I was reading the tutorials wrong.
Thanks! ^^

----

Thanks, I've got it working now.
I just had to do some minor editing!

I understand that you can tell when people do 'commands', so does it say anywhere how to know when someone says a certain word?

I ask for a lot, sorry guys.

How would I go about making a "GUI"?
Last edited by 1WOOF1; Jun 5, 2012 at 11:12 PM.
the command hook works like this:
local function doCommand(cmd)
    --echo the command the user typed
    echo(cmd)
    -- check for "/help"
    if cmd:sub(1, 4) == "help" then
        echo("you typed help")
        return 1 -- recognized command
     end
     -- if not recognized don't return anything
end
add_hook("command", "ex", doCommand)
A full GUI is a difficult toppic. I can give you some help with it but I think it's better to do that via pm.
If you really want to do a big GUI system I'd recommend doing it with OOP (object oriented programming). Since Lua doesn't really support that you have to create your own OOP like systems with so called metatables.
But if you just want to draw some panels and buttons thats rather easy.
It's easier to help if I know what you want to do as I don't want to write a whole tutorial on GUIs in this thread Provide some info and I'll give some advice.
Signature temporarily out of order.
I want to recored in-game using movia.lua it said it would make an mpeg file in the screenshots folder but it didnt.
can u help me
3DS FC :4038-6911-2047
Pokemon Player. LoZ and other Nintendo shit. =]
Is there a list of the internal lua functions of Toribash anywhere? That would be most useful...
Anyway: what I would like to do is to remap some keys, in particular I would like to have 'y' behave like 'z' (for a German keyboard).

To do that, I tried to call the key_down hook with the keycode for 'z', but that didn't help. Is there any way to call the funciton that is called when pressing 'z'?
List of functions:
You can create your own.
local funcs = {}
for k, v in pairs(_G) do
    if type(v) == "function" then
        table.insert(funcs, k)
    end
end
table.sort(funcs)
local file = assert(io.open("functions.txt", "w"))
for i=1, #funcs do
    file:write(funcs[i].."\n")
end
file:flush()
file:close()
It's just the names but it's something.

Then there is the data/scripts/sdk folder. There are some functions explained.


Remapping keys:
There's no way you can change the keycodes that a hooked function gets.
If you want to be able to "switch between English/German layout" you could do something like that:
local yCode, zCode = 121, 122
local function changeLayoutTo(lang)
    if(lang == "German") then
        yCode = 122
        zCode = 121
    end
end
-- ...
add_hook("key_down", "keydown", function(key)
    if key == yCode then
        -- do something
    elseif key == zCode then
        -- do something
    end
end)
Finally you can implement your own keymap but I don't have time to explain that right now Ask againt if you want to know how.
Last edited by psycore; Jun 10, 2012 at 02:38 AM.
Signature temporarily out of order.
hi all ...... please help
hi all

I dont know this is the right place to post my question , but I guess everyone gere are very helpful... please help in the below regard...
I want to write a script in Lua which will be able to merge two or more different xml files and make one single file which is having the info about all.
You need not give me full script but please help me by answering the below steps:
if my files are in some directory structure in my local system, how to open those files?
how to read the files?
how to print the contents of the files?
how to close one and open another?
-----
Last edited by pranavkulkarni; Jul 5, 2012 at 12:58 PM. Reason: <24 hour edit/bump
With Toribash you can only access files in the Toribash folder.
For the rest:
-- you can open many files at the same time:
local input = io.open("path/to/the/file.xml", "r") --read acces
local output = io.open("out.txt", "w") -- write acces

-- multiple ways to read:
-- line for line
for line in input:lines() do
    echo(line) -- print line to screen
end
-- cursor is now at end of file, let's put it back to the beginning
input:seek("set")
-- read whole file:
local text = input:read("*a")

input:seek("set")
-- read line:
local aLine = input:read("*l")
-- five chars:
local fiveChars = input:read(5)

--enough about reading
input:close()

-- now to writing. let's write the text of input to output:
output:write(text)

-- for demonstration let's put "LUA" at the middle of the file:
local fileSize = output:seek("end")
output:seek("set", math.floor(fileSize/2))
-- keep in mind that this overwrites the previous file content!
output:write("LUA")
output:flush
output:close
Signature temporarily out of order.
Originally Posted by psycore View Post
With Toribash you can only access files in the Toribash folder.
For the rest:
-- you can open many files at the same time:
local input = io.open("path/to/the/file.xml", "r") --read acces
local output = io.open("out.txt", "w") -- write acces

-- multiple ways to read:
-- line for line
for line in input:lines() do
    echo(line) -- print line to screen
end
-- cursor is now at end of file, let's put it back to the beginning
input:seek("set")
-- read whole file:
local text = input:read("*a")

input:seek("set")
-- read line:
local aLine = input:read("*l")
-- five chars:
local fiveChars = input:read(5)

--enough about reading
input:close()

-- now to writing. let's write the text of input to output:
output:write(text)

-- for demonstration let's put "LUA" at the middle of the file:
local fileSize = output:seek("end")
output:seek("set", math.floor(fileSize/2))
-- keep in mind that this overwrites the previous file content!
output:write("LUA")
output:flush
output:close

I did these fraction by fraction: I am getting results for most of them....
this was fine
> local output = io.open("out.txt", "w")
> local text = "hi this is the text file!!"

but how to chk the file is created or not?? what is the default location where the file get created?? can we change that??
-----
I tried to do the filesizing operation: it gave me this error:
> local fileSize = output:seek("end")
stdin:1: attempt to index global 'output' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
then I decided to write directly:
> output:write("LUA")
this also gave me the error:
stdin:1: attempt to index global 'output' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?

please help Sir...
-----
I have one doubt, if I open one file in the read and write mode I want to search one word which is there in that file several times... How can I do that... I want to add one more line next to that word.....


Please help, Thanks in advance!!
Last edited by pranavkulkarni; Jul 5, 2012 at 04:49 PM. Reason: <24 hour edit/bump
This looks like you're running Lua in a console and not in Toribash. I am not too familliar with that.
What the error means is that the variable output doesn't exist. One reason could be that out.txt doesn't exist and cannot be created (Lua usually creates files if you try to open non existing files with write access). The other reason could be that local variables don't work in the console. Try doing it without "local" infront of "output".
Signature temporarily out of order.
Is there any function equal to "sleep(time_in_seconds)" in toribash's lua?
multiple texture uploader! updated: multiple texture remover!
updated pretty colorlist!

<BobJoelZ> ok ive just rebooted my pc and ive tried to activate my reflex on yahoo internet explorer :/ no luck

<Aracoon> I do not enjoy having anal sex with multiple men