Creating and using an blocked Area for Constructions

Willkommen in der Transport Fever Community

Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.

 

Die Registrierung und Nutzung ist selbstverständlich kostenlos.

 

Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.

Das Team der Transport-Fever Community


  • Hello Modding Collegues,


    I've got a small Problem. For one of my new WIP-Mods i need a way to "block" an area. As all the positioning is totaly random i need to block the Area of an object, so the next object can't be build there. I tried to figure a way out to do this, but it seem to do not work. I've created some functions:


    The Table for Blocked Areas looks like this.

    Code
    Blocked_Areas = {}






    Every single Area is added with this.

    Code
    Blocked_Area[#Blocked_Area +1] = {low Y Pos, high Y Pos, low X Pos, high X Pos }



    1. check if the blocked Area is free


    2. create an block from Center

    Code
    function RPGFabi_Gardencalculation.createblock(X_Pos, Y_Pos, Width_X, Width_Y, safety_width)
    			local Table = {	
    				Y_Pos - Width_Y/2 - safety_width,
    				Y_Pos + Width_Y/2 + safety_width,
    				X_Pos - Width_X/2 - safety_width,
    				X_Pos + Width_X/2 + safety_width
    			}
    		end

    Width is the Distance from the first end of the object to the last end of the object
    safety width is the extra distance where nothing can be placed.


    3. show blocked Areas
    Place an Object at the side of every Block


    4. Create the m and b variable of an straight line out of 4 coordinates

    Code
    function RPGFabi_Gardencalculation.getLine(Einfahrt_Y, Einfahrt_X, Haus_Y, Haus_X)
    
    
    				local m = (Einfahrt_Y - Haus_Y) / (Einfahrt_X - Haus_X)			-- Steigung
    				local b = Einfahrt_X - (m * Einfahrt_Y)							-- Offset
    
    
    				local Table_Line = { m, b }
    			return Table_Line
    		end


    5. Use the Lines (2 create an groundface) to create an blocked Area. This should use small slices of the Area to create better blocked Areas


    Problem:


    It doesn't show me the blocks correct. As I don't know if they are created correct or not, which I need to check soon, I thought Hey maybe someone else got an easier way.


    Can someone help with the creation and use of an blocked Area Table?


    The Beginning would be the Table groundfaces use:


    Warum einfach, wenn es auch schwer geht?


  • I've got it :D


    Now i Have a Script that can block an given Area (with 4 Points), block an Area from Center, check if an Position is free, show blocked and show not blocked Areas.



    Of course the last 2 functions are only for development if everything works.


    Right now I'm thinking about Creating an own Mod (Script, Model & Texture) with it so every Modder can just require this Mod to get this functions done.


    What do you think about it?



    This is how it looks like if you are in Testing mode.

    Else it is invisible

    Warum einfach, wenn es auch schwer geht?


BlueBrixx