lua_run weird problem,..

hi all!

maybe this thread needs to go to the lua section, but i think its a hammer problem, so. …

i ve got a weird little problem with the lua_run entity,…
half a year ago i made a test map where it worked perfectly fine, but now with this setting ( but same usage of the lua_run entity ) it doesnt work anymore.

so, i ve got several rooms spreaded through the whole available grid of the hammer editor,… in all of those rooms there s a trigger_once that triggers a lua_run entity.

lua_run entity runs a method serverside (of course) called setroom(room) (e.g. setroom(room06) ) …



room01coords = { x = 14804 , y = 15044 , z = 15449 , dividefacx = 1 , dividefacy = 1 }
room02coords = { x = -14336 , y = -14336 , z = -15552 , dividefacx = 1 , dividefacy = 1 }
room03coords = { x = -10240 , y = -14336 , z = -15552 , dividefacx = 1 , dividefacy = 1 }
room04coords = { x = -526 , y = -432 , z = -32 , dividefacx = 1 , dividefacy = 1 }
room05coords = { x = -526 , y = -432 , z = -1804 , dividefacx = 2 , dividefacy = 2 }
room06coords = { x = 2048 , y = 0 , z = -2048 , dividefacx = 0.25 , dividefacy = 1 }
room07coords = { x = 3072 , y = 0 , z = -2048 , dividefacx = 2 , dividefacy = 0.25 }
room08coords = { x = -14336 , y = -13312 , z = 14336 , dividefacx = 1 , dividefacy = 1 }
room09coords = { x = -14336 , y = -13312  , z = 13744 , dividefacx = 1 , dividefacy = 1 }


function setroom(room)
	if room == room02 then
		fromroomx = room01coords.x
		fromroomy = room01coords.y
		fromroomz = room01coords.z
		
		toroomx = room02coords.x
		toroomy = room02coords.y
		toroomz = room02coords.z
	
		
		dividefacx = room01coords.dividefacx
		dividefacy = room01coords.dividefacy
		
		print("room 02 got in")
		
		setFacsv("room02facs")
	elseif room == room03 then
		fromroomx = room02coords.x
		fromroomy = room02coords.y
		fromroomz = room02coords.z
		
		toroomx = room03coords.x
		toroomy = room03coords.y
		toroomz = room03coords.z
		
		dividefacx = room02coords.dividefacx
		dividefacy = room02coords.dividefacy
		
		print("room 03 got in")
		
		setFacsv("room03facs")
	elseif room == room04 then	
		fromroomx = room03coords.x
		fromroomy = room03coords.y
		fromroomz = room03coords.z
		
		toroomx = room04coords.x
		toroomy = room04coords.y
		toroomz = room04coords.z
		
		dividefacx = room03coords.dividefacx
		dividefacy = room03coords.dividefacy
		
		print("room 04 got in")
		
		setFacsv("room04facs")
	elseif room == room06 then		
		fromroomx = room05coords.x
		fromroomy = room05coords.y
		fromroomz = room05coords.z
		
		toroomx = room06coords.x
		toroomy = room06coords.y
		toroomz = room06coords.z
		
		dividefacx = room05coords.dividefacx
		dividefacy = room05coords.dividefacy
		
		print("room 06 got in")
		
		setFacsv("room06facs")
	elseif room == room07 then	
		fromroomx = room06coords.x
		fromroomy = room06coords.y
		fromroomz = room06coords.z
		
		toroomx = room07coords.x
		toroomy = room07coords.y
		toroomz = room07coords.z
		
		dividefacx = room06coords.dividefacx
		dividefacy = room06coords.dividefacy
		
		print("room 07 got in")
		
		setFacsv("room07facs")
	elseif room == room08 then
		fromroomx = room07coords.x
		fromroomy = room07coords.y
		fromroomz = room07coords.z
		
		toroomx = room08coords.x
		toroomy = room08coords.y
		toroomz = room08coords.z
		
		dividefacx = room07coords.dividefacx
		dividefacy = room07coords.dividefacy
		
		print("room 08 got in")
		
		setFacsv("room08facs")
	end
	moveToRoom(fromroomx, fromroomy, fromroomz, toroomx, toroomy, toroomz, dividefacx, dividefacy )
	return true
end

function moveToRoom(fromroomx, fromroomy, fromroomz, toroomx, toroomy, toroomz, dividefacx, dividefacy  )
	local ply = player.GetByID(1)
	
	local ply_pos = ply:GetPos()
	
	local portx = (ply_pos.x - fromroomx) / dividefacx + toroomx
	local porty = (ply_pos.y - fromroomy) / dividefacy + toroomy
	local portz = (ply_pos.z - fromroomz) + toroomz
	
	trigger_to = Vector(portx, porty, portz)
	
	ply:SetPos(trigger_to)
	return 
end


to jump from the first room to the second works (always), but when im in the second room, somehow the method is called in a wrong way,…
it always runs the code as if the method was setroom(room02) …
even if i start, lets say in room05 it would still call the code of room02, with the prints and everything,…

so is hammer messing something up there? because the code should work fine…

thanks
numu

Looks more like an Lua code error to me. Should you not return end after each room check? I’m not that experienced in Luna, but from a quick glance that’s my suggestion.

thanks for the reply, i think murphys law stroke again!

just talked to a friend,… he told me to try it with a string so … setroom(“room08”)
and now it works…

but its so weird, because it worked this way before…

so sorry for bothering you and thanks for the help!

[SOLVED]