Scripts / Mutliple Ifused Fields

Author
Message
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 16th May 2016 13:28
I am still a novice Lua scripter but it has occurred to me that it would very useful if each entity had several Ifused fields in its properties panel instead of just one. So, Ifused1, Ifused2, Ifused3, etc.

This would allow us to use ActiveIfUsed1(e), ActiveIfUsed2(e), ActiveIfUsed3(e), etc. in our scripts.

Currently, I often find myself having to use 3-4 different Lua scripts to create just one effect or event and it normally involves identifying and using the (e) of one or more different entities, which isn't ideal.

Multiple Ifused fields would, I think, lead to cleaner, less convoluted and more powerful scripting capabilitiesz.

Perhaps Lee could sneak this is along with the much anticipated LoadSound command as it is along similar lines....?
Julian
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 16th May 2016 16:14 Edited at: 16th May 2016 16:16
There is a SetActivated statement that is in the global.lua script that does such this thing.

function SetActivated(e,v)
g_Entity[e]['activated'] = v
SendMessageI("setactivated",e,v);
end

The way I am thinking about this command is that you would set up variables for the ifused objects you wanted and then the SetActivated to switch them out for you.

Having a way for the player to activate these either by triggerzone or object range might just do it.

You would need to take this to the script board with the idea, and I am sure one of the Guru's there can point you in the right direction.

Looking in the global.lua file again I spotted the Direct Call LUA commands at the bottom.

SetEntityActive: SetEntityActive ( e, active flag ) -- Sets the entity data directly, e is entity index
SetEntityActivated: SetEntityActivated ( e, activated flag ) -- Sets the entity data directly, e is entity index
SetEntityCollected: SetEntityCollected ( e, collected flag ) -- Sets the entity data directly, e is entity index
SetEntityHasKey : SetEntityHasKey ( e, haskey flag ) -- Sets the entity data directly, e is entity index
GetEntityVisibility : vis = GetEntityVisibility ( e ) -- where e is the entity number and return vis (0-hidden,1-shown)

These might make it even easier. I would talk with the coders, and I will move this thread to the scriptboard, where I believe it will get the attention it needs.

Would be easier to have these set in the properties panel, but I feel that it would start getting pretty cluttered with all the things users would like to see there, like textures, and other sounds, videos, decals, particle, then what are provided.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 16th May 2016 19:50
Great! Thanks, Myke!
Julian
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th May 2016 00:47
@ lordjulian

Sorry, you are looking 4 multiple "IfUsed" fields via script, and I comes with some script, non using "IfUsed" fields.

As far as I know, "IfUsed" fields looks like it was created just to work with "IfUsed" fields values, you set, via properties panel.
And it should be hardcode, just my thought.

I've tried this script with not to avail.



It does not reat as expected, no sure if my code is wrong, or something does not work properly.
I must add than I place 3 barrels (SpawnAtStart=no), 1 barrel as trigger with the script attached.
Even i've tried ie: setting barrel name (barrel1) in their "IfUsed" field, not to avail,
I've tried "SpawnIfUsed(n)", same result.

So finnally, I've tried this one, and it work, but is not the way, you are looking for.



This maybe give you some clue.

3com




Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 20th May 2016 12:23
Thanks, 3com. That looks useful.
Julian
PM
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 20th May 2016 12:33 Edited at: 20th May 2016 12:37
Also. I don't like having to note an entity's (e) number then put that into another entity's script to activate the first script. It would be nice to be able to have a script that would work without the need to know an entity's (e) so that when you delete entities the script doesn't break due to a change of entity number (e).

Does anyone know some way to activate an entity by its name instead of its (e) number? Seems like this is what ActivateIfUsed(e) does.
Julian
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th May 2016 20:08
Quote: "It would be nice to be able to have a script that would work without the need to know an entity's (e) so that when you delete entities the script doesn't break due to a change of entity number (e)."


It seems that GameGuru retains the number of the entity, even if you delete an entity.
In the video I try 3 different options.

1- Place 4 barrels on the map - each tells me, his entity number assigned .
2- remove an entity - All remaining barrels, retain their number entity.
3- Place another barrel on the map - The new barrel takes the number of previously released entity, or 2.

Sorry video quality does not good as usually, but do the trick.



Conclusion
Deletes / add a new entity, it does not affect the number of entity assigned to each. Just my thoughts.
hth

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st May 2016 00:59
you can find an entity by it's name but you need to store the name of the entity via it's own script first (this is currently the only way and so you must make the entity dynamic with said script)

in the init(e) you need to change the format to something like this


i would then do the same for the object that will reference said entities later so that you can store it's name as something similar to the objects you are looking for (i.e. main object is called "wave_spawn" and then some entities called "wave_spawn1", "wave_spawn2" etc)
i would then use something like a 'for' loop to go through and find the entities that match the main objects name + a number (based on which wave i wanted to spawn)
(in this case "wave_spawn") you would use something like this

you just need to also increase wave_number whenever you wanted to spawn the next entities in the sequence (and remember to define it)
*note* this method allows you to easily do the same for many different "groups" of entities
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 26th May 2016 20:47
Thanks!
Julian
PM

Login to post a reply

Server time is: 2024-12-22 17:17:28
Your offset time is: 2024-12-22 17:17:28