Post: Objects-related question
08-05-2016, 08:10 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); I was scrolling through some BO2 functions and found something that drawn my attention:

I found a piece of code that creates a spawnStruct() which, as I am aware, is designed to create objects information, like .something:

     myStruct = spawnStruct(); 


Now, my question is, how does one goes to knowing what to call that myStruct outside of that scope.

For instance, the game created an struct and now I want to retrieve it's name so I can use it somewhere else, since it was not a level. or self. type of variable I can't just use myStruct, so I was wondering if I re-created that thread, what would I have to do to print out it's name, so I can work with it outside the game, and applying it to my own function.
08-05-2016, 08:38 PM #2
anthonything
Space Ninja
Originally posted by Conditional View Post
I was scrolling through some BO2 functions and found something that drawn my attention:

I found a piece of code that creates a spawnStruct() which, as I am aware, is designed to create objects information, like .something:

     myStruct = spawnStruct(); 


Now, my question is, how does one goes to knowing what to call that myStruct outside of that scope.

For instance, the game created an struct and now I want to retrieve it's name so I can use it somewhere else, since it was not a level. or self. type of variable I can't just use myStruct, so I was wondering if I re-created that thread, what would I have to do to print out it's name, so I can work with it outside the game, and applying it to my own function.


You must use level to declare a global variable or return the struct from the function. There is no other way, as a local struct is lost after exiting the function.
08-05-2016, 08:50 PM #3
itsSorrow
In my man cave
Originally posted by Conditional View Post
I was scrolling through some BO2 functions and found something that drawn my attention:

I found a piece of code that creates a spawnStruct() which, as I am aware, is designed to create objects information, like .something:

     myStruct = spawnStruct(); 


Now, my question is, how does one goes to knowing what to call that myStruct outside of that scope.

For instance, the game created an struct and now I want to retrieve it's name so I can use it somewhere else, since it was not a level. or self. type of variable I can't just use myStruct, so I was wondering if I re-created that thread, what would I have to do to print out it's name, so I can work with it outside the game, and applying it to my own function.


ur back? lol
08-05-2016, 09:05 PM #4
Originally posted by anthonything View Post
You must use level to declare a global variable or return the struct from the function. There is no other way, as a local struct is lost after exiting the function.


Look, here's the thread I am looking at:

    
generate_zombie_buildable_piece( buildablename, modelname, radius, height, drop_offset, hud_icon, onpickup, ondrop, use_spawn_num, part_name, can_reuse, client_field_state, buildable_slot )
{
precachemodel( modelname );
precacheshader( hud_icon );
piece = spawnstruct();
buildable_pieces = [];
buildable_pieces_structs = getstructarray( buildablename + "_" + modelname, "targetname" );
/#
println( "ERROR: Missing buildable piece <" + buildablename + "> <" + modelname + ">\n" );
#/
foreach ( struct in buildable_pieces_structs )
{
buildable_pieces[index] = struct;
buildable_pieces[index].hasspawned = 0;
}
piece.spawns = buildable_pieces;
piece.buildablename = buildablename;
piece.modelname = modelname;
piece.hud_icon = hud_icon;
piece.radius = radius;
piece.height = height;
piece.part_name = part_name;
piece.can_reuse = can_reuse;
piece.drop_offset = drop_offset;
piece.max_instances = 256;
piece.buildable_slot = buildable_slot;
piece.buildable_slot = 0;
piece.onpickup = onpickup;
piece.ondrop = ondrop;
piece.use_spawn_num = use_spawn_num;
piece.client_field_state = client_field_state;
return piece;
}


I can save level.piece before the
     return piece;
but how can I print the name of "piece" or know the entity name, so I can modify it without the need of creating it?
08-05-2016, 09:06 PM #5
Originally posted by Gentle View Post
ur back? lol


I'm just working on some things, and I actually never left.
08-05-2016, 09:08 PM #6
Originally posted by anthonything View Post
You must use level to declare a global variable or return the struct from the function. There is no other way, as a local struct is lost after exiting the function.


Like, I can use level.piece, and it works, but I can't print the name, my main goal is to know the entity name so I can use it somewhere else, outside this thread. but first I need to know how to get it's name.
08-05-2016, 09:09 PM #7
itsSorrow
In my man cave
Originally posted by Conditional View Post
I'm just working on some things, and I actually never left.


U renamed ur channel and deleted like 90% of ur modding vids
08-05-2016, 09:13 PM #8
Originally posted by Gentle View Post
U renamed ur channel and deleted like 90% of ur modding vids


my youtube name is still conditional and all my modding videos are there.
08-05-2016, 09:18 PM #9
itsSorrow
In my man cave
Originally posted by Conditional View Post
my youtube name is still conditional and all my modding videos are there.


No u renamed it back.. it was called "indolgent" and not all... You had so many more like a COD4 azza modding proof vid..
08-05-2016, 09:23 PM #10
Originally posted by Gentle View Post
No u renamed it back.. it was called "indolgent" and not all... You had so many more like a COD4 azza modding proof vid..


Every video is there, I just unlisted my first bo2 azza one, please, stop commenting here if you don't know what I'm requesting, if you want to chit-chat dm me on twitter @lowkeynho

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo