![](https://forums.duke4.net/public/style_images/cgs/_custom/switch.png)
EDuke32 Scripting "CON coding help"
#1801 Posted 31 December 2015 - 05:18 AM
#1802 Posted 31 December 2015 - 07:16 AM
edit; foxs answer was on the next page I didn't get to read... opps
This post has been edited by Drek: 31 December 2015 - 07:17 AM
#1803 Posted 31 December 2015 - 09:19 AM
Fox, on 31 December 2015 - 05:18 AM, said:
This doesn't really delete sprites, for example the Box (spritenum 951) vanishes but if an RPG subsequently lands nearby it still catches fire.
Works fine for enemies though, provided you manually adjust the kill count with addkills 1.
TTFN,
Jon
#1804 Posted 31 December 2015 - 10:08 AM
#1805 Posted 31 December 2015 - 11:39 AM
Trooper Dan, on 31 December 2015 - 10:08 AM, said:
Ah-ha ... I have a number of per-sprite vars which are actually only used by a few non-decorative sprites, so I could changespritestat 1, set one of these now spare vars to flag as "delete me" which I can then detect in EVENT_GAME. Cheers.
TTFN,
Jon
#1806 Posted 03 January 2016 - 11:16 AM
#1807 Posted 03 January 2016 - 12:17 PM
Trooper Dan, on 03 January 2016 - 11:16 AM, said:
'Course, we 'ad it 'ard, we used to live in't shoe box in middle of t'road. Kids these days don't know they're born.
![:thumbsup:](https://forums.duke4.net/public/style_emoticons/default/smile.gif)
One debug thing I'd really like to see is being able to output text in addlogvar; I'm using temp1, temp2, temp3 ... etc shared between loads of functions, would be nice if I could have:
addlogvar temp1 spriteId
with text "spriteId" written to logfile instead of text "temp1". When trying to debug something with 3 or 4 "temp" vars dumped out it can get a trifle confusing.
TTFN,
Jon
#1808 Posted 03 January 2016 - 12:34 PM
The first is within actual CON functions as it'd be nice to detect if user could be alerted if they are using an incompatible version. For example:
Quote
r5492 | hendricks266 | 2015-12-26 07:41:59 -0800 (Sat, 26 Dec 2015) | 3 lines
Add new spriteflag SFLAG_GREENSLIMEFOOD = 8388608, which controls whether GREENSLIME will eat a given actor.
The flag is automatically set on LIZTROOP, LIZMAN, PIGCOP, and NEWBEAST, .....
Excellent ! Now NEWBEASTHANGING can be made edible like it should have been in the first place. But if I make a map that relies on this feature then it'd be nice to find some way of warning the player e.g. if old version of eduke then automatically open a door sector which exposes wall with writing on that tells them they have the wrong version.
The other version detection that'd be nice is to only include a CON file if version >= some number is running as that'd allow libraries to be able to utilise newer features whilst remaining backwards compatible as it were.
TTFN,
Jon
#1809 Posted 03 January 2016 - 01:29 PM
You could always use EVENT_INIT and echo a quote with a required version string. However if it's something that will error out on older versions then I have no idea.
#1810 Posted 03 January 2016 - 04:47 PM
addvar sprite[THISACTOR].z 1024
A great deal of writing CON code involves getting struct members into variables and then manipulating those variables before putting them back into the structs. It makes for a lot of typing and it reduces readability.
#1811 Posted 04 January 2016 - 01:58 AM
Mblackwell, on 03 January 2016 - 01:29 PM, said:
Kinda what I wanted to
Trooper Dan, on 03 January 2016 - 04:47 PM, said:
addvar sprite[THISACTOR].z 1024
I could hazard a guess (and only a guess). Firstly it is an example of a read-modify-write operation of which I can't think of any others, everything seems to be a read or a modify or a write.
Secondly I suspect the original code may not be that well structured, why else would there be a need to use seperate "addvar" and "addvarvar" for example ?
But maybe something has changed - I noticed recently (r5499) that "set" can now be used to replace setvarvar, if it replaces setvar as well then excellent
![:thumbsup:](https://forums.duke4.net/public/style_emoticons/default/dukeaffirmative.gif)
Trooper Dan, on 03 January 2016 - 04:47 PM, said:
Totally agree. It would also save a few temp vars for me as I often find I end up loading struct members into temp vars at start of a function as they get used in multiple paths of the code.
TTFN,
Jon
#1812 Posted 04 January 2016 - 02:24 AM
Trooper Dan, on 03 January 2016 - 04:47 PM, said:
addvar sprite[THISACTOR].z 1024
A great deal of writing CON code involves getting struct members into variables and then manipulating those variables before putting them back into the structs. It makes for a lot of typing and it reduces readability.
Because it would be better to use Lua instead of rewriting the entire CON language to become more useful.
This post has been edited by Fox: 04 January 2016 - 02:24 AM
#1813 Posted 04 January 2016 - 08:50 PM
Trooper Dan, on 03 January 2016 - 04:47 PM, said:
addvar sprite[THISACTOR].z 1024
It has to do with how we represent parameters in bytecode when we parse the CONs. We no longer think it would be prohibitively difficult, but instead a matter subject to cost/benefit analysis on our development time--something which is starting to tilt toward benefit thanks to the Bombshell prequel!
The Mechanic, on 04 January 2016 - 01:58 AM, said:
![:thumbsup:](https://forums.duke4.net/public/style_emoticons/default/dukeaffirmative.gif)
Yes!
#1814 Posted 04 January 2016 - 09:23 PM
The Mechanic, on 04 January 2016 - 01:58 AM, said:
![:thumbsup:](https://forums.duke4.net/public/style_emoticons/default/dukeaffirmative.gif)
Check out the list in the latest gamedef.c under "const tokenmap_t altkeyw"
#1815 Posted 09 January 2016 - 10:29 PM
Like when you shoot a mob that moves or you don't perfectly point at it, you will still hit it with your weapon.
#1817 Posted 09 January 2016 - 10:41 PM
Actors and user actor as long it has "enemy"
Not notenemy?
This post has been edited by Zaxtor: 09 January 2016 - 10:42 PM
#1818 Posted 09 January 2016 - 11:02 PM
Actors and Useractors as long as they are "enemy" type.
#1819 Posted 15 January 2016 - 10:40 AM
That makes floor and ceiling blockable, unblockable etc (good for tror etc)
But is there a version for walls , especially redlines wall.
Like making a redline wall blockable, unblockable etc.
Example we put the number of the line so it doesn't change all redlines in the sector.
Only let say wall 9510 that I wanna block or unblock?
#1820 Posted 15 January 2016 - 10:51 AM
Zaxtor, on 15 January 2016 - 10:40 AM, said:
That makes floor and ceiling blockable, unblockable etc (good for tror etc)
But is there a version for walls , especially redlines wall.
http://wiki.eduke32....Cstat%28wall%29
#1821 Posted 15 January 2016 - 11:23 AM
Trooper Dan, on 15 January 2016 - 10:51 AM, said:
I saw that but do I use it the same as the ceiling and floor?
#1822 Posted 15 January 2016 - 01:07 PM
#1823 Posted 15 January 2016 - 03:45 PM
Fox, on 15 January 2016 - 01:07 PM, said:
How we identify the wall's number since a sector has 3 walls and up.
So we don't "block all 3 walls at once"
cstat I wanna use is block and is 1 according to the site.
1 just like everything else.
When I use "setwall[THISACTOR].cstat 1"
nothing happens at all.
#1824 Posted 15 January 2016 - 03:54 PM
#1825 Posted 15 January 2016 - 04:11 PM
Fox, on 15 January 2016 - 03:54 PM, said:
Ok
btw
I know the wall's ID but I am sure is not setwall[14299].cstat 1
(14299 is the wall's ID / number)
This post has been edited by Zaxtor: 15 January 2016 - 04:11 PM
#1827 Posted 15 January 2016 - 05:36 PM
I'm way too confused
This post has been edited by Zaxtor: 15 January 2016 - 05:36 PM
#1828 Posted 16 January 2016 - 02:00 AM
Mblackwell, on 15 January 2016 - 05:33 PM, said:
If I recall it correctly, [] only accepts variables. For a good reason...
#1829 Posted 19 January 2016 - 05:09 AM
Initially what I tried was setting a flag when switch was pressed and in EVENT_SOUND checking if flag was set and grunt sound was being attempted and blocking it. Unfortunately, the code that decides Duke's path is blocked and plays the relevant sound occurs BEFORE event game and hence before I can set my flag. D'oh!
So, as a workaround, in the undocumented EVENT_WORLD I set a count to zero, then in EVENT_GAME if any of my blocking objects is within 1024 units of player then I increment the count. Then in EVENT_SOUND only allow grunts if count is zero. Hack ! (If I *want* to make the duke grunt sound, I set the counter to -30000 ... hack-squared!)
Now, if in mapster I set my switch as non-blocking then Duke never grunted. Strangely, if I set it to blocking but switched off blocking during initiaisation then Duke _did_ grunt. Suggests there is some statusy thing somewhere I need to set on my objects (it 'aint statnum, I checked).
Any ideas ?
TTFN,
Jon
#1830 Posted 19 January 2016 - 06:49 AM
Zaxtor, on 15 January 2016 - 10:40 AM, said:
That makes floor and ceiling blockable, unblockable etc (good for tror etc)
But is there a version for walls , especially redlines wall.
Like making a redline wall blockable, unblockable etc.
Example we put the number of the line so it doesn't change all redlines in the sector.
Only let say wall 9510 that I wanna block or unblock?
If you want to target a particular wall - I'm assuming it is in THISACTOR's sector - try making the wall the first wall of a sector. Then do something like the following (assumes you have a global gamevars "temp1" and "temp2"
getsector[THISACTOR].wallptr temp1 // = firstwall getwall[temp1].cstat temp2 orvar temp2 1 setwall[temp1].cstat temp2
TTFN,
Jon