Jump to content

GetKey/GetEntityKey


macklebee
 Share

Recommended Posts

Has something changed with the GetKey/GetEntityKey return of a default when a key isn't found when parsing a SBX file? The same code that I was using yesterday to set the sky and water no longer functions correctly now. It always tries to load the water no matter what, even if there isn't a waterplane in the SBX file.

Function ProcessScene(scene:TEntity)
For entity = EachIn scene.kids
	Local skymaterial:String = entity.GetKey("skymaterial", "") 'only the sky will have a skymaterial property
	If skymaterial <> ""
		skymaterial = "abstract::" + skymaterial
		fw.renderer.SetSkybox(LoadMaterial(skymaterial))
		Local camrange:TVec2 = StringToVec2(entity.GetKey("camerarange", "0.1,1000.0"))
		CameraRange(fw.Main.camera, camrange.X, camrange.Y)
		Local fogmode:Int = entity.GetKey("fogmode", "0").ToInt()
		If fogmode = 1
			fw.renderer.SetDistanceFog(fogmode)
			Local fogangle:TVec2 = StringToVec2(entity.GetKey("fogangle", "0.0,15.0"), 1.0)
			fw.renderer.SetDistanceFogAngle(fogangle)
			Local fogcolor:TVec4 = StringToVec4(entity.GetKey("fogcolor", "255,255,255,255"), 1.0 / 255)
			fw.renderer.SetDistanceFogColor(fogcolor)
			Local fogrange:TVec2 = StringToVec2(entity.GetKey("fogrange", "0.0,1000.0"), 1.0)
			fw.renderer.SetDistanceFogRange(fogrange)
		End If
	EndIf

	Local submersioncolor:String = GetEntityKey(entity, "submersioncolor", "")
	If submersioncolor <> ""
		fw.renderer.SetWater(1) 'because if there is a submersioncolor then there is water
		fw.renderer.SetCaustics(1) 'optional, but it looks really nice
		Local watercolor:TVec4 = StringToVec4(entity.getkey("color", "255,255,255,255"), 1.0 / 255)
		fw.renderer.SetWaterColor(watercolor, StringToVec4(submersioncolor, 1.0 / 255))
		Local waterheight:TVec3 = EntityPosition(entity) 'get waterheight from the waterplane.gmf position
		fw.renderer.SetWaterHeight(waterheight.Y)
		Local softness:Float = entity.GetKey("softness", "1.0").ToFloat()
		fw.renderer.SetWaterSoftness(softness)
		Local visibility:TVec2 = StringToVec2(entity.getkey("visibility", "0,20"), 1.0)
		fw.renderer.SetWaterVisibility(visibility)
		Local wavespeed:Float = entity.GetKey("wavespeed", "1.0").ToFloat()
		fw.renderer.SetWaterWaveSpeed(wavespeed)
	End If
Next
End Function

 

This code worked correctly before but now its like something is being returned as the default differently due to the new 2.3 update last night... I have tried it both ways with GetKey and GetEntityKey and it makes no difference.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Why don't you print out the value of submersioncolor, then you see if it's empty or not.

 

i tried that already... I see nothing being returned as I would expect... but its still continuing with the code as if 'submersioncolor <> ""'

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Maybe you have some hidden character between the "" which your BlitzMax IDE doesn't show.

Try to delete the "" from both lines and rewrite it again.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

also just as a test I ran the program with the "old" 2.3 SDK stuff and it works correctly.

 

edit-- ive tried that as well... and even putting characters in the default and checking for the character in the if-statement... its not working... i take the exact same program and use it with the old 2.3 and it works.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Maybe the temporary files in your .bmx folder are corrupted and using code from the old 2.3 SDK. BlitzMax does that quite often.

Then you can just delete the .bmx folder and have clean compile. Disabling the Quick Build mode in BlitzMax should do the same, but I trust more deleting the files myself.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...