A few questions about LUA and MAPS

Status
Not open for further replies.

CloudyTheFox

IT'S HIGH NOON
Hello everyone once again!
I made a topic for help yesterday but I have new questions.

One,
As for when I want to press a button on the keyboard, in lua the button would be BT_SOMETHING, that when pressed once you can close a door, press again and you can open it.

Two,
Using the same idea as question one, how can I make a light flicker on and off with BT_SOMETHING in LUA?

Three,
In my last help topic, I asked about controlling camera's with a button.
I want the buttons to use BT_WEAPONMASK, 1 2 3 etc... to change view ports. I also want to see if I can return to normal view without waiting a timer?


I would appreciate the help and thank you.
 
Not exactly that good with LUA, but I'll try to help
One,
As for when I want to press a button on the keyboard, in lua the button would be BT_SOMETHING, that when pressed once you can close a door, press again and you can open it.
You can call actions with LUA, so maybe you could use http://wiki.srb2.org/wiki/A_LinedefExecute? All you'd need is a way to make it open the door, rather than activating the close linedef repeatedly.
Two,
Using the same idea as question one, how can I make a light flicker on and off with BT_SOMETHING in LUA?
See above.
Three,
In my last help topic, I asked about controlling camera's with a button.
I want the buttons to use BT_WEAPONMASK, 1 2 3 etc... to change view ports. I also want to see if I can return to normal view without waiting a timer?
??? You want to activate remote camera objects with the buttons? I don't understand...
 
I recommend in the code you have for opening the door, to check if a variable (that means an open door) is off, as well as if the button is pressed, and at the end of the script, turn that on, which would prevent you from opening a door when it is opened.

Likewise, you could check to see if it is on in a check for the button yet again, in which case it could close the door and change the variable back again.
 
I've tried to LUA until my brain hurt

All I got was...

Code:
local function leftDoor(height, sector)
	sector.FixedCeil = P_Move(height.ceilingheight)/1
end

addHook("LinedefExecute", leftDoor, "LDOOR")

I am really confused...
 
Yeah, you've got a few things completely wrong seemingly. Here's a few questions and things to think about:
  • What is "height"? a mobj? a linedef? a sector? I get the impression you have no idea what it is yourself.
  • What are you expecting P_Move to do? Do you know what it's meant to do? If you don't know the first thing about it, it's usually a good idea to consult the wiki about it: http://wiki.srb2.org/wiki/Lua/Functions#P_Move
    What P_Move DOES do is move an object a set distance at a direction determined by the mobj's movedir attribute. What it DOESN'T do is return a number, it only returns a boolean and a mobj_t as its two return values.
  • The "LinedefExecute" Lua hook function (leftDoor in your case) can have up to 3 arguments: they are of types line_t (a linedef), mobj_t (an object), and sector_t (a sector), in this order. Some or all of these can be omitted, but only if it's not missing out any arguments in-between others - the game will just assume you left out one or so on the end of the argument list instead, and problems will arise. See also http://wiki.srb2.org/wiki/Lua/Hooks#LinedefExecute
  • Since otherwise you don't quite seem to know what exists as variables for sectors, objects etc to use (sector.FixedCeil? really?), you should also consult the wiki on this matter: http://wiki.srb2.org/wiki/Lua/Userdata_structures
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top