SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 08-29-2017   #1
Yoshirocks90
Mapping/Scripting Hedgehog
 
Yoshirocks90's Avatar
Default Another Lua Problem

Code:
local PlayerHeight = player.mo.z
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo.skin = "yoshi" & player.powers[pw_super] & PF_JUMPED & (player.cmd.buttons & BT_USE) then
			player.mo.z = PlayerHeight
		else
		end
	end
end)
When I add the script, I get this in the console:

WARNING: Yoshi.wad|LUA_FLOT:6: unexpected symbol near '='

What am I doing wrong?
__________________
I'm accepting mod testers! Test mods before they're released! Submit your own edits! Apply
Yoshirocks90 is offline   Reply With Quote
Old 08-29-2017   #2
Monster Iestyn
Friendly Neighbour-Hood
Moderator
 
Monster Iestyn's Avatar
Default

The problem is with this line:

Quote:
if player.mo.skin = "yoshi" & player.powers[pw_super] & PF_JUMPED & (player.cmd.buttons & BT_USE) then
Here's where you're going wrong:
  • = is for assignment (changing the value of something), not for checking if x is equal to y. "==" is what you want to use instead for that, so to check that player.mo.skin is set to "yoshi", you use "player.mo.skin == "yoshi"" instead.
  • & isn't the symbol for logical and (that is, when you want to say two or more things should be true at the same time), you're meant to use "and" for that. "player.cmd.buttons & BT_USE" using & is fine, since there we're checking that BT_USE flag is set in player.cmd.buttons.
  • "PF_JUMPED" is meaningless on its own there, use "player.pflags & PF_JUMPED" to show you're checking if the flag is set in player.pflags. Just to be safe though, put brackets around that too.

The correct version should be:

Quote:
if player.mo.skin == "yoshi" and player.powers[pw_super] and (player.pflags & PF_JUMPED) and (player.cmd.buttons & BT_USE) then
For your convenience, I bolded all the new and changed parts (it doesn't show for == though for some reason?).
Monster Iestyn is offline   Reply With Quote
Old 08-29-2017   #3
Yoshirocks90
Mapping/Scripting Hedgehog
 
Yoshirocks90's Avatar
Default

Ah, thank you.
__________________
I'm accepting mod testers! Test mods before they're released! Submit your own edits! Apply
Yoshirocks90 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:56 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.