Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Game/Datapacks/UI/CrotchCode/CodeBlocks/NpcIsHybrid.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
extends "res://Game/Datapacks/UI/CrotchCode/CodeBlockBase.gd"

var nameSlot := CrotchSlotVar.new()

func getCategories():
return ["NPC Manipulation"]

func _init():
nameSlot.setRawType(CrotchVarType.STRING)
nameSlot.setRawValue("")

func getType():
return CrotchBlocks.LOGIC

func execute(_contex:CodeContex):
var charName = nameSlot.getValue(_contex)
if(_contex.hadAnError()):
return
if(!isString(charName)):
throwError(_contex, "Character name must a string, got "+str(charName)+" instead")
return

return _contex.charMethod(charName, "getSpecies", [], []).size()>1


func getTemplate():
return [
{
type = "label",
text = "Is",
},
{
type = "slot",
id = "name",
slot = nameSlot,
slotType = CrotchBlocks.VALUE,
expand=true,
},
{
type = "label",
text = "a hybrid",
},
]

func getSlot(_id):
if(_id == "name"):
return nameSlot

func updateEditor(_editor):
if(_editor != null && _editor.has_method("getAllInvolvedCharIDs")):
nameSlot.setRawValue(_editor.getAllInvolvedCharIDs()[0] if _editor.getAllInvolvedCharIDs().size() > 0 else "")

func updateVisualSlot(_editor, _id, _visSlot):
if(_id == "name"):
if(_editor != null && _editor.has_method("getAllInvolvedCharIDs")):
_visSlot.setPossibleValues(_editor.getAllInvolvedCharIDs())
86 changes: 86 additions & 0 deletions Game/Datapacks/UI/CrotchCode/CodeBlocks/NpcIsSpecies.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
extends "res://Game/Datapacks/UI/CrotchCode/CodeBlockBase.gd"

var nameSlot := CrotchSlotVar.new()
var speciesSlot := CrotchSlotVar.new()

func getCategories():
return ["NPC Manipulation"]

func _init():
nameSlot.setRawType(CrotchVarType.STRING)
nameSlot.setRawValue("")
speciesSlot.setRawType(CrotchVarType.STRING)
var speciesKeys = GlobalRegistry.getAllSpecies().keys()
speciesSlot.setRawValue(speciesKeys[0] if speciesKeys.size()>0 else "")

func getType():
return CrotchBlocks.LOGIC

func execute(_contex:CodeContex):
var charName = nameSlot.getValue(_contex)
if(_contex.hadAnError()):
return
if(!isString(charName)):
throwError(_contex, "Character name must a string, got "+str(charName)+" instead")
return

var speciesId = speciesSlot.getValue(_contex)
if(_contex.hadAnError()):
return
if(!isString(speciesId)):
throwError(_contex, "Species must a string, got "+str(speciesId)+" instead")
return
if(!(speciesId in GlobalRegistry.getAllSpecies().keys())):
throwError(_contex, "Species with id "+speciesId+" doesn't exist. If your species is modded, make sure to have the mod loaded and add it as a requirement")
return



return (speciesId in _contex.charMethod(charName, "getSpecies", [], []))


func getTemplate():
return [
{
type = "label",
text = "Does",
},
{
type = "slot",
id = "name",
slot = nameSlot,
slotType = CrotchBlocks.VALUE,
expand=true,
},
{
type = "label",
text = "belong to the",
},
{
type = "slot",
id = "species",
slot = speciesSlot,
slotType = CrotchBlocks.VALUE,
},
{
type = "label",
text = "species",
},
]

func getSlot(_id):
if(_id == "name"):
return nameSlot
if(_id == "species"):
return speciesSlot

func updateEditor(_editor):
if(_editor != null && _editor.has_method("getAllInvolvedCharIDs")):
nameSlot.setRawValue(_editor.getAllInvolvedCharIDs()[0] if _editor.getAllInvolvedCharIDs().size() > 0 else "")

func updateVisualSlot(_editor, _id, _visSlot):
if(_id == "name"):
if(_editor != null && _editor.has_method("getAllInvolvedCharIDs")):
_visSlot.setPossibleValues(_editor.getAllInvolvedCharIDs())
if(_id == "species"):
_visSlot.setPossibleValues(GlobalRegistry.getAllSpecies().keys())
2 changes: 2 additions & 0 deletions Game/Datapacks/UI/CrotchCode/CrotchBlocks.gd
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ static func getAll():
"NpcGetPCRep",
"NpcAffectRelationship2",
"NpcGetRelationship2",
"NpcIsSpecies",
"NpcIsHybrid",

"TFCanHas",
"TFStartTF",
Expand Down