Scripts / Ifused field question

Author
Message
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Jan 2019 12:46
Is it possible to parse the ifused field into a variable?

So basically if i have a variable let's just say "bob" and set it to bob = 0 in the init, then if i put a number in the ifused field of the entity, can i take that number from the ifused field and change the bob variable to that number?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Jan 2019 13:49
no but you can use the strength or name field instead.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Jan 2019 14:48
ah, how would i convert the strength field to a variable?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 3rd Jan 2019 16:09
variable = g_Entity[ e ].health
Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Jan 2019 16:19
Ah great, i'm working on a set of scripts for basic quests and i want to make it as easy as possible for anyone to just use, so i thought to have it read the name field into a variable and have them number the entities to add them to the quest chains, but then i thought what if i wanted to prompt the name of the item, but if i can use the strength for the number variable, i can still use the name for the name prompt, that shouls work perfectly.

The only issue is obviously the strength part is how many hit points it has so if it's shot it will be destroyed, is it right you can make it unkillable by changing explodable to no? or is there another option needed to be set for that?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Jan 2019 16:29 Edited at: 3rd Jan 2019 16:37
I can't check at the moment because i am not at a pc with gameguru on, but i think this is right, can you proof read for me?

Basically the actual quest script will have each quest associated to g_qid and with this script on an object i'm hoping when you are close to the object it will prompt "Press E to collect the itemname" IF the number in the strength field is the same g_qid on the quest script, and when you press E it will progress g_qid on the quest script by one triggering the next quest and destroy the item.

Does it look right to you?


Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 3rd Jan 2019 18:00 Edited at: 3rd Jan 2019 18:03
Looks reasonable.

After the line g_qnum[e] = g_Entity[e].health put SetEntityHealth( e, 999999 ) or similar to make sure the entity can't be killed (or at least without an awful lot of hits ).

What I tend to do is use the name field and separate the values using '_' then split them out in the script, i.e. if you have a health collectable and you wanted it to give 20 health, have the name as 'health_20'.

The code to parse the string would look something like this:



Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Jan 2019 18:04
Wooah, that's just gone way over my head lol.

Thanks for the tips though Amen, as long as i know mine should work, i can work with it.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 3rd Jan 2019 20:39 Edited at: 3rd Jan 2019 20:47
Right been playing with it, had to make a few changes, nil fields and such, but i got it working, and also wrote a few more scripts.

So far there are two types of quest; a single item collection quest, and a multi item collection quest.

There is also a journal/tracker which is viewed and hidden by pressing the J key.

I'm trying to make the user setup of this system as easy as possible, all the user needs to do is:

1. Change the title and text info for each quest in "simplequest.lua" (5 quest slots by default, but more can be added by copy/pasting a slot and changing it's ID number).
2. Place a dynamic object in the map and in its properties panel change its strength field to the ID number of the quest it's to be associated with, and apply one of the two collect scripts to it.

For the collect script place only one item per number in the strength field.
For the multi collect script, place three objects with the same number in their strength field.

That's as easy as i can get it.

I'm also working on a quest trigger zone, and a use animated object (lever, button etc.) script.

Here's how it looks in game at the moment:



Once i have them sorted i will submit it to Lee and see if he will add it to GameGuru so we have at least a basic easy to use quest system by default. I've actually been meaning to do this for ages, but i couldn't work out how to avoid massive editing of scripts by users, then it hit me that i could use the name field to control the variables, and again it hit me after you guys helped me that i could use the strength field, thus cutting down the user edits drastically and making it more feasible as an easy quest system.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Blacknyt46
8
Years of Service
User Offline
Joined: 29th Feb 2016
Location:
Posted: 4th Jan 2019 10:27
Good job Belidos.
Jim C
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 4th Jan 2019 11:28 Edited at: 4th Jan 2019 11:43
Just had a thought, apparently you can write scripts so that you can have more than one piece of information in the name field, for example you could have the name as "a box,1" and read the part before the comma as the name and the part after the comma parsed as a variable, the code below works for converting a number in the name field as a variable, but how would i change it if i wanted to call it "box,1" and have the "box" part show as the name on the prompt, and the "1" part put into the g_qnum variable? I'd rather do it that way so as not to use up the strength field, or if i wanted to use it in a zone which doesn't have a strength field.


Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 4th Jan 2019 18:52
Look at my previous post!
Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 4th Jan 2019 20:28 Edited at: 4th Jan 2019 20:34
Yeah i saw that, i have no idea how that would fit in my script though.

Replace lines 7 an 8 with your 3 lines?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Jan 2019 20:59
yes basically, just change the _ to , in what you're looking for.
string.sub basically has 3 inputs;
1. the text to edit
2. the starting point
3. the end point
we're using string.find to find the start points and end points (i.e. the comma's), & +/- 1 because we don't want to display the comma


lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 4th Jan 2019 21:10 Edited at: 4th Jan 2019 21:13
Great, thanks guys ive learned a lot, i always apreciate your input.

I'll stick both your names in the credits when it's done

I'm not actually doing this for myself, theres a chap on the steam discussions complaining that fundamental basics like quest systems are missing from gsmeguru that should be default systems, and to be honest to a point i understand his view (i don't entirely agree but i understand) so im trying to write a series of scripts for a quest system that are as easy as possible for the user to set up, so i can send it to Lee for possible inclusion to gameguru so we at least have something basic by default for people who expect that sort of thing. Its about time i contributed something worthwhile.

Now that i know how to parse the name field with multiple info I will be able to actually give it a lot more options than originally planned.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 4th Jan 2019 22:48
If this sort of feature is something you think you can make use of I can add a function to utillib to parse a string and return a list of the sub strings based on separator, sort of like how args are handled in C programs.

Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 5th Jan 2019 12:59 Edited at: 5th Jan 2019 16:47
Here is the generic function


Simply call it like this:


Then you can access the values directly:


To make it even simpler I've defaulted the separator to a comma so if your string uses a comma separator simply call the function like so:
args[ e ] = GetArgs( name )
Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 5th Jan 2019 13:19
Thanks amenmoses, at first look im not sure i undrstand all that, but when i get time on the pc ill take a proper look and try to implement it in my scripts.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 7th Jan 2019 09:35 Edited at: 7th Jan 2019 09:39
I have been away from the PC for a while so haven't had a chance to do anything with it, but I've been reading through it, i'm not entirely certain how to add it to my script though, would the below work?



So if i for example called the objects barrel,1 this would set then g-name[e] to barrel, and g_num[e] to 1 right?

Looking at this, with this function i could have as many args as i like, so i could effectively add a third arg to the chain and have that define a variable that controls how many steps the quest has, so i wouldn't need a separate single or multi quest script?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 7th Jan 2019 19:39
Yes but put the GetArgs function at the top before the _init function.

Yes you can have as many arguments as you like as long as they are all separated by the same separator character.

If they are numeric remember to use tonumber() to convert them:

g_qnum[e] = tonumber( myArgs[ 2 ] )


for example.
Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 7th Jan 2019 20:45
Got it thanks

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 14th Jan 2019 12:26 Edited at: 15th Jan 2019 09:12
OK been trying all morning to get this to work Amen, it's just not having it.

I've set up a barrel, called it:

barrel,1

and given it the script below. It's supposed to prompt "Press E To collect the barrel" when you walk up to it, but nothing, nada, no error message, nowt at all happens, any ideas?


Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 14th Jan 2019 12:42
I've tried smallg's one too but i get the exact same result.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 14th Jan 2019 16:32
OK, managed to work out what was wrong with smallg's one, it was just a couple of the variables named wrong, checked Amen one but still can't get it working.

If i was to add a third variable (g_steps[E]) to smallg's method, what would i need to add/change?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th Jan 2019 19:41
You are specifying the separator as "_" when you are using ","!

Take out the separator part (as it defaults to "," in the function), i.e. just have:

args[ e ] = GetArgs( name )
Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 14th Jan 2019 20:00
Ah OK thanks amen, but i did also try it with _ but i kept getting nil errors, ill try again tomorrow with a fresh mind.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th Jan 2019 21:12
If you get nil errors tomorrow let me know what line number they are on and I'll try to figure out what's wrong.
Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 15th Jan 2019 08:11
Will do, thanks for the help.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 15th Jan 2019 17:12 Edited at: 15th Jan 2019 17:22
Been trying to get this to work all day, no joy. It just doesn't seem to parse the names into the tables, i place a barrel, i change it's name to Barrel,1,1 and add the attached script, and nothing happens, it doesn't even prompt.



Just a thought, my scripting laptop i use when at work (which i've been texting this on) only uses 1.14 because it's only a DX9 laptop, is this too early a version for the function you created?

If that is so, i would really like it to remain compatible with as many versions of GG as possible, so what and how would i change the method in the script smallg posted to include three parameters in the name?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Jan 2019 20:03
Was missing a few things.

Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 15th Jan 2019 21:41
Thanks Amen, that worked perfectly, i'm trying to do it myself, but that was stumping me. Very much appreciated mate.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Jan 2019 22:29
Part of the problem is that if an error occurs in the _init function it doesn't get reported on screen.

What I do nowadays is do my initialisation in the _main function the first time it runs. Only when it is all debugged and working fine do I move initialisation code into the _init function.
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-26 10:37:16
Your offset time is: 2024-04-26 10:37:16