how i do for the "RUN SCRIPT" work?

Status
Not open for further replies.

vinicius

Member
How do I display these letters on the screen when I press a button? I did not find any tutorial on this, and I already saw the srb2 wiki about it, but I could not find where he wrote those letters to appear on the screen.
 
Your best bet is to check out the Lua HUD functions that the game has to offer. If you're unfamiliar with Lua, it'll probably be pretty hard to understand, so make sure you've learnt a little bit at least before attempting anything involving the HUD.

The most primitive HUD function I can think of that falls under your specifications works like this:

Code:
hud.add(function(v, player, camera)
	if (player.cmd.buttons & BT_JUMP)
		v.drawString(16, 160, "JUMPING")
	else
		v.drawString(16, 160, "NOT JUMPING")
	end
end, "game")

Basically, "v" represents the game's "drawer" (what renders the HUD), and "player" represents the player the drawer is currently running for. This code says, if the player is holding down the jump button, have the drawer print "JUMPING", otherwise (i.e. the player is not holding jump), print "NOT JUMPING".
 
...I think he was actually talking about this linedef effect: https://wiki.srb2.org/wiki/Linedef_type_415

In order to make pressing a button run a script using this linedef type, you need to make a "linedef executor". There's a tutorial for making a linedef executor here: https://wiki.srb2.org/wiki/Linedef_executor_tutorial (the example is kind of similar to what you want, except pressing the button opens a door instead of running a script)

Just so you know though, Linedef type 415 only runs text files with a list of console commands, not Lua or SOC. Old level packs that use the "Run Script" linedef, such as Mystic Realm, usually used "cecho" to make text appear in the middle of the screen.
 
Last edited:
Status
Not open for further replies.

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

Back
Top