I have set up a production map (a grayscale image with splotches all over it) in order to determine what spots in my game are good for resources. It works, but it doesn't. None of the following return anything (they give 0.0) to fort\production. I have tested it however, and fort\production does exist. The readpixel command returns the right number, but the problem seems to lie in the spot where I divide it or multiply it. Why would this be?
Also, is there a way to just read a pixel on an image without using imagebuffer? Because either that method killed my framerate, or something very annoying is running in the background (probably the stupid firewall or virus scanner).
function buildFort(x,y,z,name$ = false) fort.fort = new fort fortNum = FortNum + 1 if name$ = false fort\name = "Fort " + fortnum else fort\name = name$ endif fort\x = x fort\y = terrainheight(terrain,x,z) * 128 fort\z = z fort\list_drawpage = 1 fort\buildradius = 50 fort\building = 5 ;this is to find the fort's production abilities, and shipping bonus ;setbuffer imagebuffer(prodMap) bittocomponent(readpixel(fort\x,fort\z,imagebuffer(prodMap))) ;divide red (should be the same value as every other colour) by 255 ;to get a number from 0 to 1 ;fort\Production = production# * 100 ;fort\Production# = ((B2Cr + 5) / 255) * 100 fort\Production# = 64 * 100 ;picking and drawing stuff e.entity = new entity e\entityForm = TradePost e\parent_id = handle(fort.fort) building = createcube() scaleentity building,rand(2,5),rand(2,4),rand(2,5),true positionentity building,fort\x,fort\y,fort\z,true TurnEntity building,0,rand(-180,180),0 entitycolor building,80,60,40 entitypickmode building,2 nameentity building,handle(e.entity) fort\pickID = handle(e.entity) end function ;the bitTocomponent function ; // Bit (argb) to Component (r,g,b) Function BitToComponent(ARGB) B2Cr=ARGB Shr 16 And $FF B2Cg=ARGB Shr 8 And $FF B2Cb=ARGB And $FF End Function ;AARGB! IT DOESN'T WORK!!! (this is fine, I mean the fort function)
Also, is there a way to just read a pixel on an image without using imagebuffer? Because either that method killed my framerate, or something very annoying is running in the background (probably the stupid firewall or virus scanner).