Unknown Lua Script Problem

Status
Not open for further replies.

Prisima

Member
My lua script won't work when I add it. You can get a good example of what I'm trying to do here:
Code:
//Made by Prisima the Fox
COM_AddCommand("orderpizza", orderpizza)
local function orderpizza(player)
	if player.playerstate == PST_DEAD
		CONS_Printf(player, "You can't eat pizza while you're 

dead.")
		return
	end
	if playing
		print(player.name+" has ordered a delicious pizza.")
		return
	end
end
When I type 'orderpizza' in the console, it says that it isn't a command, even though it is right here in the script! Any help?
 
Likely you did something wrong with the Lua script itself, since when the game realises it doesn't work it just doesn't run it! So if the Lua script is badly broke in some way, the console command won't exist.

For future reference, test out what happens when you add the Lua script in-game with addfile, and see what errors the console spits out when you do.

If I'm right, it'll be complaining that you defined the function orderpizza AFTER you create a command using the (previously undefined) name, which is simply just an ordering issue. Just move the whole function to before the COM_AddCommand bit, and it'll probably work!

...except though, what is "playing"?
 
I found out that "playing" was some imaginary figament that I thought was equal to "PST_LIVE". Anyways, here's my new code that STILL gives me problems:
Code:
//Made by Prisima the Fox
local function orderpizza(player.mo)
COM_AddCommand("orderpizza", orderpizza, 0)
	if player.playerstate == PST_DEAD
		CONS_Printf(player, "You can't eat pizza while you're dead.")
		return
	end
	if player.playerstate == PST_LIVE
		print(player.name+" has ordered a delicious pizza.")
		return
	end
end
 
Nonono, not like that! More like this:
Code:
//Made by Prisima the Fox
local function orderpizza(player)
	if player.playerstate == PST_DEAD
		CONS_Printf(player, "You can't eat pizza while you're dead.")
		return
	end
	if player.playerstate == PST_LIVE
		print(player.name+" has ordered a delicious pizza.")
		return
	end
end
COM_AddCommand("orderpizza", orderpizza)
 
Status
Not open for further replies.

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

Back
Top