Page 1 of 1
					
				Problem using aimAt command
				Posted: Sat Jan 30, 2016 10:51 am
				by noobbotter
				Need some help here. I'm using a .lua script similar in fashion to the creatpaths script and in it, I'm attempting to make the bot's camera point toward a specific coordinates. In the script where I run the command player:aimAt({v.x, v.z, player.Y-3}), I get the error: 
"2016-01-30 10:43:43 - ...am Files (x86)/micromacro/scripts/rom/classes/player.lua:3919: attempt to index global 'camera' (a nil value)"
Line 3919 of player.lua is simply camera:update(). Why is that not running? I'm assuming something isn't loading that is needed? But I have no idea what.
			 
			
					
				Re: Problem using aimAt command
				Posted: Sat Jan 30, 2016 7:20 pm
				by lisa
				If you are using a modified version of createpath then quite a lot of the bot functions wouldn't be loaded.
Try adding this to your code.
Code: Select all
	local cameraAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.camPtr_offset);
	if( cameraAddress == nil ) then cameraAddress = 0; end;
	camera = CCamera(cameraAddress);
There may be more needed to add/include but it would be a matter of trying and working out what is missing to be able to do what you want.
TBH it might be easier to just make up a WP file that does what you want for creating paths, that way every function in the bot will be active.
 
			
					
				Re: Problem using aimAt command
				Posted: Sun Jan 31, 2016 12:36 am
				by noobbotter
				Thanks Lisa. I was wondering earlier today if maybe I should make it a waypoint file instead.
I have another question. I have this file creating a table (with embedded tables) holding nodes, NPCs, MOBs, objects, and neighboring nodes. Now I'm at the point where I want to save this off into a file. Any idea how I might save a table like this into a file that I can later copy into a userfunction? I know doing a table.print doesn't make it look anything like the arrays we tend to use a lot. For example, this is the format we tend to use a lot:
Code: Select all
mytable = {
   [1] = {x = 1435, z = 6532, Neighbors = { 2, 4}, NPCs = {110532}, }
   [2] = {x = 1504, z = 6620, Neighbors = { 1, 3, 7}, MOBs= {110532}, }
   [3] = {x = 1435, z = 6532, Neighbors = { 2, 4}, NPCs = {110529}, }
}
But I'm not sure how to save my table info out into a format like that. Any ideas?
 
			
					
				Re: Problem using aimAt command
				Posted: Mon Feb 01, 2016 10:23 am
				by lisa
				Basically you want to save the exact thing you see that you posted into a file.
Here is an example that does more than you want but you can pick and choose what you need from it.
Code: Select all
local function savefile()
	local tmp_points = {};
	for i,v in pairs(worldmap.points) do
		table.insert(tmp_points, {index = i, value = v});
	end
	table.sort(tmp_points, function (a,b) return (a.index < b.index) end)
	file, err = io.open("rbmedit/pointssaved.lua", "w+");
	file:write("return {\n")
	for i,v in ipairs(tmp_points) do
		file:write("\t["..(v.index).."]={ X="..v.value.X.." , Z="..v.value.Z)
		if v.value.Y ~= nil then
			file:write(", Y="..v.value.Y)
		end
		if v.value.Name ~= nil then
			file:write(", Name=\""..v.value.Name.."\"")
		end
		file:write(", Links={")
		if v.value.Links ~= nil then
			for j,k in ipairs(v.value.Links) do
				if k.Num then
					file:write("["..j.."]={Num="..k.Num)
				end
				if k.Action then
					file:write(", Action=\""..k.Action.."\"")
				end
				file:write("},")
			end
			file:write("}")
		else
			file:write("}")
		end
	file:write("},\n")
	end
	file:write("}")
	file:close()
end
You also want to have
instead of the
Then to use the table in the file you just need to do
something like that anyway