Level Editing: Scripting

Talk about Severance Blade of Darkness modifications and maps here. No tips or tech support questions please, use the forum above. Note that the game is rated 18 so some content may be unsuitable for younger readers.

Moderators: Ade, prospero

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

2 hours later...

Postby cieply » Tue Jun 10, 2014 12:46 am

i spend 2 hours trying to find entry in Reference.EntitiesSelectionData dictionary for that object and it turned out so easy - just run it and it will automatically add element to dictionary and object is now just a monument
thx
Last edited by cieply on Thu Sep 04, 2014 5:17 pm, edited 1 time in total.
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

AddScheduledFunc() problem

Postby cieply » Tue Jun 10, 2014 4:55 pm

MyReference.py :

Code: Select all

# @ Lib/Widgets/ScorerWidgets::B_SmoothBarWidget SMOOTHBARWIDGET_DELAY=1.5 #def SmoothBarWidget_delay(delay=1.5): def SmoothBarWidget_delay(delay=None): global SMOOTHBARWIDGET_DELAY if (delay==None): return SMOOTHBARWIDGET_DELAY SMOOTHBARWIDGET_DELAY = delay # return delay # Bladex.AddScheduledFunc(Bladex.GetTime()+5.0, MyReference.SmoothBarWidget_delay, (1.5)) # in theory it should work ##
# when scheduled it refuses to work

import MyReference
Bladex.AddScheduledFunc(Bladex.GetTime()+5.0, MyReference.SmoothBarWidget_delay, (1.0))


when called normally, it works
MyReference.SmoothBarWidget_delay(1.0)

i'm totaly comfused because it's so simple that it should work
Last edited by cieply on Thu Sep 04, 2014 5:19 pm, edited 1 time in total.
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1675
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: Level Editing: Scripting

Postby prospero » Tue Jun 10, 2014 9:43 pm

One of those tricky Python things.......


Bladex.AddScheduledFunc(Bladex.GetTime()+5.0, MyReference.SmoothBarWidget_delay, (1.0))


Bladex.AddScheduledFunc(Bladex.GetTime()+5.0, MyReference.SmoothBarWidget_delay, (1.0,)) # this will work.


Spot the difference? :wink:

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

yeah, I spot a difference

Postby cieply » Wed Jun 11, 2014 12:56 am

and didn't know that it's a tuple that should be passed as parameter

now it works, thx
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

how to call in code built-in functions like "Next View"

Postby cieply » Thu Jun 12, 2014 5:21 pm

how to call in code built-in functions like "Next View"
in Config/Control.py :
Bladex.AssocKey("Next View","Keyboard","Add")
cannot find it in modules and there cannot be the function with space in name, is it?
l'aria fresca,
vino puro, ...

User avatar
Sryml
Dragon
Posts: 96
Joined: Tue Aug 28, 2012 12:50 pm
Location: China

Re: how to call in code built-in functions like "Next View"

Postby Sryml » Fri Jun 13, 2014 7:28 am

how to call in code built-in functions like "Next View"
In the "../../Scripts/acts.py", You can find this code:

Code: Select all

Bladex.AddBoundFunc("Next View","NextView")
Yes, the "NextView" is built-in function. But it looks to be a string.

I don't know how it works internally, but I found another way to accomplish the same work. :mrgreen:

Code: Select all

cam=Bladex.GetEntity("Camera") cam.PViewType=0 # or 1,2,3(There are four Perspective)
So, you can define a function to complete perspective switching.
Any Possibility!

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

Re: how to call in code built-in functions like "Next View"

Postby cieply » Fri Jun 13, 2014 2:26 pm

thanks for that, good workaround, maybe even better than function because I can immediately set view I want

nevertheless the question in general stays with no answer but it's worth of it
"NextView" does not seem to belong anywhere, certainly not in Bladex although this function is certainly defined in Blade.exe but not exported, maybe Bladex.AddBoundFunc() can be utilised somehow but I don't get it yet

btw. I found good way of checking modules using built-in python functions:

Code: Select all

dir(module-name) vars(module-name)
you can test them with any module, for example dir(Bladex)
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

pickup event

Postby cieply » Wed Jun 25, 2014 6:36 pm

how to use pickup event?
cannot find a solution
all I found is in Lib/Actions.py PickupEventHandler()
which generates event when item is picked up:

PickupEventHandler Player1, PickupEvent, BicheroRuins

but I still don't know how to use it
l'aria fresca,
vino puro, ...

BODnewbie2
Dragon
Posts: 50
Joined: Mon Dec 08, 2014 8:13 pm

Re: Level Editing: Scripting

Postby BODnewbie2 » Tue Jul 28, 2015 1:17 pm

As Harrison disappeared, can you help me in this post ? :roll:

http://www.arokhslair.net/forum/viewtop ... =11&t=3970

I'm searching all information to create characters

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

Re: help with this post

Postby cieply » Mon Aug 17, 2015 3:17 pm

what specifically do you mean?
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

sector OnEnter event

Postby cieply » Thu Jan 14, 2016 1:19 pm

I tried to utilise OnEnter event of sector.
I found some example in map's code but doesn't work.

Code: Select all

def f_BEETLE(): print 'def f_BEETLE():' sector_BEETLE.OnEnter="" sector_BEETLE2.OnEnter="" char = Bladex.GetEntity("Player1") print Bladex.GetSector(char.Position[0], char.Position[1], char.Position[2]).Index #def f_BEETLE(): sector_BEETLE = Bladex.GetSector(-24595.105589,16968.456436,34935.464395) sector_BEETLE.OnEnter = f_BEETLE sector_BEETLE2 = Bladex.GetSector(-24670.8450108, 15905.7950648, 36178.4678815) sector_BEETLE2.OnEnter = f_BEETLE
after entering the sector I have checked values in console and they are somewhat interesting:

Code: Select all

""" # console.log -- Bladex.GetSector(char.Position[0], char.Position[1], char.Position[2]) <B_PySector object at aff5198> sector_BEETLE <B_PySector object at fdfb20> sector_BEETLE2 <B_PySector object at fdcee0> Bladex.GetSector(char.Position[0], char.Position[1], char.Position[2]).Index 654 sector_BEETLE.Index 654 sector_BEETLE2.Index 654 """ # -- console.log
seems like there are different sector objects although same sector (has same index) but doesn't work anyway.

I also check forum and tried to use ``darfuncs.EnterSecEvent(x,y,z,func)''

Code: Select all

import darfuncs darfuncs.EnterSecEvent(-24595.105589,16968.456436,34935.464395, f_BEETLE)
but all I got was error:

Code: Select all

ERROR : OnEnter Asigned to <function f_BEETLE at 6c854c0> Traceback (innermost last): File "Blade input", line 1, in ? File "..\..\Lib\darfuncs.py", line 647, in EnterSecEvent EnterSecEventSector(sec,func) File "..\..\Lib\darfuncs.py", line 683, in EnterSecEventSector SectorTable[sec.Index].insert(0,func) KeyError: 654
so I'm stuck again though `KeyError: 654' looks exactly like sector's Index so
in act of desperation (so to speak) I tried to add my sector manually to darfuncs.SetorTable

Code: Select all

darfuncs.SectorTable['654']=[f_BEETLE] darfuncs.SectorTable[654]=[f_BEETLE]
and it's been added:

Code: Select all

print darfuncs.SectorTable (...) '654': [<function f_BEETLE at 6c854c0>], 'salealtaragua': [<function OnEnterSectorMusic at 6dffa08>], 654: [<function f_BEETLE at 6c854c0>], (...)
but didn't work either

I'm irritated that so simple thing refuses to work
l'aria fresca,
vino puro, ...

User avatar
Sryml
Dragon
Posts: 96
Joined: Tue Aug 28, 2012 12:50 pm
Location: China

Re: Level Editing: Scripting

Postby Sryml » Thu Jan 14, 2016 4:10 pm

Hi cieply, :)
f_BEETLE function requires two arguments, like this:

Code: Select all

def f_BEETLE(sectorindex,entityname): print 'def f_BEETLE():' sector_BEETLE.OnEnter="" sector_BEETLE2.OnEnter="" print Bladex.GetSector(char.Position[0], char.Position[1], char.Position[2]).Index sector_BEETLE = Bladex.GetSector(-24595.105589,16968.456436,34935.464395) sector_BEETLE.OnEnter = f_BEETLE sector_BEETLE2 = Bladex.GetSector(-24670.8450108, 15905.7950648, 36178.4678815) sector_BEETLE2.OnEnter = f_BEETLE
Any Possibility!

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

function requires two arguments

Postby cieply » Fri Jan 15, 2016 4:28 pm

thanks, it works
pro is pro after all :-)
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 289
Joined: Wed Jun 26, 2013 3:43 pm

there is still something wrong with this code

Postby cieply » Tue Jan 19, 2016 11:36 am

I added something to the code so it was doing something, not only print location

Code: Select all

sector_BEETLE = Bladex.GetSector(-24595.105589,16968.456436,34935.464395) #sector_BEETLE.OnEnter = PickUpLaLlave sector_BEETLE.OnEnter = f_BEETLE def f_BEETLE(sectorindex,entityname): print 'def f_BEETLE():' global sector_BEETLE # not sure whether it has to be global sector_BEETLE.OnEnter = "" char = Bladex.GetEntity("Player1") print "char.Position=", char.Position print "sector.Index=", Bladex.GetSector(char.Position[0], char.Position[1], char.Position[2]).Index PickUpLaLlave() ##
I tested it and was happy to see how it works, until I restarted the map...
Then game hanged. After enabling console logging I got this in return:

Code: Select all

BladeInit -> Executed Control.py Menu.py -> No GameCfg.py found Config file exed Activadas! (...) desert.sf trampas.sf poniendo el trigger sector def f_BEETLE(): char.Position= (-24062.7324487, -8328.80026054, 44065.7069402) sector.Index= 2337
if you remember it suppose to happen in sector with index 654 and this location is in the middle of the map - probably default starting location (not even one written in pj.py).
I don't get why it triggers this function right at the start but it shouldn't happen - I bet I miss something important here.
l'aria fresca,
vino puro, ...

User avatar
Sryml
Dragon
Posts: 96
Joined: Tue Aug 28, 2012 12:50 pm
Location: China

Re: there is still something wrong with this code

Postby Sryml » Tue Jan 19, 2016 5:01 pm

Maybe there are other things into the trigger sector, a torch, a table, a skull...etc. :roll:
Try print parameter "entityname". It will tell you what objects to enter the sector, and you can add a determine statements. :wink:

Code: Select all

def f_BEETLE(sectorindex,entityname): print 'def f_BEETLE():' print "entityname=", entityname if entityname=="Player1": global sector_BEETLE # not sure whether it has to be global sector_BEETLE.OnEnter = "" char = Bladex.GetEntity("Player1") print "char.Position=", char.Position print "sector.Index=", Bladex.GetSector(char.Position[0], char.Position[1], char.Position[2]).Index PickUpLaLlave()
Any Possibility!


Return to “Severance BoD: Modding Community”

Who is online

Users browsing this forum: No registered users and 1 guest